Show More
@@ -1,240 +1,241 b'' | |||
|
1 | 1 | # Nix environment for the community edition |
|
2 | 2 | # |
|
3 | 3 | # This shall be as lean as possible, just producing the Enterprise |
|
4 | 4 | # derivation. For advanced tweaks to pimp up the development environment we use |
|
5 | 5 | # "shell.nix" so that it does not have to clutter this file. |
|
6 | 6 | |
|
7 | 7 | args@ |
|
8 | 8 | { pythonPackages ? "python27Packages" |
|
9 | 9 | , pythonExternalOverrides ? self: super: {} |
|
10 | 10 | , doCheck ? true |
|
11 | 11 | , ... |
|
12 | 12 | }: |
|
13 | 13 | |
|
14 | 14 | let |
|
15 | 15 | |
|
16 | 16 | # Use nixpkgs from args or import them. We use this indirect approach |
|
17 | 17 | # through args to be able to use the name `pkgs` for our customized packages. |
|
18 | 18 | # Otherwise we will end up with an infinite recursion. |
|
19 | 19 | nixpkgs = args.pkgs or (import <nixpkgs> { }); |
|
20 | 20 | |
|
21 | 21 | # johbo: Interim bridge which allows us to build with the upcoming |
|
22 | 22 | # nixos.16.09 branch (unstable at the moment of writing this note) and the |
|
23 | 23 | # current stable nixos-16.03. |
|
24 | 24 | backwardsCompatibleFetchgit = { ... }@args: |
|
25 | 25 | let |
|
26 | 26 | origSources = nixpkgs.fetchgit args; |
|
27 | 27 | in |
|
28 | 28 | nixpkgs.lib.overrideDerivation origSources (oldAttrs: { |
|
29 | 29 | NIX_PREFETCH_GIT_CHECKOUT_HOOK = '' |
|
30 | 30 | find $out -name '.git*' -print0 | xargs -0 rm -rf |
|
31 | 31 | ''; |
|
32 | 32 | }); |
|
33 | 33 | |
|
34 | 34 | # Create a customized version of nixpkgs which should be used throughout the |
|
35 | 35 | # rest of this file. |
|
36 | 36 | pkgs = nixpkgs.overridePackages (self: super: { |
|
37 | 37 | fetchgit = backwardsCompatibleFetchgit; |
|
38 | 38 | }); |
|
39 | 39 | |
|
40 | 40 | # Evaluates to the last segment of a file system path. |
|
41 | 41 | basename = path: with pkgs.lib; last (splitString "/" path); |
|
42 | 42 | |
|
43 | 43 | # source code filter used as arugment to builtins.filterSource. |
|
44 | 44 | src-filter = path: type: with pkgs.lib; |
|
45 | 45 | let |
|
46 | 46 | ext = last (splitString "." path); |
|
47 | 47 | in |
|
48 | 48 | !builtins.elem (basename path) [ |
|
49 | 49 | ".git" ".hg" "__pycache__" ".eggs" |
|
50 | 50 | "bower_components" "node_modules" |
|
51 | 51 | "build" "data" "result" "tmp"] && |
|
52 | 52 | !builtins.elem ext ["egg-info" "pyc"] && |
|
53 | 53 | # TODO: johbo: This check is wrong, since "path" contains an absolute path, |
|
54 | 54 | # it would still be good to restore it since we want to ignore "result-*". |
|
55 | 55 | !hasPrefix "result" path; |
|
56 | 56 | |
|
57 | 57 | basePythonPackages = with builtins; if isAttrs pythonPackages |
|
58 | 58 | then pythonPackages |
|
59 | 59 | else getAttr pythonPackages pkgs; |
|
60 | 60 | |
|
61 | 61 | buildBowerComponents = |
|
62 | 62 | pkgs.buildBowerComponents or |
|
63 | 63 | (import ./pkgs/backport-16.03-build-bower-components.nix { inherit pkgs; }); |
|
64 | 64 | |
|
65 | 65 | sources = pkgs.config.rc.sources or {}; |
|
66 | 66 | version = builtins.readFile ./rhodecode/VERSION; |
|
67 | 67 | rhodecode-enterprise-ce-src = builtins.filterSource src-filter ./.; |
|
68 | 68 | |
|
69 | 69 | nodeEnv = import ./pkgs/node-default.nix { |
|
70 | 70 | inherit pkgs; |
|
71 | 71 | }; |
|
72 | 72 | nodeDependencies = nodeEnv.shell.nodeDependencies; |
|
73 | 73 | |
|
74 | 74 | bowerComponents = buildBowerComponents { |
|
75 | 75 | name = "enterprise-ce-${version}"; |
|
76 | 76 | generated = ./pkgs/bower-packages.nix; |
|
77 | 77 | src = rhodecode-enterprise-ce-src; |
|
78 | 78 | }; |
|
79 | 79 | |
|
80 | 80 | pythonGeneratedPackages = self: basePythonPackages.override (a: { |
|
81 | 81 | inherit self; |
|
82 | 82 | }) |
|
83 | 83 | // (scopedImport { |
|
84 | 84 | self = self; |
|
85 | 85 | super = basePythonPackages; |
|
86 | 86 | inherit pkgs; |
|
87 | 87 | inherit (pkgs) fetchurl fetchgit; |
|
88 | 88 | } ./pkgs/python-packages.nix); |
|
89 | 89 | |
|
90 | 90 | pythonOverrides = import ./pkgs/python-packages-overrides.nix { |
|
91 | 91 | inherit |
|
92 | 92 | basePythonPackages |
|
93 | 93 | pkgs; |
|
94 | 94 | }; |
|
95 | 95 | |
|
96 | 96 | pythonLocalOverrides = self: super: { |
|
97 | 97 | rhodecode-enterprise-ce = |
|
98 | 98 | let |
|
99 | 99 | linkNodeAndBowerPackages = '' |
|
100 | 100 | echo "Export RhodeCode CE path" |
|
101 | 101 | export RHODECODE_CE_PATH=${rhodecode-enterprise-ce-src} |
|
102 | 102 | echo "Link node packages" |
|
103 | 103 | rm -fr node_modules |
|
104 | 104 | mkdir node_modules |
|
105 | 105 | # johbo: Linking individual packages allows us to run "npm install" |
|
106 | 106 | # inside of a shell to try things out. Re-entering the shell will |
|
107 | 107 | # restore a clean environment. |
|
108 | 108 | ln -s ${nodeDependencies}/lib/node_modules/* node_modules/ |
|
109 | 109 | |
|
110 | 110 | echo "DONE: Link node packages" |
|
111 | 111 | |
|
112 | 112 | echo "Link bower packages" |
|
113 | 113 | rm -fr bower_components |
|
114 | 114 | mkdir bower_components |
|
115 | 115 | |
|
116 | 116 | ln -s ${bowerComponents}/bower_components/* bower_components/ |
|
117 | 117 | echo "DONE: Link bower packages" |
|
118 | 118 | ''; |
|
119 | 119 | in super.rhodecode-enterprise-ce.override (attrs: { |
|
120 | 120 | |
|
121 | 121 | inherit |
|
122 | 122 | doCheck |
|
123 | 123 | version; |
|
124 | 124 | name = "rhodecode-enterprise-ce-${version}"; |
|
125 | 125 | releaseName = "RhodeCodeEnterpriseCE-${version}"; |
|
126 | 126 | src = rhodecode-enterprise-ce-src; |
|
127 | dontStrip = true; # prevent strip, we don't need it. | |
|
127 | 128 | |
|
128 | 129 | buildInputs = |
|
129 | 130 | attrs.buildInputs ++ |
|
130 | 131 | (with self; [ |
|
131 | 132 | pkgs.nodePackages.bower |
|
132 | 133 | pkgs.nodePackages.grunt-cli |
|
133 | 134 | pkgs.subversion |
|
134 | 135 | pytest-catchlog |
|
135 | 136 | rhodecode-testdata |
|
136 | 137 | ]); |
|
137 | 138 | |
|
138 | 139 | #TODO: either move this into overrides, OR use the new machanics from |
|
139 | 140 | # pip2nix and requiremtn.txt file |
|
140 | 141 | propagatedBuildInputs = attrs.propagatedBuildInputs ++ (with self; [ |
|
141 | 142 | rhodecode-tools |
|
142 | 143 | ]); |
|
143 | 144 | |
|
144 | 145 | # TODO: johbo: Make a nicer way to expose the parts. Maybe |
|
145 | 146 | # pkgs/default.nix? |
|
146 | 147 | passthru = { |
|
147 | 148 | inherit |
|
148 | 149 | bowerComponents |
|
149 | 150 | linkNodeAndBowerPackages |
|
150 | 151 | myPythonPackagesUnfix |
|
151 | 152 | pythonLocalOverrides; |
|
152 | 153 | pythonPackages = self; |
|
153 | 154 | }; |
|
154 | 155 | |
|
155 | 156 | LC_ALL = "en_US.UTF-8"; |
|
156 | 157 | LOCALE_ARCHIVE = |
|
157 | 158 | if pkgs.stdenv ? glibc |
|
158 | 159 | then "${pkgs.glibcLocales}/lib/locale/locale-archive" |
|
159 | 160 | else ""; |
|
160 | 161 | |
|
161 | 162 | preCheck = '' |
|
162 | 163 | export PATH="$out/bin:$PATH" |
|
163 | 164 | ''; |
|
164 | 165 | |
|
165 | 166 | postCheck = '' |
|
166 | 167 | rm -rf $out/lib/${self.python.libPrefix}/site-packages/pytest_pylons |
|
167 | 168 | rm -rf $out/lib/${self.python.libPrefix}/site-packages/rhodecode/tests |
|
168 | 169 | ''; |
|
169 | 170 | |
|
170 | 171 | preBuild = linkNodeAndBowerPackages + '' |
|
171 | 172 | grunt |
|
172 | 173 | rm -fr node_modules |
|
173 | 174 | ''; |
|
174 | 175 | |
|
175 | 176 | postInstall = '' |
|
176 | 177 | # python based programs need to be wrapped |
|
177 | 178 | ln -s ${self.supervisor}/bin/supervisor* $out/bin/ |
|
178 | 179 | ln -s ${self.gunicorn}/bin/gunicorn $out/bin/ |
|
179 | 180 | ln -s ${self.PasteScript}/bin/paster $out/bin/ |
|
180 | 181 | ln -s ${self.channelstream}/bin/channelstream $out/bin/ |
|
181 | 182 | ln -s ${self.pyramid}/bin/* $out/bin/ #*/ |
|
182 | 183 | |
|
183 | 184 | # rhodecode-tools |
|
184 | 185 | # TODO: johbo: re-think this. Do the tools import anything from enterprise? |
|
185 | 186 | ln -s ${self.rhodecode-tools}/bin/rhodecode-* $out/bin/ |
|
186 | 187 | |
|
187 | 188 | # note that condition should be restricted when adding further tools |
|
188 | 189 | for file in $out/bin/*; do #*/ |
|
189 | 190 | wrapProgram $file \ |
|
190 | 191 | --prefix PYTHONPATH : $PYTHONPATH \ |
|
191 | 192 | --prefix PATH : $PATH \ |
|
192 | 193 | --set PYTHONHASHSEED random |
|
193 | 194 | done |
|
194 | 195 | |
|
195 | 196 | mkdir $out/etc |
|
196 | 197 | cp configs/production.ini $out/etc |
|
197 | 198 | |
|
198 | 199 | echo "Writing meta information for rccontrol to nix-support/rccontrol" |
|
199 | 200 | mkdir -p $out/nix-support/rccontrol |
|
200 | 201 | cp -v rhodecode/VERSION $out/nix-support/rccontrol/version |
|
201 | 202 | echo "DONE: Meta information for rccontrol written" |
|
202 | 203 | |
|
203 | 204 | # TODO: johbo: Make part of ac-tests |
|
204 | 205 | if [ ! -f rhodecode/public/js/scripts.js ]; then |
|
205 | 206 | echo "Missing scripts.js" |
|
206 | 207 | exit 1 |
|
207 | 208 | fi |
|
208 | 209 | if [ ! -f rhodecode/public/css/style.css ]; then |
|
209 | 210 | echo "Missing style.css" |
|
210 | 211 | exit 1 |
|
211 | 212 | fi |
|
212 | 213 | ''; |
|
213 | 214 | |
|
214 | 215 | }); |
|
215 | 216 | |
|
216 | 217 | rhodecode-testdata = import "${rhodecode-testdata-src}/default.nix" { |
|
217 | 218 | inherit |
|
218 | 219 | doCheck |
|
219 | 220 | pkgs |
|
220 | 221 | pythonPackages; |
|
221 | 222 | }; |
|
222 | 223 | |
|
223 | 224 | }; |
|
224 | 225 | |
|
225 | 226 | rhodecode-testdata-src = sources.rhodecode-testdata or ( |
|
226 | 227 | pkgs.fetchhg { |
|
227 | 228 | url = "https://code.rhodecode.com/upstream/rc_testdata"; |
|
228 | 229 | rev = "v0.9.0"; |
|
229 | 230 | sha256 = "0k0ccb7cncd6mmzwckfbr6l7fsymcympwcm948qc3i0f0m6bbg1y"; |
|
230 | 231 | }); |
|
231 | 232 | |
|
232 | 233 | # Apply all overrides and fix the final package set |
|
233 | 234 | myPythonPackagesUnfix = with pkgs.lib; |
|
234 | 235 | (extends pythonExternalOverrides |
|
235 | 236 | (extends pythonLocalOverrides |
|
236 | 237 | (extends pythonOverrides |
|
237 | 238 | pythonGeneratedPackages))); |
|
238 | 239 | myPythonPackages = (pkgs.lib.fix myPythonPackagesUnfix); |
|
239 | 240 | |
|
240 | 241 | in myPythonPackages.rhodecode-enterprise-ce |
General Comments 0
You need to be logged in to leave comments.
Login now