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