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