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