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