Show More
@@ -1,243 +1,244 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 | args@ |
|
7 | args@ | |
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 |
|
13 | |||
14 | let |
|
14 | let | |
15 |
|
15 | |||
16 | # Use nixpkgs from args or import them. We use this indirect approach |
|
16 | # Use nixpkgs from args or import them. We use this indirect approach | |
17 | # through args to be able to use the name `pkgs` for our customized packages. |
|
17 | # through args to be able to use the name `pkgs` for our customized packages. | |
18 | # Otherwise we will end up with an infinite recursion. |
|
18 | # Otherwise we will end up with an infinite recursion. | |
19 | nixpkgs = args.pkgs or (import <nixpkgs> { }); |
|
19 | nixpkgs = args.pkgs or (import <nixpkgs> { }); | |
20 |
|
20 | |||
21 | # johbo: Interim bridge which allows us to build with the upcoming |
|
21 | # johbo: Interim bridge which allows us to build with the upcoming | |
22 | # nixos.16.09 branch (unstable at the moment of writing this note) and the |
|
22 | # nixos.16.09 branch (unstable at the moment of writing this note) and the | |
23 | # current stable nixos-16.03. |
|
23 | # current stable nixos-16.03. | |
24 | backwardsCompatibleFetchgit = { ... }@args: |
|
24 | backwardsCompatibleFetchgit = { ... }@args: | |
25 | let |
|
25 | let | |
26 | origSources = nixpkgs.fetchgit args; |
|
26 | origSources = nixpkgs.fetchgit args; | |
27 | in |
|
27 | in | |
28 | nixpkgs.lib.overrideDerivation origSources (oldAttrs: { |
|
28 | nixpkgs.lib.overrideDerivation origSources (oldAttrs: { | |
29 | NIX_PREFETCH_GIT_CHECKOUT_HOOK = '' |
|
29 | NIX_PREFETCH_GIT_CHECKOUT_HOOK = '' | |
30 | find $out -name '.git*' -print0 | xargs -0 rm -rf |
|
30 | find $out -name '.git*' -print0 | xargs -0 rm -rf | |
31 | ''; |
|
31 | ''; | |
32 | }); |
|
32 | }); | |
33 |
|
33 | |||
34 | # Create a customized version of nixpkgs which should be used throughout the |
|
34 | # Create a customized version of nixpkgs which should be used throughout the | |
35 | # rest of this file. |
|
35 | # rest of this file. | |
36 | pkgs = nixpkgs.overridePackages (self: super: { |
|
36 | pkgs = nixpkgs.overridePackages (self: super: { | |
37 | fetchgit = backwardsCompatibleFetchgit; |
|
37 | fetchgit = backwardsCompatibleFetchgit; | |
38 | }); |
|
38 | }); | |
39 |
|
39 | |||
40 | # Evaluates to the last segment of a file system path. |
|
40 | # Evaluates to the last segment of a file system path. | |
41 | basename = path: with pkgs.lib; last (splitString "/" path); |
|
41 | basename = path: with pkgs.lib; last (splitString "/" path); | |
42 |
|
42 | |||
43 | # source code filter used as arugment to builtins.filterSource. |
|
43 | # source code filter used as arugment to builtins.filterSource. | |
44 | src-filter = path: type: with pkgs.lib; |
|
44 | src-filter = path: type: with pkgs.lib; | |
45 | let |
|
45 | let | |
46 | ext = last (splitString "." path); |
|
46 | ext = last (splitString "." path); | |
47 | in |
|
47 | in | |
48 | !builtins.elem (basename path) [ |
|
48 | !builtins.elem (basename path) [ | |
49 | ".git" ".hg" "__pycache__" ".eggs" |
|
49 | ".git" ".hg" "__pycache__" ".eggs" | |
50 | "bower_components" "node_modules" |
|
50 | "bower_components" "node_modules" | |
51 | "build" "data" "result" "tmp"] && |
|
51 | "build" "data" "result" "tmp"] && | |
52 | !builtins.elem ext ["egg-info" "pyc"] && |
|
52 | !builtins.elem ext ["egg-info" "pyc"] && | |
53 | # TODO: johbo: This check is wrong, since "path" contains an absolute path, |
|
53 | # TODO: johbo: This check is wrong, since "path" contains an absolute path, | |
54 | # it would still be good to restore it since we want to ignore "result-*". |
|
54 | # it would still be good to restore it since we want to ignore "result-*". | |
55 | !hasPrefix "result" path; |
|
55 | !hasPrefix "result" path; | |
56 |
|
56 | |||
57 | basePythonPackages = with builtins; if isAttrs pythonPackages |
|
57 | basePythonPackages = with builtins; if isAttrs pythonPackages | |
58 | then pythonPackages |
|
58 | then pythonPackages | |
59 | else getAttr pythonPackages pkgs; |
|
59 | else getAttr pythonPackages pkgs; | |
60 |
|
60 | |||
61 | buildBowerComponents = |
|
61 | buildBowerComponents = | |
62 | pkgs.buildBowerComponents or |
|
62 | pkgs.buildBowerComponents or | |
63 | (import ./pkgs/backport-16.03-build-bower-components.nix { inherit pkgs; }); |
|
63 | (import ./pkgs/backport-16.03-build-bower-components.nix { inherit pkgs; }); | |
64 |
|
64 | |||
65 | sources = pkgs.config.rc.sources or {}; |
|
65 | sources = pkgs.config.rc.sources or {}; | |
66 | version = builtins.readFile ./rhodecode/VERSION; |
|
66 | version = builtins.readFile ./rhodecode/VERSION; | |
67 | rhodecode-enterprise-ce-src = builtins.filterSource src-filter ./.; |
|
67 | rhodecode-enterprise-ce-src = builtins.filterSource src-filter ./.; | |
68 |
|
68 | |||
69 | nodeEnv = import ./pkgs/node-default.nix { |
|
69 | nodeEnv = import ./pkgs/node-default.nix { | |
70 | inherit pkgs; |
|
70 | inherit pkgs; | |
71 | }; |
|
71 | }; | |
72 | nodeDependencies = nodeEnv.shell.nodeDependencies; |
|
72 | nodeDependencies = nodeEnv.shell.nodeDependencies; | |
73 |
|
73 | |||
74 | bowerComponents = buildBowerComponents { |
|
74 | bowerComponents = buildBowerComponents { | |
75 | name = "enterprise-ce-${version}"; |
|
75 | name = "enterprise-ce-${version}"; | |
76 | generated = ./pkgs/bower-packages.nix; |
|
76 | generated = ./pkgs/bower-packages.nix; | |
77 | src = rhodecode-enterprise-ce-src; |
|
77 | src = rhodecode-enterprise-ce-src; | |
78 | }; |
|
78 | }; | |
79 |
|
79 | |||
80 | pythonGeneratedPackages = self: basePythonPackages.override (a: { |
|
80 | pythonGeneratedPackages = self: basePythonPackages.override (a: { | |
81 | inherit self; |
|
81 | inherit self; | |
82 | }) |
|
82 | }) | |
83 | // (scopedImport { |
|
83 | // (scopedImport { | |
84 | self = self; |
|
84 | self = self; | |
85 | super = basePythonPackages; |
|
85 | super = basePythonPackages; | |
86 | inherit pkgs; |
|
86 | inherit pkgs; | |
87 | inherit (pkgs) fetchurl fetchgit; |
|
87 | inherit (pkgs) fetchurl fetchgit; | |
88 | } ./pkgs/python-packages.nix); |
|
88 | } ./pkgs/python-packages.nix); | |
89 |
|
89 | |||
90 | pythonOverrides = import ./pkgs/python-packages-overrides.nix { |
|
90 | pythonOverrides = import ./pkgs/python-packages-overrides.nix { | |
91 | inherit |
|
91 | inherit | |
92 | basePythonPackages |
|
92 | basePythonPackages | |
93 | pkgs; |
|
93 | pkgs; | |
94 | }; |
|
94 | }; | |
95 |
|
95 | |||
96 | pythonLocalOverrides = self: super: { |
|
96 | pythonLocalOverrides = self: super: { | |
97 | rhodecode-enterprise-ce = |
|
97 | rhodecode-enterprise-ce = | |
98 | let |
|
98 | let | |
99 | linkNodeAndBowerPackages = '' |
|
99 | linkNodeAndBowerPackages = '' | |
100 | echo "Export RhodeCode CE path" |
|
100 | echo "Export RhodeCode CE path" | |
101 | export RHODECODE_CE_PATH=${rhodecode-enterprise-ce-src} |
|
101 | export RHODECODE_CE_PATH=${rhodecode-enterprise-ce-src} | |
102 | echo "Link node packages" |
|
102 | echo "Link node packages" | |
103 | rm -fr node_modules |
|
103 | rm -fr node_modules | |
104 | mkdir node_modules |
|
104 | mkdir node_modules | |
105 | # johbo: Linking individual packages allows us to run "npm install" |
|
105 | # johbo: Linking individual packages allows us to run "npm install" | |
106 | # inside of a shell to try things out. Re-entering the shell will |
|
106 | # inside of a shell to try things out. Re-entering the shell will | |
107 | # restore a clean environment. |
|
107 | # restore a clean environment. | |
108 | ln -s ${nodeDependencies}/lib/node_modules/* node_modules/ |
|
108 | ln -s ${nodeDependencies}/lib/node_modules/* node_modules/ | |
109 |
|
109 | |||
110 | echo "DONE: Link node packages" |
|
110 | echo "DONE: Link node packages" | |
111 |
|
111 | |||
112 | echo "Link bower packages" |
|
112 | echo "Link bower packages" | |
113 | rm -fr bower_components |
|
113 | rm -fr bower_components | |
114 | mkdir bower_components |
|
114 | mkdir bower_components | |
115 |
|
115 | |||
116 | ln -s ${bowerComponents}/bower_components/* bower_components/ |
|
116 | ln -s ${bowerComponents}/bower_components/* bower_components/ | |
117 | echo "DONE: Link bower packages" |
|
117 | echo "DONE: Link bower packages" | |
118 | ''; |
|
118 | ''; | |
119 | in super.rhodecode-enterprise-ce.override (attrs: { |
|
119 | in super.rhodecode-enterprise-ce.override (attrs: { | |
120 |
|
120 | |||
121 | inherit |
|
121 | inherit | |
122 | doCheck |
|
122 | doCheck | |
123 | version; |
|
123 | version; | |
124 | name = "rhodecode-enterprise-ce-${version}"; |
|
124 | name = "rhodecode-enterprise-ce-${version}"; | |
125 | releaseName = "RhodeCodeEnterpriseCE-${version}"; |
|
125 | releaseName = "RhodeCodeEnterpriseCE-${version}"; | |
126 | src = rhodecode-enterprise-ce-src; |
|
126 | src = rhodecode-enterprise-ce-src; | |
127 | dontStrip = true; # prevent strip, we don't need it. |
|
127 | dontStrip = true; # prevent strip, we don't need it. | |
128 |
|
128 | |||
129 | buildInputs = |
|
129 | buildInputs = | |
130 | attrs.buildInputs ++ |
|
130 | attrs.buildInputs ++ | |
131 | (with self; [ |
|
131 | (with self; [ | |
132 | pkgs.nodePackages.bower |
|
132 | pkgs.nodePackages.bower | |
133 | pkgs.nodePackages.grunt-cli |
|
133 | pkgs.nodePackages.grunt-cli | |
134 | pkgs.subversion |
|
134 | pkgs.subversion | |
135 | pytest-catchlog |
|
135 | pytest-catchlog | |
136 | rhodecode-testdata |
|
136 | rhodecode-testdata | |
137 | ]); |
|
137 | ]); | |
138 |
|
138 | |||
139 | #TODO: either move this into overrides, OR use the new machanics from |
|
139 | #TODO: either move this into overrides, OR use the new machanics from | |
140 | # pip2nix and requiremtn.txt file |
|
140 | # pip2nix and requiremtn.txt file | |
141 | propagatedBuildInputs = attrs.propagatedBuildInputs ++ (with self; [ |
|
141 | propagatedBuildInputs = attrs.propagatedBuildInputs ++ (with self; [ | |
142 | rhodecode-tools |
|
142 | rhodecode-tools | |
143 | ]); |
|
143 | ]); | |
144 |
|
144 | |||
145 | # TODO: johbo: Make a nicer way to expose the parts. Maybe |
|
145 | # TODO: johbo: Make a nicer way to expose the parts. Maybe | |
146 | # pkgs/default.nix? |
|
146 | # pkgs/default.nix? | |
147 | passthru = { |
|
147 | passthru = { | |
148 | inherit |
|
148 | inherit | |
149 | bowerComponents |
|
149 | bowerComponents | |
150 | linkNodeAndBowerPackages |
|
150 | linkNodeAndBowerPackages | |
151 | myPythonPackagesUnfix |
|
151 | myPythonPackagesUnfix | |
152 | pythonLocalOverrides; |
|
152 | pythonLocalOverrides; | |
153 | pythonPackages = self; |
|
153 | pythonPackages = self; | |
154 | }; |
|
154 | }; | |
155 |
|
155 | |||
156 | LC_ALL = "en_US.UTF-8"; |
|
156 | LC_ALL = "en_US.UTF-8"; | |
157 | LOCALE_ARCHIVE = |
|
157 | LOCALE_ARCHIVE = | |
158 | if pkgs.stdenv ? glibc |
|
158 | if pkgs.stdenv ? glibc | |
159 | then "${pkgs.glibcLocales}/lib/locale/locale-archive" |
|
159 | then "${pkgs.glibcLocales}/lib/locale/locale-archive" | |
160 | else ""; |
|
160 | else ""; | |
161 |
|
161 | |||
162 | preCheck = '' |
|
162 | preCheck = '' | |
163 | export PATH="$out/bin:$PATH" |
|
163 | export PATH="$out/bin:$PATH" | |
164 | ''; |
|
164 | ''; | |
165 |
|
165 | |||
166 | postCheck = '' |
|
166 | postCheck = '' | |
167 | rm -rf $out/lib/${self.python.libPrefix}/site-packages/pytest_pylons |
|
167 | rm -rf $out/lib/${self.python.libPrefix}/site-packages/pytest_pylons | |
168 | rm -rf $out/lib/${self.python.libPrefix}/site-packages/rhodecode/tests |
|
168 | rm -rf $out/lib/${self.python.libPrefix}/site-packages/rhodecode/tests | |
169 | ''; |
|
169 | ''; | |
170 |
|
170 | |||
171 | preBuild = linkNodeAndBowerPackages + '' |
|
171 | preBuild = linkNodeAndBowerPackages + '' | |
172 | grunt |
|
172 | grunt | |
173 | rm -fr node_modules |
|
173 | rm -fr node_modules | |
174 | ''; |
|
174 | ''; | |
175 |
|
175 | |||
176 | postInstall = '' |
|
176 | postInstall = '' | |
177 | echo "Writing meta information for rccontrol to nix-support/rccontrol" |
|
177 | echo "Writing meta information for rccontrol to nix-support/rccontrol" | |
178 | mkdir -p $out/nix-support/rccontrol |
|
178 | mkdir -p $out/nix-support/rccontrol | |
179 | cp -v rhodecode/VERSION $out/nix-support/rccontrol/version |
|
179 | cp -v rhodecode/VERSION $out/nix-support/rccontrol/version | |
180 | echo "DONE: Meta information for rccontrol written" |
|
180 | echo "DONE: Meta information for rccontrol written" | |
181 |
|
181 | |||
182 | # python based programs need to be wrapped |
|
182 | # python based programs need to be wrapped | |
|
183 | #ln -s ${self.python}/bin/* $out/bin/ | |||
183 | ln -s ${self.pyramid}/bin/* $out/bin/ |
|
184 | ln -s ${self.pyramid}/bin/* $out/bin/ | |
184 | ln -s ${self.gunicorn}/bin/gunicorn $out/bin/ |
|
185 | ln -s ${self.gunicorn}/bin/gunicorn $out/bin/ | |
185 | ln -s ${self.supervisor}/bin/supervisor* $out/bin/ |
|
186 | ln -s ${self.supervisor}/bin/supervisor* $out/bin/ | |
186 | ln -s ${self.pastescript}/bin/paster $out/bin/ |
|
187 | ln -s ${self.pastescript}/bin/paster $out/bin/ | |
187 | ln -s ${self.channelstream}/bin/channelstream $out/bin/ |
|
188 | ln -s ${self.channelstream}/bin/channelstream $out/bin/ | |
188 | ln -s ${self.celery}/bin/celery $out/bin/ |
|
189 | ln -s ${self.celery}/bin/celery $out/bin/ | |
189 |
|
190 | |||
190 | # rhodecode-tools |
|
191 | # rhodecode-tools | |
191 | ln -s ${self.rhodecode-tools}/bin/rhodecode-* $out/bin/ |
|
192 | ln -s ${self.rhodecode-tools}/bin/rhodecode-* $out/bin/ | |
192 |
|
193 | |||
193 | # note that condition should be restricted when adding further tools |
|
194 | # note that condition should be restricted when adding further tools | |
194 | for file in $out/bin/*; |
|
195 | for file in $out/bin/*; | |
195 | do |
|
196 | do | |
196 | wrapProgram $file \ |
|
197 | wrapProgram $file \ | |
197 | --prefix PATH : $PATH \ |
|
198 | --prefix PATH : $PATH \ | |
198 | --prefix PYTHONPATH : $PYTHONPATH \ |
|
199 | --prefix PYTHONPATH : $PYTHONPATH \ | |
199 | --set PYTHONHASHSEED random |
|
200 | --set PYTHONHASHSEED random | |
200 | done |
|
201 | done | |
201 |
|
202 | |||
202 | mkdir $out/etc |
|
203 | mkdir $out/etc | |
203 | cp configs/production.ini $out/etc |
|
204 | cp configs/production.ini $out/etc | |
204 |
|
205 | |||
205 |
|
206 | |||
206 | # TODO: johbo: Make part of ac-tests |
|
207 | # TODO: johbo: Make part of ac-tests | |
207 | if [ ! -f rhodecode/public/js/scripts.js ]; then |
|
208 | if [ ! -f rhodecode/public/js/scripts.js ]; then | |
208 | echo "Missing scripts.js" |
|
209 | echo "Missing scripts.js" | |
209 | exit 1 |
|
210 | exit 1 | |
210 | fi |
|
211 | fi | |
211 | if [ ! -f rhodecode/public/css/style.css ]; then |
|
212 | if [ ! -f rhodecode/public/css/style.css ]; then | |
212 | echo "Missing style.css" |
|
213 | echo "Missing style.css" | |
213 | exit 1 |
|
214 | exit 1 | |
214 | fi |
|
215 | fi | |
215 | ''; |
|
216 | ''; | |
216 |
|
217 | |||
217 | }); |
|
218 | }); | |
218 |
|
219 | |||
219 | rhodecode-testdata = import "${rhodecode-testdata-src}/default.nix" { |
|
220 | rhodecode-testdata = import "${rhodecode-testdata-src}/default.nix" { | |
220 | inherit |
|
221 | inherit | |
221 | doCheck |
|
222 | doCheck | |
222 | pkgs |
|
223 | pkgs | |
223 | pythonPackages; |
|
224 | pythonPackages; | |
224 | }; |
|
225 | }; | |
225 |
|
226 | |||
226 | }; |
|
227 | }; | |
227 |
|
228 | |||
228 | rhodecode-testdata-src = sources.rhodecode-testdata or ( |
|
229 | rhodecode-testdata-src = sources.rhodecode-testdata or ( | |
229 | pkgs.fetchhg { |
|
230 | pkgs.fetchhg { | |
230 | url = "https://code.rhodecode.com/upstream/rc_testdata"; |
|
231 | url = "https://code.rhodecode.com/upstream/rc_testdata"; | |
231 | rev = "v0.10.0"; |
|
232 | rev = "v0.10.0"; | |
232 | sha256 = "0zn9swwvx4vgw4qn8q3ri26vvzgrxn15x6xnjrysi1bwmz01qjl0"; |
|
233 | sha256 = "0zn9swwvx4vgw4qn8q3ri26vvzgrxn15x6xnjrysi1bwmz01qjl0"; | |
233 | }); |
|
234 | }); | |
234 |
|
235 | |||
235 | # Apply all overrides and fix the final package set |
|
236 | # Apply all overrides and fix the final package set | |
236 | myPythonPackagesUnfix = with pkgs.lib; |
|
237 | myPythonPackagesUnfix = with pkgs.lib; | |
237 | (extends pythonExternalOverrides |
|
238 | (extends pythonExternalOverrides | |
238 | (extends pythonLocalOverrides |
|
239 | (extends pythonLocalOverrides | |
239 | (extends pythonOverrides |
|
240 | (extends pythonOverrides | |
240 | pythonGeneratedPackages))); |
|
241 | pythonGeneratedPackages))); | |
241 | myPythonPackages = (pkgs.lib.fix myPythonPackagesUnfix); |
|
242 | myPythonPackages = (pkgs.lib.fix myPythonPackagesUnfix); | |
242 |
|
243 | |||
243 | in myPythonPackages.rhodecode-enterprise-ce |
|
244 | in myPythonPackages.rhodecode-enterprise-ce |
General Comments 0
You need to be logged in to leave comments.
Login now