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