Show More
@@ -1,200 +1,208 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 rhodecode-vcsserver |
|
3 | # This shall be as lean as possible, just producing the rhodecode-vcsserver | |
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 | { system ? builtins.currentSystem |
|
8 | { system ? builtins.currentSystem | |
9 | , pythonPackages ? "python27Packages" |
|
9 | , pythonPackages ? "python27Packages" | |
10 | , pythonExternalOverrides ? self: super: {} |
|
10 | , pythonExternalOverrides ? self: super: {} | |
11 | , doCheck ? false |
|
11 | , doCheck ? false | |
12 | , ... |
|
12 | , ... | |
13 | }: |
|
13 | }: | |
14 |
|
14 | |||
15 | let |
|
15 | let | |
16 | pkgs_ = args.pkgs or (import <nixpkgs> { inherit system; }); |
|
16 | pkgs_ = args.pkgs or (import <nixpkgs> { inherit system; }); | |
17 | in |
|
17 | in | |
18 |
|
18 | |||
19 | let |
|
19 | let | |
20 | pkgs = import <nixpkgs> { |
|
20 | pkgs = import <nixpkgs> { | |
21 | overlays = [ |
|
21 | overlays = [ | |
22 | (import ./pkgs/overlays.nix) |
|
22 | (import ./pkgs/overlays.nix) | |
23 | ]; |
|
23 | ]; | |
24 | inherit |
|
24 | inherit | |
25 | (pkgs_) |
|
25 | (pkgs_) | |
26 | system; |
|
26 | system; | |
27 | }; |
|
27 | }; | |
28 |
|
28 | |||
29 | # Works with the new python-packages, still can fallback to the old |
|
29 | # Works with the new python-packages, still can fallback to the old | |
30 | # variant. |
|
30 | # variant. | |
31 | basePythonPackagesUnfix = basePythonPackages.__unfix__ or ( |
|
31 | basePythonPackagesUnfix = basePythonPackages.__unfix__ or ( | |
32 | self: basePythonPackages.override (a: { inherit self; })); |
|
32 | self: basePythonPackages.override (a: { inherit self; })); | |
33 |
|
33 | |||
34 | # Evaluates to the last segment of a file system path. |
|
34 | # Evaluates to the last segment of a file system path. | |
35 | basename = path: with pkgs.lib; last (splitString "/" path); |
|
35 | basename = path: with pkgs.lib; last (splitString "/" path); | |
36 | startsWith = prefix: full: let |
|
36 | startsWith = prefix: full: let | |
37 | actualPrefix = builtins.substring 0 (builtins.stringLength prefix) full; |
|
37 | actualPrefix = builtins.substring 0 (builtins.stringLength prefix) full; | |
38 | in actualPrefix == prefix; |
|
38 | in actualPrefix == prefix; | |
39 |
|
39 | |||
40 | # source code filter used as arugment to builtins.filterSource. |
|
40 | # source code filter used as arugment to builtins.filterSource. | |
41 | src-filter = path: type: with pkgs.lib; |
|
41 | src-filter = path: type: with pkgs.lib; | |
42 | let |
|
42 | let | |
43 | ext = last (splitString "." path); |
|
43 | ext = last (splitString "." path); | |
44 | parts = last (splitString "/" path); |
|
44 | parts = last (splitString "/" path); | |
45 | in |
|
45 | in | |
46 | !builtins.elem (basename path) [ |
|
46 | !builtins.elem (basename path) [ | |
47 | ".git" ".hg" "__pycache__" ".eggs" ".idea" ".dev" |
|
47 | ".git" ".hg" "__pycache__" ".eggs" ".idea" ".dev" | |
48 | "node_modules" "node_binaries" |
|
48 | "node_modules" "node_binaries" | |
49 | "build" "data" "result" "tmp"] && |
|
49 | "build" "data" "result" "tmp"] && | |
50 | !builtins.elem ext ["egg-info" "pyc"] && |
|
50 | !builtins.elem ext ["egg-info" "pyc"] && | |
51 | !startsWith "result" (basename path); |
|
51 | !startsWith "result" (basename path); | |
52 |
|
52 | |||
53 | sources = |
|
53 | sources = | |
54 | let |
|
54 | let | |
55 | inherit |
|
55 | inherit | |
56 | (pkgs.lib) |
|
56 | (pkgs.lib) | |
57 | all |
|
57 | all | |
58 | isString |
|
58 | isString | |
59 | attrValues; |
|
59 | attrValues; | |
60 |
|
60 | |||
61 | sourcesConfig = pkgs.config.rc.sources or {}; |
|
61 | sourcesConfig = pkgs.config.rc.sources or {}; | |
62 | in |
|
62 | in | |
63 | # Ensure that sources are configured as strings. Using a path |
|
63 | # Ensure that sources are configured as strings. Using a path | |
64 | # would result in a copy into the nix store. |
|
64 | # would result in a copy into the nix store. | |
65 | assert all isString (attrValues sourcesConfig); |
|
65 | assert all isString (attrValues sourcesConfig); | |
66 | sourcesConfig; |
|
66 | sourcesConfig; | |
67 |
|
67 | |||
68 | version = builtins.readFile "${rhodecode-vcsserver-src}/vcsserver/VERSION"; |
|
68 | version = builtins.readFile "${rhodecode-vcsserver-src}/vcsserver/VERSION"; | |
69 | rhodecode-vcsserver-src = builtins.filterSource src-filter ./.; |
|
69 | rhodecode-vcsserver-src = builtins.filterSource src-filter ./.; | |
70 |
|
70 | |||
71 | pythonLocalOverrides = self: super: { |
|
71 | pythonLocalOverrides = self: super: { | |
72 | rhodecode-vcsserver = |
|
72 | rhodecode-vcsserver = | |
73 | let |
|
73 | let | |
74 | releaseName = "RhodeCodeVCSServer-${version}"; |
|
74 | releaseName = "RhodeCodeVCSServer-${version}"; | |
75 | in super.rhodecode-vcsserver.override (attrs: { |
|
75 | in super.rhodecode-vcsserver.override (attrs: { | |
76 | inherit |
|
76 | inherit | |
77 | doCheck |
|
77 | doCheck | |
78 | version; |
|
78 | version; | |
79 |
|
79 | |||
80 | name = "rhodecode-vcsserver-${version}"; |
|
80 | name = "rhodecode-vcsserver-${version}"; | |
81 | releaseName = releaseName; |
|
81 | releaseName = releaseName; | |
82 | src = rhodecode-vcsserver-src; |
|
82 | src = rhodecode-vcsserver-src; | |
83 | dontStrip = true; # prevent strip, we don't need it. |
|
83 | dontStrip = true; # prevent strip, we don't need it. | |
84 |
|
84 | |||
85 | # expose following attributed outside |
|
85 | # expose following attributed outside | |
86 | passthru = { |
|
86 | passthru = { | |
87 | pythonPackages = self; |
|
87 | pythonPackages = self; | |
88 | vcs_pkgs = pkgs; |
|
88 | vcs_pkgs = pkgs; | |
89 | }; |
|
89 | }; | |
90 |
|
90 | |||
91 | buildInputs = |
|
91 | buildInputs = | |
92 | attrs.buildInputs or [] ++ [ |
|
92 | attrs.buildInputs or [] ++ [ | |
93 |
|
93 | |||
94 | ]; |
|
94 | ]; | |
95 |
|
95 | |||
96 | #NOTE: option to inject additional propagatedBuildInputs |
|
96 | #NOTE: option to inject additional propagatedBuildInputs | |
97 | propagatedBuildInputs = |
|
97 | propagatedBuildInputs = | |
98 | attrs.propagatedBuildInputs or [] ++ [ |
|
98 | attrs.propagatedBuildInputs or [] ++ [ | |
99 | pkgs.git |
|
99 | pkgs.git | |
100 | pkgs.subversion |
|
100 | pkgs.subversion | |
101 | ]; |
|
101 | ]; | |
102 |
|
102 | |||
103 | preBuild = '' |
|
103 | preBuild = '' | |
104 | export NIX_PATH=nixpkgs=${pkgs.path} |
|
104 | export NIX_PATH=nixpkgs=${pkgs.path} | |
105 | export SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt |
|
105 | export SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt | |
106 | ''; |
|
106 | ''; | |
107 |
|
107 | |||
108 | # Add bin directory to path so that tests can find 'vcsserver'. |
|
108 | # Add bin directory to path so that tests can find 'vcsserver'. | |
109 | preCheck = '' |
|
109 | preCheck = '' | |
110 | export PATH="$out/bin:$PATH" |
|
110 | export PATH="$out/bin:$PATH" | |
111 | ''; |
|
111 | ''; | |
112 |
|
112 | |||
113 | # custom check phase for testing |
|
113 | # custom check phase for testing | |
114 | checkPhase = '' |
|
114 | checkPhase = '' | |
115 | runHook preCheck |
|
115 | runHook preCheck | |
116 | PYTHONHASHSEED=random py.test -vv -p no:sugar -r xw --cov-config=.coveragerc --cov=vcsserver --cov-report=term-missing vcsserver |
|
116 | PYTHONHASHSEED=random py.test -vv -p no:sugar -r xw --cov-config=.coveragerc --cov=vcsserver --cov-report=term-missing vcsserver | |
117 | runHook postCheck |
|
117 | runHook postCheck | |
118 | ''; |
|
118 | ''; | |
119 |
|
119 | |||
120 | postCheck = '' |
|
120 | postCheck = '' | |
121 | echo "Cleanup of vcsserver/tests" |
|
121 | echo "Cleanup of vcsserver/tests" | |
122 | rm -rf $out/lib/${self.python.libPrefix}/site-packages/vcsserver/tests |
|
122 | rm -rf $out/lib/${self.python.libPrefix}/site-packages/vcsserver/tests | |
123 | ''; |
|
123 | ''; | |
124 |
|
124 | |||
125 | postInstall = '' |
|
125 | postInstall = '' | |
126 | echo "Writing vcsserver meta information for rccontrol to nix-support/rccontrol" |
|
126 | echo "Writing vcsserver meta information for rccontrol to nix-support/rccontrol" | |
127 | mkdir -p $out/nix-support/rccontrol |
|
127 | mkdir -p $out/nix-support/rccontrol | |
128 | cp -v vcsserver/VERSION $out/nix-support/rccontrol/version |
|
128 | cp -v vcsserver/VERSION $out/nix-support/rccontrol/version | |
129 | echo "DONE: vcsserver meta information for rccontrol written" |
|
129 | echo "DONE: vcsserver meta information for rccontrol written" | |
130 |
|
130 | |||
131 | mkdir -p $out/etc |
|
131 | mkdir -p $out/etc | |
132 | cp configs/production.ini $out/etc |
|
132 | cp configs/production.ini $out/etc | |
133 | echo "DONE: saved vcsserver production.ini into $out/etc" |
|
133 | echo "DONE: saved vcsserver production.ini into $out/etc" | |
134 |
|
134 | |||
|
135 | echo "saving env in $out/etc/env_vars.txt" | |||
|
136 | touch $out/etc/env_vars.txt | |||
|
137 | echo "# RhodeCode build env vars" >> $out/etc/env_vars.txt | |||
|
138 | echo "LOCALE_ARCHIVE=\"${pkgs.glibcLocales}/lib/locale/locale-archive\"" >> $out/etc/env_vars.txt | |||
|
139 | echo "LC_ALL=\"en_US.UTF-8\"" >> $out/etc/env_vars.txt | |||
|
140 | ||||
135 | # python based programs need to be wrapped |
|
141 | # python based programs need to be wrapped | |
136 | mkdir -p $out/bin |
|
142 | mkdir -p $out/bin | |
137 |
|
143 | |||
|
144 | # expose python | |||
|
145 | ln -s ${self.python}/bin/python $out/bin/ | |||
|
146 | ||||
138 | # required binaries from dependencies |
|
147 | # required binaries from dependencies | |
139 | ln -s ${self.python}/bin/python $out/bin/ |
|
|||
140 | ln -s ${self.gunicorn}/bin/gunicorn $out/bin/ |
|
148 | ln -s ${self.gunicorn}/bin/gunicorn $out/bin/ | |
141 | ln -s ${self.pyramid}/bin/prequest $out/bin/ |
|
149 | ln -s ${self.pyramid}/bin/prequest $out/bin/ | |
142 | ln -s ${self.pyramid}/bin/pserve $out/bin/ |
|
150 | ln -s ${self.pyramid}/bin/pserve $out/bin/ | |
143 |
|
151 | |||
144 | # Symlink version control utilities |
|
152 | # Symlink version control utilities | |
145 | # We ensure that always the correct version is available as a symlink. |
|
153 | # We ensure that always the correct version is available as a symlink. | |
146 | # So that users calling them via the profile path will always use the |
|
154 | # So that users calling them via the profile path will always use the | |
147 | # correct version. Wrapping is required so those can "import" |
|
155 | # correct version. Wrapping is required so those can "import" | |
148 | # vcsserver python hooks. |
|
156 | # vcsserver python hooks. | |
149 |
|
157 | |||
150 | ln -s ${pkgs.git}/bin/git $out/bin |
|
158 | ln -s ${pkgs.git}/bin/git $out/bin | |
151 | ln -s ${self.mercurial}/bin/hg $out/bin |
|
159 | ln -s ${self.mercurial}/bin/hg $out/bin | |
152 | ln -s ${pkgs.subversion}/bin/svn* $out/bin |
|
160 | ln -s ${pkgs.subversion}/bin/svn* $out/bin | |
153 |
|
161 | |||
154 | echo "DONE: created symlinks into $out/bin" |
|
162 | echo "DONE: created symlinks into $out/bin" | |
155 | DEPS="$out/bin/*" |
|
163 | DEPS="$out/bin/*" | |
156 |
|
164 | |||
157 | # wrap only dependency scripts, they require to have full PYTHONPATH set |
|
165 | # wrap only dependency scripts, they require to have full PYTHONPATH set | |
158 | # to be able to import all packages |
|
166 | # to be able to import all packages | |
159 | for file in $DEPS; |
|
167 | for file in $DEPS; | |
160 | do |
|
168 | do | |
161 | wrapProgram $file \ |
|
169 | wrapProgram $file \ | |
162 | --prefix PATH : $PATH \ |
|
170 | --prefix PATH : $PATH \ | |
163 | --prefix PYTHONPATH : $PYTHONPATH \ |
|
171 | --prefix PYTHONPATH : $PYTHONPATH \ | |
164 | --set PYTHONHASHSEED random |
|
172 | --set PYTHONHASHSEED random | |
165 | done |
|
173 | done | |
166 |
|
174 | |||
167 | echo "DONE: vcsserver binary wrapping" |
|
175 | echo "DONE: vcsserver binary wrapping" | |
168 |
|
176 | |||
169 | ''; |
|
177 | ''; | |
170 |
|
178 | |||
171 | }); |
|
179 | }); | |
172 | }; |
|
180 | }; | |
173 |
|
181 | |||
174 |
|
182 | |||
175 | basePythonPackages = with builtins; |
|
183 | basePythonPackages = with builtins; | |
176 | if isAttrs pythonPackages then |
|
184 | if isAttrs pythonPackages then | |
177 | pythonPackages |
|
185 | pythonPackages | |
178 | else |
|
186 | else | |
179 | getAttr pythonPackages pkgs; |
|
187 | getAttr pythonPackages pkgs; | |
180 |
|
188 | |||
181 | pythonGeneratedPackages = import ./pkgs/python-packages.nix { |
|
189 | pythonGeneratedPackages = import ./pkgs/python-packages.nix { | |
182 | inherit pkgs; |
|
190 | inherit pkgs; | |
183 | inherit (pkgs) fetchurl fetchgit fetchhg; |
|
191 | inherit (pkgs) fetchurl fetchgit fetchhg; | |
184 | }; |
|
192 | }; | |
185 |
|
193 | |||
186 | pythonVCSServerOverrides = import ./pkgs/python-packages-overrides.nix { |
|
194 | pythonVCSServerOverrides = import ./pkgs/python-packages-overrides.nix { | |
187 | inherit pkgs basePythonPackages; |
|
195 | inherit pkgs basePythonPackages; | |
188 | }; |
|
196 | }; | |
189 |
|
197 | |||
190 | # Apply all overrides and fix the final package set |
|
198 | # Apply all overrides and fix the final package set | |
191 | myPythonPackagesUnfix = with pkgs.lib; |
|
199 | myPythonPackagesUnfix = with pkgs.lib; | |
192 | (extends pythonExternalOverrides |
|
200 | (extends pythonExternalOverrides | |
193 | (extends pythonLocalOverrides |
|
201 | (extends pythonLocalOverrides | |
194 | (extends pythonVCSServerOverrides |
|
202 | (extends pythonVCSServerOverrides | |
195 | (extends pythonGeneratedPackages |
|
203 | (extends pythonGeneratedPackages | |
196 | basePythonPackagesUnfix)))); |
|
204 | basePythonPackagesUnfix)))); | |
197 |
|
205 | |||
198 | myPythonPackages = (pkgs.lib.fix myPythonPackagesUnfix); |
|
206 | myPythonPackages = (pkgs.lib.fix myPythonPackagesUnfix); | |
199 |
|
207 | |||
200 | in myPythonPackages.rhodecode-vcsserver |
|
208 | in myPythonPackages.rhodecode-vcsserver |
General Comments 0
You need to be logged in to leave comments.
Login now