Show More
@@ -1,227 +1,228 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" "node_modules" |
|
44 | ".git" ".hg" "__pycache__" ".eggs" "node_modules" | |
45 | "build" "data" "tmp"] && |
|
45 | "build" "data" "tmp"] && | |
46 | !elem ext ["egg-info" "pyc"] && |
|
46 | !elem ext ["egg-info" "pyc"] && | |
47 | !startsWith "result" path; |
|
47 | !startsWith "result" path; | |
48 |
|
48 | |||
49 | sources = pkgs.config.rc.sources or {}; |
|
49 | sources = pkgs.config.rc.sources or {}; | |
50 | rhodecode-enterprise-ce-src = builtins.filterSource src-filter ./.; |
|
50 | rhodecode-enterprise-ce-src = builtins.filterSource src-filter ./.; | |
51 |
|
51 | |||
52 | # Load the generated node packages |
|
52 | # Load the generated node packages | |
53 | nodePackages = pkgs.callPackage "${pkgs.path}/pkgs/top-level/node-packages.nix" rec { |
|
53 | nodePackages = pkgs.callPackage "${pkgs.path}/pkgs/top-level/node-packages.nix" rec { | |
54 | self = nodePackages; |
|
54 | self = nodePackages; | |
55 | generated = pkgs.callPackage ./pkgs/node-packages.nix { inherit self; }; |
|
55 | generated = pkgs.callPackage ./pkgs/node-packages.nix { inherit self; }; | |
56 | }; |
|
56 | }; | |
57 |
|
57 | |||
58 | # TODO: Should be taken automatically out of the generates packages. |
|
58 | # TODO: Should be taken automatically out of the generates packages. | |
59 | # apps.nix has one solution for this, although I'd prefer to have the deps |
|
59 | # apps.nix has one solution for this, although I'd prefer to have the deps | |
60 | # from package.json mapped in here. |
|
60 | # from package.json mapped in here. | |
61 | nodeDependencies = with nodePackages; [ |
|
61 | nodeDependencies = with nodePackages; [ | |
62 | grunt |
|
62 | grunt | |
63 | grunt-contrib-concat |
|
63 | grunt-contrib-concat | |
64 | grunt-contrib-jshint |
|
64 | grunt-contrib-jshint | |
65 | grunt-contrib-less |
|
65 | grunt-contrib-less | |
66 | grunt-contrib-watch |
|
66 | grunt-contrib-watch | |
67 | jshint |
|
67 | jshint | |
68 | ]; |
|
68 | ]; | |
69 |
|
69 | |||
70 | pythonGeneratedPackages = self: basePythonPackages.override (a: { |
|
70 | pythonGeneratedPackages = self: basePythonPackages.override (a: { | |
71 | inherit self; |
|
71 | inherit self; | |
72 | }) |
|
72 | }) | |
73 | // (scopedImport { |
|
73 | // (scopedImport { | |
74 | self = self; |
|
74 | self = self; | |
75 | super = basePythonPackages; |
|
75 | super = basePythonPackages; | |
76 | inherit pkgs; |
|
76 | inherit pkgs; | |
77 | inherit (pkgs) fetchurl fetchgit; |
|
77 | inherit (pkgs) fetchurl fetchgit; | |
78 | } ./pkgs/python-packages.nix); |
|
78 | } ./pkgs/python-packages.nix); | |
79 |
|
79 | |||
80 | pythonOverrides = import ./pkgs/python-packages-overrides.nix { |
|
80 | pythonOverrides = import ./pkgs/python-packages-overrides.nix { | |
81 | inherit |
|
81 | inherit | |
82 | basePythonPackages |
|
82 | basePythonPackages | |
83 | pkgs; |
|
83 | pkgs; | |
84 | }; |
|
84 | }; | |
85 |
|
85 | |||
86 | pythonLocalOverrides = self: super: { |
|
86 | pythonLocalOverrides = self: super: { | |
87 | rhodecode-enterprise-ce = |
|
87 | rhodecode-enterprise-ce = | |
88 | let |
|
88 | let | |
89 | version = builtins.readFile ./rhodecode/VERSION; |
|
89 | version = builtins.readFile ./rhodecode/VERSION; | |
90 | linkNodeModules = '' |
|
90 | linkNodeModules = '' | |
91 | echo "Link node packages" |
|
91 | echo "Link node packages" | |
92 | # TODO: check if this adds stuff as a dependency, closure size |
|
92 | # TODO: check if this adds stuff as a dependency, closure size | |
93 | rm -fr node_modules |
|
93 | rm -fr node_modules | |
94 | mkdir -p node_modules |
|
94 | mkdir -p node_modules | |
95 | ${pkgs.lib.concatMapStrings (dep: '' |
|
95 | ${pkgs.lib.concatMapStrings (dep: '' | |
96 | ln -sfv ${dep}/lib/node_modules/${dep.pkgName} node_modules/ |
|
96 | ln -sfv ${dep}/lib/node_modules/${dep.pkgName} node_modules/ | |
97 | '') nodeDependencies} |
|
97 | '') nodeDependencies} | |
98 | echo "DONE: Link node packages" |
|
98 | echo "DONE: Link node packages" | |
99 | ''; |
|
99 | ''; | |
100 | in super.rhodecode-enterprise-ce.override (attrs: { |
|
100 | in super.rhodecode-enterprise-ce.override (attrs: { | |
101 |
|
101 | |||
102 | inherit |
|
102 | inherit | |
103 | doCheck |
|
103 | doCheck | |
104 | version; |
|
104 | version; | |
105 | name = "rhodecode-enterprise-ce-${version}"; |
|
105 | name = "rhodecode-enterprise-ce-${version}"; | |
106 | releaseName = "RhodeCodeEnterpriseCE-${version}"; |
|
106 | releaseName = "RhodeCodeEnterpriseCE-${version}"; | |
107 | src = rhodecode-enterprise-ce-src; |
|
107 | src = rhodecode-enterprise-ce-src; | |
108 |
|
108 | |||
109 | buildInputs = |
|
109 | buildInputs = | |
110 | attrs.buildInputs ++ |
|
110 | attrs.buildInputs ++ | |
111 | (with self; [ |
|
111 | (with self; [ | |
112 | pkgs.nodePackages.grunt-cli |
|
112 | pkgs.nodePackages.grunt-cli | |
113 | pkgs.subversion |
|
113 | pkgs.subversion | |
114 | pytest-catchlog |
|
114 | pytest-catchlog | |
115 | rhodecode-testdata |
|
115 | rhodecode-testdata | |
116 | ]); |
|
116 | ]); | |
117 |
|
117 | |||
118 | propagatedBuildInputs = attrs.propagatedBuildInputs ++ (with self; [ |
|
118 | propagatedBuildInputs = attrs.propagatedBuildInputs ++ (with self; [ | |
119 | rhodecode-tools |
|
119 | rhodecode-tools | |
120 | ]); |
|
120 | ]); | |
121 |
|
121 | |||
122 | # TODO: johbo: Make a nicer way to expose the parts. Maybe |
|
122 | # TODO: johbo: Make a nicer way to expose the parts. Maybe | |
123 | # pkgs/default.nix? |
|
123 | # pkgs/default.nix? | |
124 | passthru = { |
|
124 | passthru = { | |
125 | inherit |
|
125 | inherit | |
126 | pythonLocalOverrides |
|
126 | linkNodeModules | |
127 |
myPythonPackagesUnfix |
|
127 | myPythonPackagesUnfix | |
|
128 | pythonLocalOverrides; | |||
128 | pythonPackages = self; |
|
129 | pythonPackages = self; | |
129 | }; |
|
130 | }; | |
130 |
|
131 | |||
131 | LC_ALL = "en_US.UTF-8"; |
|
132 | LC_ALL = "en_US.UTF-8"; | |
132 | LOCALE_ARCHIVE = |
|
133 | LOCALE_ARCHIVE = | |
133 | if pkgs.stdenv ? glibc |
|
134 | if pkgs.stdenv ? glibc | |
134 | then "${pkgs.glibcLocales}/lib/locale/locale-archive" |
|
135 | then "${pkgs.glibcLocales}/lib/locale/locale-archive" | |
135 | else ""; |
|
136 | else ""; | |
136 |
|
137 | |||
137 | # Somewhat snappier setup of the development environment |
|
138 | # Somewhat snappier setup of the development environment | |
138 | # TODO: move into shell.nix |
|
139 | # TODO: move into shell.nix | |
139 | # TODO: think of supporting a stable path again, so that multiple shells |
|
140 | # TODO: think of supporting a stable path again, so that multiple shells | |
140 | # can share it. |
|
141 | # can share it. | |
141 | shellHook = '' |
|
142 | shellHook = '' | |
142 | tmp_path=$(mktemp -d) |
|
143 | tmp_path=$(mktemp -d) | |
143 | export PATH="$tmp_path/bin:$PATH" |
|
144 | export PATH="$tmp_path/bin:$PATH" | |
144 | export PYTHONPATH="$tmp_path/${self.python.sitePackages}:$PYTHONPATH" |
|
145 | export PYTHONPATH="$tmp_path/${self.python.sitePackages}:$PYTHONPATH" | |
145 | mkdir -p $tmp_path/${self.python.sitePackages} |
|
146 | mkdir -p $tmp_path/${self.python.sitePackages} | |
146 | python setup.py develop --prefix $tmp_path --allow-hosts "" |
|
147 | python setup.py develop --prefix $tmp_path --allow-hosts "" | |
147 | '' + linkNodeModules; |
|
148 | '' + linkNodeModules; | |
148 |
|
149 | |||
149 | preCheck = '' |
|
150 | preCheck = '' | |
150 | export PATH="$out/bin:$PATH" |
|
151 | export PATH="$out/bin:$PATH" | |
151 | ''; |
|
152 | ''; | |
152 |
|
153 | |||
153 | postCheck = '' |
|
154 | postCheck = '' | |
154 | rm -rf $out/lib/${self.python.libPrefix}/site-packages/pytest_pylons |
|
155 | rm -rf $out/lib/${self.python.libPrefix}/site-packages/pytest_pylons | |
155 | rm -rf $out/lib/${self.python.libPrefix}/site-packages/rhodecode/tests |
|
156 | rm -rf $out/lib/${self.python.libPrefix}/site-packages/rhodecode/tests | |
156 | ''; |
|
157 | ''; | |
157 |
|
158 | |||
158 | preBuild = linkNodeModules + '' |
|
159 | preBuild = linkNodeModules + '' | |
159 | grunt |
|
160 | grunt | |
160 | rm -fr node_modules |
|
161 | rm -fr node_modules | |
161 | ''; |
|
162 | ''; | |
162 |
|
163 | |||
163 | postInstall = '' |
|
164 | postInstall = '' | |
164 | # python based programs need to be wrapped |
|
165 | # python based programs need to be wrapped | |
165 | ln -s ${self.supervisor}/bin/supervisor* $out/bin/ |
|
166 | ln -s ${self.supervisor}/bin/supervisor* $out/bin/ | |
166 | ln -s ${self.gunicorn}/bin/gunicorn $out/bin/ |
|
167 | ln -s ${self.gunicorn}/bin/gunicorn $out/bin/ | |
167 | ln -s ${self.PasteScript}/bin/paster $out/bin/ |
|
168 | ln -s ${self.PasteScript}/bin/paster $out/bin/ | |
168 | ln -s ${self.pyramid}/bin/* $out/bin/ #*/ |
|
169 | ln -s ${self.pyramid}/bin/* $out/bin/ #*/ | |
169 |
|
170 | |||
170 | # rhodecode-tools |
|
171 | # rhodecode-tools | |
171 | # TODO: johbo: re-think this. Do the tools import anything from enterprise? |
|
172 | # TODO: johbo: re-think this. Do the tools import anything from enterprise? | |
172 | ln -s ${self.rhodecode-tools}/bin/rhodecode-* $out/bin/ |
|
173 | ln -s ${self.rhodecode-tools}/bin/rhodecode-* $out/bin/ | |
173 |
|
174 | |||
174 | # note that condition should be restricted when adding further tools |
|
175 | # note that condition should be restricted when adding further tools | |
175 | for file in $out/bin/*; do #*/ |
|
176 | for file in $out/bin/*; do #*/ | |
176 | wrapProgram $file \ |
|
177 | wrapProgram $file \ | |
177 | --prefix PYTHONPATH : $PYTHONPATH \ |
|
178 | --prefix PYTHONPATH : $PYTHONPATH \ | |
178 | --prefix PATH : $PATH \ |
|
179 | --prefix PATH : $PATH \ | |
179 | --set PYTHONHASHSEED random |
|
180 | --set PYTHONHASHSEED random | |
180 | done |
|
181 | done | |
181 |
|
182 | |||
182 | mkdir $out/etc |
|
183 | mkdir $out/etc | |
183 | cp configs/production.ini $out/etc |
|
184 | cp configs/production.ini $out/etc | |
184 |
|
185 | |||
185 | echo "Writing meta information for rccontrol to nix-support/rccontrol" |
|
186 | echo "Writing meta information for rccontrol to nix-support/rccontrol" | |
186 | mkdir -p $out/nix-support/rccontrol |
|
187 | mkdir -p $out/nix-support/rccontrol | |
187 | cp -v rhodecode/VERSION $out/nix-support/rccontrol/version |
|
188 | cp -v rhodecode/VERSION $out/nix-support/rccontrol/version | |
188 | echo "DONE: Meta information for rccontrol written" |
|
189 | echo "DONE: Meta information for rccontrol written" | |
189 |
|
190 | |||
190 | # TODO: johbo: Make part of ac-tests |
|
191 | # TODO: johbo: Make part of ac-tests | |
191 | if [ ! -f rhodecode/public/js/scripts.js ]; then |
|
192 | if [ ! -f rhodecode/public/js/scripts.js ]; then | |
192 | echo "Missing scripts.js" |
|
193 | echo "Missing scripts.js" | |
193 | exit 1 |
|
194 | exit 1 | |
194 | fi |
|
195 | fi | |
195 | if [ ! -f rhodecode/public/css/style.css ]; then |
|
196 | if [ ! -f rhodecode/public/css/style.css ]; then | |
196 | echo "Missing style.css" |
|
197 | echo "Missing style.css" | |
197 | exit 1 |
|
198 | exit 1 | |
198 | fi |
|
199 | fi | |
199 | ''; |
|
200 | ''; | |
200 |
|
201 | |||
201 | }); |
|
202 | }); | |
202 |
|
203 | |||
203 | rhodecode-testdata = import "${rhodecode-testdata-src}/default.nix" { |
|
204 | rhodecode-testdata = import "${rhodecode-testdata-src}/default.nix" { | |
204 | inherit |
|
205 | inherit | |
205 | doCheck |
|
206 | doCheck | |
206 | pkgs |
|
207 | pkgs | |
207 | pythonPackages; |
|
208 | pythonPackages; | |
208 | }; |
|
209 | }; | |
209 |
|
210 | |||
210 | }; |
|
211 | }; | |
211 |
|
212 | |||
212 | rhodecode-testdata-src = sources.rhodecode-testdata or ( |
|
213 | rhodecode-testdata-src = sources.rhodecode-testdata or ( | |
213 | pkgs.fetchhg { |
|
214 | pkgs.fetchhg { | |
214 | url = "https://code.rhodecode.com/upstream/rc_testdata"; |
|
215 | url = "https://code.rhodecode.com/upstream/rc_testdata"; | |
215 | rev = "v0.8.0"; |
|
216 | rev = "v0.8.0"; | |
216 | sha256 = "0hy1ba134rq2f9si85yx7j4qhc9ky0hjzdk553s3q026i7km809m"; |
|
217 | sha256 = "0hy1ba134rq2f9si85yx7j4qhc9ky0hjzdk553s3q026i7km809m"; | |
217 | }); |
|
218 | }); | |
218 |
|
219 | |||
219 | # Apply all overrides and fix the final package set |
|
220 | # Apply all overrides and fix the final package set | |
220 | myPythonPackagesUnfix = |
|
221 | myPythonPackagesUnfix = | |
221 | (extends pythonExternalOverrides |
|
222 | (extends pythonExternalOverrides | |
222 | (extends pythonLocalOverrides |
|
223 | (extends pythonLocalOverrides | |
223 | (extends pythonOverrides |
|
224 | (extends pythonOverrides | |
224 | pythonGeneratedPackages))); |
|
225 | pythonGeneratedPackages))); | |
225 | myPythonPackages = (fix myPythonPackagesUnfix); |
|
226 | myPythonPackages = (fix myPythonPackagesUnfix); | |
226 |
|
227 | |||
227 | in myPythonPackages.rhodecode-enterprise-ce |
|
228 | in myPythonPackages.rhodecode-enterprise-ce |
General Comments 0
You need to be logged in to leave comments.
Login now