Show More
@@ -1,294 +1,294 b'' | |||
|
1 | 1 | # Nix environment for the community edition |
|
2 | 2 | # |
|
3 | 3 | # This shall be as lean as possible, just producing the enterprise-ce |
|
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 | # Configuration, set values in "~/.nixpkgs/config.nix". |
|
8 | 8 | # example |
|
9 | 9 | # { |
|
10 | 10 | # # Thoughts on how to configure the dev environment |
|
11 | 11 | # rc = { |
|
12 | 12 | # codeInternalUrl = "https://usr:token@code.rhodecode.com/internal"; |
|
13 | 13 | # sources = { |
|
14 | 14 | # rhodecode-vcsserver = "/home/user/work/rhodecode-vcsserver"; |
|
15 | 15 | # rhodecode-enterprise-ce = "/home/user/work/rhodecode-enterprise-ce"; |
|
16 | 16 | # rhodecode-enterprise-ee = "/home/user/work/rhodecode-enterprise-ee"; |
|
17 | 17 | # }; |
|
18 | 18 | # }; |
|
19 | 19 | # } |
|
20 | 20 | |
|
21 | 21 | args@ |
|
22 | 22 | { pythonPackages ? "python27Packages" |
|
23 | 23 | , pythonExternalOverrides ? self: super: {} |
|
24 | 24 | , doCheck ? false |
|
25 | 25 | , ... |
|
26 | 26 | }: |
|
27 | 27 | |
|
28 | 28 | let |
|
29 | 29 | pkgs_ = (import <nixpkgs> {}); |
|
30 | 30 | in |
|
31 | 31 | |
|
32 | 32 | let |
|
33 | 33 | pkgs = import <nixpkgs> { |
|
34 | 34 | overlays = [ |
|
35 | 35 | (import ./pkgs/overlays.nix) |
|
36 | 36 | ]; |
|
37 | 37 | inherit |
|
38 | 38 | (pkgs_) |
|
39 | 39 | system; |
|
40 | 40 | }; |
|
41 | 41 | |
|
42 | 42 | # Works with the new python-packages, still can fallback to the old |
|
43 | 43 | # variant. |
|
44 | 44 | basePythonPackagesUnfix = basePythonPackages.__unfix__ or ( |
|
45 | 45 | self: basePythonPackages.override (a: { inherit self; })); |
|
46 | 46 | |
|
47 | 47 | # Evaluates to the last segment of a file system path. |
|
48 | 48 | basename = path: with pkgs.lib; last (splitString "/" path); |
|
49 | 49 | |
|
50 | 50 | # source code filter used as arugment to builtins.filterSource. |
|
51 | 51 | src-filter = path: type: with pkgs.lib; |
|
52 | 52 | let |
|
53 | 53 | ext = last (splitString "." path); |
|
54 | 54 | in |
|
55 | 55 | !builtins.elem (basename path) [ |
|
56 | 56 | ".git" ".hg" "__pycache__" ".eggs" ".idea" ".dev" |
|
57 | 57 | "node_modules" "node_binaries" |
|
58 | 58 | "build" "data" "result" "tmp"] && |
|
59 | 59 | !builtins.elem ext ["egg-info" "pyc"] && |
|
60 | 60 | # TODO: johbo: This check is wrong, since "path" contains an absolute path, |
|
61 | 61 | # it would still be good to restore it since we want to ignore "result-*". |
|
62 | 62 | !hasPrefix "result" path; |
|
63 | 63 | |
|
64 | 64 | sources = |
|
65 | 65 | let |
|
66 | 66 | inherit |
|
67 | 67 | (pkgs.lib) |
|
68 | 68 | all |
|
69 | 69 | isString |
|
70 | 70 | attrValues; |
|
71 | 71 | sourcesConfig = pkgs.config.rc.sources or {}; |
|
72 | 72 | in |
|
73 | 73 | # Ensure that sources are configured as strings. Using a path |
|
74 | 74 | # would result in a copy into the nix store. |
|
75 | 75 | assert all isString (attrValues sourcesConfig); |
|
76 | 76 | sourcesConfig; |
|
77 | 77 | |
|
78 | 78 | version = builtins.readFile "${rhodecode-enterprise-ce-src}/rhodecode/VERSION"; |
|
79 | 79 | rhodecode-enterprise-ce-src = builtins.filterSource src-filter ./.; |
|
80 | 80 | |
|
81 | 81 | nodeEnv = import ./pkgs/node-default.nix { |
|
82 | 82 | inherit |
|
83 | 83 | pkgs; |
|
84 | 84 | }; |
|
85 | 85 | nodeDependencies = nodeEnv.shell.nodeDependencies; |
|
86 | 86 | |
|
87 | 87 | rhodecode-testdata-src = sources.rhodecode-testdata or ( |
|
88 | 88 | pkgs.fetchhg { |
|
89 | 89 | url = "https://code.rhodecode.com/upstream/rc_testdata"; |
|
90 | 90 | rev = "v0.10.0"; |
|
91 | 91 | sha256 = "0zn9swwvx4vgw4qn8q3ri26vvzgrxn15x6xnjrysi1bwmz01qjl0"; |
|
92 | 92 | }); |
|
93 | 93 | |
|
94 | 94 | rhodecode-testdata = import "${rhodecode-testdata-src}/default.nix" { |
|
95 | 95 | inherit |
|
96 | 96 | doCheck |
|
97 | 97 | pkgs |
|
98 | 98 | pythonPackages; |
|
99 | 99 | }; |
|
100 | 100 | |
|
101 | 101 | pythonLocalOverrides = self: super: { |
|
102 | 102 | rhodecode-enterprise-ce = |
|
103 | 103 | let |
|
104 | 104 | linkNodePackages = '' |
|
105 | 105 | export RHODECODE_CE_PATH=${rhodecode-enterprise-ce-src} |
|
106 | 106 | |
|
107 | 107 | echo "[BEGIN]: Link node packages and binaries" |
|
108 | 108 | # johbo: Linking individual packages allows us to run "npm install" |
|
109 | 109 | # inside of a shell to try things out. Re-entering the shell will |
|
110 | 110 | # restore a clean environment. |
|
111 | 111 | rm -fr node_modules |
|
112 | 112 | mkdir node_modules |
|
113 | 113 | ln -s ${nodeDependencies}/lib/node_modules/* node_modules/ |
|
114 | 114 | export NODE_PATH=./node_modules |
|
115 | 115 | |
|
116 | 116 | rm -fr node_binaries |
|
117 | 117 | mkdir node_binaries |
|
118 | 118 | ln -s ${nodeDependencies}/bin/* node_binaries/ |
|
119 | 119 | echo "[DONE ]: Link node packages and binaries" |
|
120 | 120 | ''; |
|
121 | 121 | |
|
122 | 122 | releaseName = "RhodeCodeEnterpriseCE-${version}"; |
|
123 | 123 | in super.rhodecode-enterprise-ce.override (attrs: { |
|
124 | 124 | inherit |
|
125 | 125 | doCheck |
|
126 | 126 | version; |
|
127 | 127 | |
|
128 | 128 | name = "rhodecode-enterprise-ce-${version}"; |
|
129 | 129 | releaseName = releaseName; |
|
130 | 130 | src = rhodecode-enterprise-ce-src; |
|
131 | 131 | dontStrip = true; # prevent strip, we don't need it. |
|
132 | 132 | |
|
133 | 133 | # expose following attributed outside |
|
134 | 134 | passthru = { |
|
135 | 135 | inherit |
|
136 | 136 | rhodecode-testdata |
|
137 | 137 | linkNodePackages |
|
138 | 138 | myPythonPackagesUnfix |
|
139 | 139 | pythonLocalOverrides |
|
140 | 140 | pythonCommunityOverrides; |
|
141 | 141 | |
|
142 | 142 | pythonPackages = self; |
|
143 | 143 | }; |
|
144 | 144 | |
|
145 | 145 | buildInputs = |
|
146 | 146 | attrs.buildInputs or [] ++ [ |
|
147 | 147 | rhodecode-testdata |
|
148 | 148 | ]; |
|
149 | 149 | |
|
150 | 150 | #NOTE: option to inject additional propagatedBuildInputs |
|
151 | 151 | propagatedBuildInputs = |
|
152 | 152 | attrs.propagatedBuildInputs or [] ++ [ |
|
153 | 153 | |
|
154 | 154 | ]; |
|
155 | 155 | |
|
156 | 156 | LC_ALL = "en_US.UTF-8"; |
|
157 | 157 | LOCALE_ARCHIVE = |
|
158 | 158 | if pkgs.stdenv.isLinux |
|
159 | 159 | then "${pkgs.glibcLocales}/lib/locale/locale-archive" |
|
160 | 160 | else ""; |
|
161 | 161 | |
|
162 | 162 | # Add bin directory to path so that tests can find 'rhodecode'. |
|
163 | 163 | preCheck = '' |
|
164 | 164 | export PATH="$out/bin:$PATH" |
|
165 | 165 | ''; |
|
166 | 166 | |
|
167 | 167 | # custom check phase for testing |
|
168 | 168 | checkPhase = '' |
|
169 | 169 | runHook preCheck |
|
170 | 170 | PYTHONHASHSEED=random py.test -vv -p no:sugar -r xw --cov-config=.coveragerc --cov=rhodecode --cov-report=term-missing rhodecode |
|
171 | 171 | runHook postCheck |
|
172 | 172 | ''; |
|
173 | 173 | |
|
174 | 174 | postCheck = '' |
|
175 | 175 | echo "Cleanup of rhodecode/tests" |
|
176 | 176 | rm -rf $out/lib/${self.python.libPrefix}/site-packages/rhodecode/tests |
|
177 | 177 | ''; |
|
178 | 178 | |
|
179 | 179 | preBuild = '' |
|
180 | 180 | echo "[BEGIN]: Building frontend assets" |
|
181 | 181 | ${linkNodePackages} |
|
182 | 182 | make web-build |
|
183 | 183 | rm -fr node_modules |
|
184 | 184 | rm -fr node_binaries |
|
185 | 185 | echo "[DONE ]: Building frontend assets" |
|
186 | 186 | ''; |
|
187 | 187 | |
|
188 | 188 | postInstall = '' |
|
189 | 189 | # check required files |
|
190 | 190 | STATIC_CHECK="/robots.txt /502.html |
|
191 | 191 | /js/scripts.js /js/rhodecode-components.js |
|
192 | 192 | /css/style.css /css/style-polymer.css" |
|
193 | 193 | |
|
194 | 194 | for file in $STATIC_CHECK; |
|
195 | 195 | do |
|
196 | 196 | if [ ! -f rhodecode/public/$file ]; then |
|
197 | 197 | echo "Missing $file" |
|
198 | 198 | exit 1 |
|
199 | 199 | fi |
|
200 | 200 | done |
|
201 | 201 | |
|
202 | 202 | echo "Writing enterprise-ce meta information for rccontrol to nix-support/rccontrol" |
|
203 | 203 | mkdir -p $out/nix-support/rccontrol |
|
204 | 204 | cp -v rhodecode/VERSION $out/nix-support/rccontrol/version |
|
205 | 205 | echo "[DONE ]: enterprise-ce meta information for rccontrol written" |
|
206 | 206 | |
|
207 | 207 | mkdir -p $out/etc |
|
208 | 208 | cp configs/production.ini $out/etc |
|
209 | 209 | echo "[DONE ]: saved enterprise-ce production.ini into $out/etc" |
|
210 | 210 | |
|
211 |
cp - |
|
|
211 | cp -Rf rhodecode/config/rcextensions $out/etc/rcextensions.tmpl | |
|
212 | 212 | echo "[DONE ]: saved enterprise-ce rcextensions into $out/etc/rcextensions.tmpl" |
|
213 | 213 | |
|
214 | 214 | # python based programs need to be wrapped |
|
215 | 215 | mkdir -p $out/bin |
|
216 | 216 | |
|
217 | 217 | # required binaries from dependencies |
|
218 | 218 | ln -s ${self.supervisor}/bin/supervisorctl $out/bin/ |
|
219 | 219 | ln -s ${self.supervisor}/bin/supervisord $out/bin/ |
|
220 | 220 | ln -s ${self.pastescript}/bin/paster $out/bin/ |
|
221 | 221 | ln -s ${self.channelstream}/bin/channelstream $out/bin/ |
|
222 | 222 | ln -s ${self.celery}/bin/celery $out/bin/ |
|
223 | 223 | ln -s ${self.gunicorn}/bin/gunicorn $out/bin/ |
|
224 | 224 | ln -s ${self.pyramid}/bin/prequest $out/bin/ |
|
225 | 225 | ln -s ${self.pyramid}/bin/pserve $out/bin/ |
|
226 | 226 | |
|
227 | 227 | echo "[DONE ]: created symlinks into $out/bin" |
|
228 | 228 | DEPS="$out/bin/supervisorctl \ |
|
229 | 229 | $out/bin/supervisord \ |
|
230 | 230 | $out/bin/paster \ |
|
231 | 231 | $out/bin/channelstream \ |
|
232 | 232 | $out/bin/celery \ |
|
233 | 233 | $out/bin/gunicorn \ |
|
234 | 234 | $out/bin/prequest \ |
|
235 | 235 | $out/bin/pserve" |
|
236 | 236 | |
|
237 | 237 | # wrap only dependency scripts, they require to have full PYTHONPATH set |
|
238 | 238 | # to be able to import all packages |
|
239 | 239 | for file in $DEPS; |
|
240 | 240 | do |
|
241 | 241 | wrapProgram $file \ |
|
242 | 242 | --prefix PATH : $PATH \ |
|
243 | 243 | --prefix PYTHONPATH : $PYTHONPATH \ |
|
244 | 244 | --set PYTHONHASHSEED random |
|
245 | 245 | done |
|
246 | 246 | |
|
247 | 247 | echo "[DONE ]: enterprise-ce binary wrapping" |
|
248 | 248 | |
|
249 | 249 | # rhodecode-tools don't need wrapping |
|
250 | 250 | ln -s ${self.rhodecode-tools}/bin/rhodecode-* $out/bin/ |
|
251 | 251 | |
|
252 | 252 | # expose sources of CE |
|
253 | 253 | ln -s $out $out/etc/rhodecode_enterprise_ce_source |
|
254 | 254 | |
|
255 | 255 | # expose static files folder |
|
256 | 256 | cp -Rf $out/lib/${self.python.libPrefix}/site-packages/rhodecode/public/ $out/etc/static |
|
257 | 257 | chmod 755 -R $out/etc/static |
|
258 | 258 | |
|
259 | 259 | ''; |
|
260 | 260 | }); |
|
261 | 261 | |
|
262 | 262 | }; |
|
263 | 263 | |
|
264 | 264 | basePythonPackages = with builtins; |
|
265 | 265 | if isAttrs pythonPackages then |
|
266 | 266 | pythonPackages |
|
267 | 267 | else |
|
268 | 268 | getAttr pythonPackages pkgs; |
|
269 | 269 | |
|
270 | 270 | pythonGeneratedPackages = import ./pkgs/python-packages.nix { |
|
271 | 271 | inherit |
|
272 | 272 | pkgs; |
|
273 | 273 | inherit |
|
274 | 274 | (pkgs) |
|
275 | 275 | fetchurl |
|
276 | 276 | fetchgit |
|
277 | 277 | fetchhg; |
|
278 | 278 | }; |
|
279 | 279 | |
|
280 | 280 | pythonCommunityOverrides = import ./pkgs/python-packages-overrides.nix { |
|
281 | 281 | inherit pkgs basePythonPackages; |
|
282 | 282 | }; |
|
283 | 283 | |
|
284 | 284 | # Apply all overrides and fix the final package set |
|
285 | 285 | myPythonPackagesUnfix = with pkgs.lib; |
|
286 | 286 | (extends pythonExternalOverrides |
|
287 | 287 | (extends pythonLocalOverrides |
|
288 | 288 | (extends pythonCommunityOverrides |
|
289 | 289 | (extends pythonGeneratedPackages |
|
290 | 290 | basePythonPackagesUnfix)))); |
|
291 | 291 | |
|
292 | 292 | myPythonPackages = (pkgs.lib.fix myPythonPackagesUnfix); |
|
293 | 293 | |
|
294 | 294 | in myPythonPackages.rhodecode-enterprise-ce |
General Comments 0
You need to be logged in to leave comments.
Login now