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