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