##// END OF EJS Templates
nix: Pass the backwards compatible fetchgit to python and node packages.
Martin Bornhold -
r926:14a58a7b default
parent child Browse files
Show More
@@ -1,228 +1,250 b''
1 1 # Nix environment for the community edition
2 2 #
3 3 # This shall be as lean as possible, just producing the Enterprise
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 { pkgs ? (import <nixpkgs> {})
8 , pythonPackages ? "python27Packages"
7 args@
8 { pythonPackages ? "python27Packages"
9 9 , pythonExternalOverrides ? self: super: {}
10 10 , doCheck ? true
11 , ...
11 12 }:
12 13
13 14 let
14 inherit (pkgs.lib) fix extends;
15
16 # Use nixpkgs from args or import them. We use this indirect approach
17 # through args to be able to use the name `pkgs` for our customized packages.
18 # Otherwise we will end up with an infinite recursion.
19 nixpkgs = args.pkgs or (import <nixpkgs> { });
20
21 # johbo: Interim bridge which allows us to build with the upcoming
22 # nixos.16.09 branch (unstable at the moment of writing this note) and the
23 # current stable nixos-16.03.
24 backwardsCompatibleFetchgit = { ... }@args:
25 let
26 origSources = nixpkgs.fetchgit args;
27 in
28 nixpkgs.lib.overrideDerivation origSources (oldAttrs: {
29 NIX_PREFETCH_GIT_CHECKOUT_HOOK = ''
30 find $out -name '.git*' -print0 | xargs -0 rm -rf
31 '';
32 });
33
34 # Create a customized version of nixpkgs which should be used throughout the
35 # rest of this file.
36 pkgs = nixpkgs.overridePackages (self: super: {
37 fetchgit = backwardsCompatibleFetchgit;
38 });
39
40 # Evaluates to the last segment of a file system path.
41 basename = path: with pkgs.lib; last (splitString "/" path);
42
43 # source code filter used as arugment to builtins.filterSource.
44 src-filter = path: type: with pkgs.lib;
45 let
46 ext = last (splitString "." path);
47 in
48 !builtins.elem (basename path) [
49 ".git" ".hg" "__pycache__" ".eggs"
50 "bower_components" "node_modules"
51 "build" "data" "result" "tmp"] &&
52 !builtins.elem ext ["egg-info" "pyc"] &&
53 # TODO: johbo: This check is wrong, since "path" contains an absolute path,
54 # it would still be good to restore it since we want to ignore "result-*".
55 !hasPrefix "result" path;
15 56
16 57 basePythonPackages = with builtins; if isAttrs pythonPackages
17 58 then pythonPackages
18 59 else getAttr pythonPackages pkgs;
19 60
20 61 buildBowerComponents =
21 62 pkgs.buildBowerComponents or
22 63 (import ./pkgs/backport-16.03-build-bower-components.nix { inherit pkgs; });
23 64
24 elem = builtins.elem;
25 basename = path: with pkgs.lib; last (splitString "/" path);
26 startsWith = prefix: full: let
27 actualPrefix = builtins.substring 0 (builtins.stringLength prefix) full;
28 in actualPrefix == prefix;
29
30 src-filter = path: type: with pkgs.lib;
31 let
32 ext = last (splitString "." path);
33 in
34 !elem (basename path) [
35 ".git" ".hg" "__pycache__" ".eggs"
36 "bower_components" "node_modules"
37 "build" "data" "result" "tmp"] &&
38 !elem ext ["egg-info" "pyc"] &&
39 # TODO: johbo: This check is wrong, since "path" contains an absolute path,
40 # it would still be good to restore it since we want to ignore "result-*".
41 !startsWith "result" path;
42
43 65 sources = pkgs.config.rc.sources or {};
44 66 version = builtins.readFile ./rhodecode/VERSION;
45 67 rhodecode-enterprise-ce-src = builtins.filterSource src-filter ./.;
46 68
47 69 nodeEnv = import ./pkgs/node-default.nix {
48 70 inherit pkgs;
49 71 };
50 72 nodeDependencies = nodeEnv.shell.nodeDependencies;
51 73
52 74 bowerComponents = buildBowerComponents {
53 75 name = "enterprise-ce-${version}";
54 76 generated = ./pkgs/bower-packages.nix;
55 77 src = rhodecode-enterprise-ce-src;
56 78 };
57 79
58 80 pythonGeneratedPackages = self: basePythonPackages.override (a: {
59 81 inherit self;
60 82 })
61 83 // (scopedImport {
62 84 self = self;
63 85 super = basePythonPackages;
64 86 inherit pkgs;
65 87 inherit (pkgs) fetchurl fetchgit;
66 88 } ./pkgs/python-packages.nix);
67 89
68 90 pythonOverrides = import ./pkgs/python-packages-overrides.nix {
69 91 inherit
70 92 basePythonPackages
71 93 pkgs;
72 94 };
73 95
74 96 pythonLocalOverrides = self: super: {
75 97 rhodecode-enterprise-ce =
76 98 let
77 99 linkNodeAndBowerPackages = ''
78 100 echo "Export RhodeCode CE path"
79 101 export RHODECODE_CE_PATH=${rhodecode-enterprise-ce-src}
80 102 echo "Link node packages"
81 103 rm -fr node_modules
82 104 mkdir node_modules
83 105 # johbo: Linking individual packages allows us to run "npm install"
84 106 # inside of a shell to try things out. Re-entering the shell will
85 107 # restore a clean environment.
86 108 ln -s ${nodeDependencies}/lib/node_modules/* node_modules/
87 109
88 110 echo "DONE: Link node packages"
89 111
90 112 echo "Link bower packages"
91 113 rm -fr bower_components
92 114 mkdir bower_components
93 115
94 116 ln -s ${bowerComponents}/bower_components/* bower_components/
95 117 echo "DONE: Link bower packages"
96 118 '';
97 119 in super.rhodecode-enterprise-ce.override (attrs: {
98 120
99 121 inherit
100 122 doCheck
101 123 version;
102 124 name = "rhodecode-enterprise-ce-${version}";
103 125 releaseName = "RhodeCodeEnterpriseCE-${version}";
104 126 src = rhodecode-enterprise-ce-src;
105 127
106 128 buildInputs =
107 129 attrs.buildInputs ++
108 130 (with self; [
109 131 pkgs.nodePackages.bower
110 132 pkgs.nodePackages.grunt-cli
111 133 pkgs.subversion
112 134 pytest-catchlog
113 135 rhodecode-testdata
114 136 ]);
115 137
116 138 propagatedBuildInputs = attrs.propagatedBuildInputs ++ (with self; [
117 139 rhodecode-tools
118 140 ]);
119 141
120 142 # TODO: johbo: Make a nicer way to expose the parts. Maybe
121 143 # pkgs/default.nix?
122 144 passthru = {
123 145 inherit
124 146 bowerComponents
125 147 linkNodeAndBowerPackages
126 148 myPythonPackagesUnfix
127 149 pythonLocalOverrides;
128 150 pythonPackages = self;
129 151 };
130 152
131 153 LC_ALL = "en_US.UTF-8";
132 154 LOCALE_ARCHIVE =
133 155 if pkgs.stdenv ? glibc
134 156 then "${pkgs.glibcLocales}/lib/locale/locale-archive"
135 157 else "";
136 158
137 159 # Somewhat snappier setup of the development environment
138 160 # TODO: move into shell.nix
139 161 # TODO: think of supporting a stable path again, so that multiple shells
140 162 # can share it.
141 163 shellHook = ''
142 164 tmp_path=$(mktemp -d)
143 165 export PATH="$tmp_path/bin:$PATH"
144 166 export PYTHONPATH="$tmp_path/${self.python.sitePackages}:$PYTHONPATH"
145 167 mkdir -p $tmp_path/${self.python.sitePackages}
146 168 python setup.py develop --prefix $tmp_path --allow-hosts ""
147 169 '' + linkNodeAndBowerPackages;
148 170
149 171 preCheck = ''
150 172 export PATH="$out/bin:$PATH"
151 173 '';
152 174
153 175 postCheck = ''
154 176 rm -rf $out/lib/${self.python.libPrefix}/site-packages/pytest_pylons
155 177 rm -rf $out/lib/${self.python.libPrefix}/site-packages/rhodecode/tests
156 178 '';
157 179
158 180 preBuild = linkNodeAndBowerPackages + ''
159 181 grunt
160 182 rm -fr node_modules
161 183 '';
162 184
163 185 postInstall = ''
164 186 # python based programs need to be wrapped
165 187 ln -s ${self.supervisor}/bin/supervisor* $out/bin/
166 188 ln -s ${self.gunicorn}/bin/gunicorn $out/bin/
167 189 ln -s ${self.PasteScript}/bin/paster $out/bin/
168 190 ln -s ${self.channelstream}/bin/channelstream $out/bin/
169 191 ln -s ${self.pyramid}/bin/* $out/bin/ #*/
170 192
171 193 # rhodecode-tools
172 194 # TODO: johbo: re-think this. Do the tools import anything from enterprise?
173 195 ln -s ${self.rhodecode-tools}/bin/rhodecode-* $out/bin/
174 196
175 197 # note that condition should be restricted when adding further tools
176 198 for file in $out/bin/*; do #*/
177 199 wrapProgram $file \
178 200 --prefix PYTHONPATH : $PYTHONPATH \
179 201 --prefix PATH : $PATH \
180 202 --set PYTHONHASHSEED random
181 203 done
182 204
183 205 mkdir $out/etc
184 206 cp configs/production.ini $out/etc
185 207
186 208 echo "Writing meta information for rccontrol to nix-support/rccontrol"
187 209 mkdir -p $out/nix-support/rccontrol
188 210 cp -v rhodecode/VERSION $out/nix-support/rccontrol/version
189 211 echo "DONE: Meta information for rccontrol written"
190 212
191 213 # TODO: johbo: Make part of ac-tests
192 214 if [ ! -f rhodecode/public/js/scripts.js ]; then
193 215 echo "Missing scripts.js"
194 216 exit 1
195 217 fi
196 218 if [ ! -f rhodecode/public/css/style.css ]; then
197 219 echo "Missing style.css"
198 220 exit 1
199 221 fi
200 222 '';
201 223
202 224 });
203 225
204 226 rhodecode-testdata = import "${rhodecode-testdata-src}/default.nix" {
205 227 inherit
206 228 doCheck
207 229 pkgs
208 230 pythonPackages;
209 231 };
210 232
211 233 };
212 234
213 235 rhodecode-testdata-src = sources.rhodecode-testdata or (
214 236 pkgs.fetchhg {
215 237 url = "https://code.rhodecode.com/upstream/rc_testdata";
216 238 rev = "v0.8.0";
217 239 sha256 = "0hy1ba134rq2f9si85yx7j4qhc9ky0hjzdk553s3q026i7km809m";
218 240 });
219 241
220 242 # Apply all overrides and fix the final package set
221 myPythonPackagesUnfix =
243 myPythonPackagesUnfix = with pkgs.lib;
222 244 (extends pythonExternalOverrides
223 245 (extends pythonLocalOverrides
224 246 (extends pythonOverrides
225 247 pythonGeneratedPackages)));
226 myPythonPackages = (fix myPythonPackagesUnfix);
248 myPythonPackages = (pkgs.lib.fix myPythonPackagesUnfix);
227 249
228 250 in myPythonPackages.rhodecode-enterprise-ce
@@ -1,296 +1,283 b''
1 1 # Overrides for the generated python-packages.nix
2 2 #
3 3 # This function is intended to be used as an extension to the generated file
4 4 # python-packages.nix. The main objective is to add needed dependencies of C
5 5 # libraries and tweak the build instructions where needed.
6 6
7 7 { pkgs, basePythonPackages }:
8 8
9 9 let
10 10 sed = "sed -i";
11 11 localLicenses = {
12 12 repoze = {
13 13 fullName = "Repoze License";
14 14 url = http://www.repoze.org/LICENSE.txt;
15 15 };
16 16 };
17 17
18 # johbo: Interim bridge which allows us to build with the upcoming
19 # nixos.16.09 branch (unstable at the moment of writing this note) and the
20 # current stable nixos-16.03.
21 backwardsCompatibleFetchgit = { ... }@args:
22 let
23 origSources = pkgs.fetchgit args;
24 in
25 pkgs.lib.overrideDerivation origSources (oldAttrs: {
26 NIX_PREFETCH_GIT_CHECKOUT_HOOK = ''
27 find $out -name '.git*' -print0 | xargs -0 rm -rf
28 '';
29 });
30
31 18 in
32 19
33 20 self: super: {
34 21
35 22 appenlight-client = super.appenlight-client.override (attrs: {
36 23 meta = {
37 24 license = [ pkgs.lib.licenses.bsdOriginal ];
38 25 };
39 26 });
40 27
41 28 future = super.future.override (attrs: {
42 29 meta = {
43 30 license = [ pkgs.lib.licenses.mit ];
44 31 };
45 32 });
46 33
47 34 gnureadline = super.gnureadline.override (attrs: {
48 35 buildInputs = attrs.buildInputs ++ [
49 36 pkgs.ncurses
50 37 ];
51 38 patchPhase = ''
52 39 substituteInPlace setup.py --replace "/bin/bash" "${pkgs.bash}/bin/bash"
53 40 '';
54 41 });
55 42
56 43 gunicorn = super.gunicorn.override (attrs: {
57 44 propagatedBuildInputs = attrs.propagatedBuildInputs ++ [
58 45 # johbo: futures is needed as long as we are on Python 2, otherwise
59 46 # gunicorn explodes if used with multiple threads per worker.
60 47 self.futures
61 48 ];
62 49 });
63 50
64 51 ipython = super.ipython.override (attrs: {
65 52 propagatedBuildInputs = attrs.propagatedBuildInputs ++ [
66 53 self.gnureadline
67 54 ];
68 55 });
69 56
70 57 kombu = super.kombu.override (attrs: {
71 58 # The current version of kombu needs some patching to work with the
72 59 # other libs. Should be removed once we update celery and kombu.
73 60 patches = [
74 61 ./patch-kombu-py-2-7-11.diff
75 62 ./patch-kombu-msgpack.diff
76 63 ];
77 64 });
78 65
79 66 lxml = super.lxml.override (attrs: {
80 67 buildInputs = with self; [
81 68 pkgs.libxml2
82 69 pkgs.libxslt
83 70 ];
84 71 });
85 72
86 73 MySQL-python = super.MySQL-python.override (attrs: {
87 74 buildInputs = attrs.buildInputs ++ [
88 75 pkgs.openssl
89 76 ];
90 77 propagatedBuildInputs = attrs.propagatedBuildInputs ++ [
91 78 pkgs.mysql.lib
92 79 pkgs.zlib
93 80 ];
94 81 });
95 82
96 83 psutil = super.psutil.override (attrs: {
97 84 buildInputs = attrs.buildInputs ++
98 85 pkgs.lib.optional pkgs.stdenv.isDarwin pkgs.darwin.IOKit;
99 86 });
100 87
101 88 psycopg2 = super.psycopg2.override (attrs: {
102 89 buildInputs = attrs.buildInputs ++
103 90 pkgs.lib.optional pkgs.stdenv.isDarwin pkgs.openssl;
104 91 propagatedBuildInputs = attrs.propagatedBuildInputs ++ [
105 92 pkgs.postgresql
106 93 ];
107 94 meta = {
108 95 license = pkgs.lib.licenses.lgpl3Plus;
109 96 };
110 97 });
111 98
112 99 py-gfm = super.py-gfm.override {
113 src = backwardsCompatibleFetchgit {
100 src = pkgs.fetchgit {
114 101 url = "https://code.rhodecode.com/upstream/py-gfm";
115 102 rev = "0d66a19bc16e3d49de273c0f797d4e4781e8c0f2";
116 103 sha256 = "0ryp74jyihd3ckszq31bml5jr3bciimhfp7va7kw6ld92930ksv3";
117 104 };
118 105 };
119 106
120 107 pycurl = super.pycurl.override (attrs: {
121 108 propagatedBuildInputs = attrs.propagatedBuildInputs ++ [
122 109 pkgs.curl
123 110 pkgs.openssl
124 111 ];
125 112 preConfigure = ''
126 113 substituteInPlace setup.py --replace '--static-libs' '--libs'
127 114 export PYCURL_SSL_LIBRARY=openssl
128 115 '';
129 116 meta = {
130 117 # TODO: It is LGPL and MIT
131 118 license = pkgs.lib.licenses.mit;
132 119 };
133 120 });
134 121
135 122 Pylons = super.Pylons.override (attrs: {
136 123 name = "Pylons-1.0.1-patch1";
137 src = backwardsCompatibleFetchgit {
124 src = pkgs.fetchgit {
138 125 url = "https://code.rhodecode.com/upstream/pylons";
139 126 rev = "707354ee4261b9c10450404fc9852ccea4fd667d";
140 127 sha256 = "b2763274c2780523a335f83a1df65be22ebe4ff413a7bc9e9288d23c1f62032e";
141 128 };
142 129 });
143 130
144 131 pyramid = super.pyramid.override (attrs: {
145 132 postFixup = ''
146 133 wrapPythonPrograms
147 134 # TODO: johbo: "wrapPython" adds this magic line which
148 135 # confuses pserve.
149 136 ${sed} '/import sys; sys.argv/d' $out/bin/.pserve-wrapped
150 137 '';
151 138 meta = {
152 139 license = localLicenses.repoze;
153 140 };
154 141 });
155 142
156 143 pyramid-debugtoolbar = super.pyramid-debugtoolbar.override (attrs: {
157 144 meta = {
158 145 license = [ pkgs.lib.licenses.bsdOriginal localLicenses.repoze ];
159 146 };
160 147 });
161 148
162 149 Pyro4 = super.Pyro4.override (attrs: {
163 150 # TODO: Was not able to generate this version, needs further
164 151 # investigation.
165 152 name = "Pyro4-4.35";
166 153 src = pkgs.fetchurl {
167 154 url = "https://pypi.python.org/packages/source/P/Pyro4/Pyro4-4.35.src.tar.gz";
168 155 md5 = "cbe6cb855f086a0f092ca075005855f3";
169 156 };
170 157 });
171 158
172 159 pysqlite = super.pysqlite.override (attrs: {
173 160 propagatedBuildInputs = [
174 161 pkgs.sqlite
175 162 ];
176 163 meta = {
177 164 license = [ pkgs.lib.licenses.zlib pkgs.lib.licenses.libpng ];
178 165 };
179 166 });
180 167
181 168 pytest-runner = super.pytest-runner.override (attrs: {
182 169 propagatedBuildInputs = [
183 170 self.setuptools-scm
184 171 ];
185 172 });
186 173
187 174 python-ldap = super.python-ldap.override (attrs: {
188 175 propagatedBuildInputs = attrs.propagatedBuildInputs ++ [
189 176 pkgs.cyrus_sasl
190 177 pkgs.openldap
191 178 pkgs.openssl
192 179 ];
193 180 # TODO: johbo: Remove the "or" once we drop 16.03 support.
194 181 NIX_CFLAGS_COMPILE = "-I${pkgs.cyrus_sasl.dev or pkgs.cyrus_sasl}/include/sasl";
195 182 });
196 183
197 184 python-pam = super.python-pam.override (attrs:
198 185 let
199 186 includeLibPam = pkgs.stdenv.isLinux;
200 187 in {
201 188 # TODO: johbo: Move the option up into the default.nix, we should
202 189 # include python-pam only on supported platforms.
203 190 propagatedBuildInputs = attrs.propagatedBuildInputs ++
204 191 pkgs.lib.optional includeLibPam [
205 192 pkgs.pam
206 193 ];
207 194 # TODO: johbo: Check if this can be avoided, or transform into
208 195 # a real patch
209 196 patchPhase = pkgs.lib.optionals includeLibPam ''
210 197 substituteInPlace pam.py \
211 198 --replace 'find_library("pam")' '"${pkgs.pam}/lib/libpam.so.0"'
212 199 '';
213 200 });
214 201
215 202 rhodecode-tools = super.rhodecode-tools.override (attrs: {
216 203 patches = [
217 204 ./patch-rhodecode-tools-setup.diff
218 205 ];
219 206 });
220 207
221 208 URLObject = super.URLObject.override (attrs: {
222 209 meta = {
223 210 license = {
224 211 spdxId = "Unlicense";
225 212 fullName = "The Unlicense";
226 213 url = http://unlicense.org/;
227 214 };
228 215 };
229 216 });
230 217
231 218 amqplib = super.amqplib.override (attrs: {
232 219 meta = {
233 220 license = pkgs.lib.licenses.lgpl3;
234 221 };
235 222 });
236 223
237 224 docutils = super.docutils.override (attrs: {
238 225 meta = {
239 226 license = pkgs.lib.licenses.bsd2;
240 227 };
241 228 });
242 229
243 230 colander = super.colander.override (attrs: {
244 231 meta = {
245 232 license = localLicenses.repoze;
246 233 };
247 234 });
248 235
249 236 pyramid-beaker = super.pyramid-beaker.override (attrs: {
250 237 meta = {
251 238 license = localLicenses.repoze;
252 239 };
253 240 });
254 241
255 242 pyramid-mako = super.pyramid-mako.override (attrs: {
256 243 meta = {
257 244 license = localLicenses.repoze;
258 245 };
259 246 });
260 247
261 248 repoze.lru = super.repoze.lru.override (attrs: {
262 249 meta = {
263 250 license = localLicenses.repoze;
264 251 };
265 252 });
266 253
267 254 recaptcha-client = super.recaptcha-client.override (attrs: {
268 255 meta = {
269 256 # TODO: It is MIT/X11
270 257 license = pkgs.lib.licenses.mit;
271 258 };
272 259 });
273 260
274 261 python-editor = super.python-editor.override (attrs: {
275 262 meta = {
276 263 license = pkgs.lib.licenses.asl20;
277 264 };
278 265 });
279 266
280 267 translationstring = super.translationstring.override (attrs: {
281 268 meta = {
282 269 license = localLicenses.repoze;
283 270 };
284 271 });
285 272
286 273 venusian = super.venusian.override (attrs: {
287 274 meta = {
288 275 license = localLicenses.repoze;
289 276 };
290 277 });
291 278
292 279 # Avoid that setuptools is replaced, this leads to trouble
293 280 # with buildPythonPackage.
294 281 setuptools = basePythonPackages.setuptools;
295 282
296 283 }
General Comments 0
You need to be logged in to leave comments. Login now