##// END OF EJS Templates
nix: Use path to rc_testdata from pkgs.config.rc.sources if present.
Martin Bornhold -
r211:c0fc5cc3 default
parent child Browse files
Show More
@@ -1,219 +1,223 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 7 { pkgs ? (import <nixpkgs> {})
8 8 , pythonPackages ? "python27Packages"
9 9 , pythonExternalOverrides ? self: super: {}
10 10 , doCheck ? true
11 11 }:
12 12
13 13 let pkgs_ = pkgs; in
14 14
15 15 let
16 16 pkgs = pkgs_.overridePackages (self: super: {
17 17 # Override subversion derivation to
18 18 # - activate python bindings
19 19 # - set version to 1.8
20 20 subversion = super.subversion18.override {
21 21 httpSupport = true;
22 22 pythonBindings = true;
23 23 python = self.python27Packages.python;
24 24 };
25 25 });
26 26
27 27 inherit (pkgs.lib) fix extends;
28 28
29 29 basePythonPackages = with builtins; if isAttrs pythonPackages
30 30 then pythonPackages
31 31 else getAttr pythonPackages pkgs;
32 32
33 33 elem = builtins.elem;
34 34 basename = path: with pkgs.lib; last (splitString "/" path);
35 35 startsWith = prefix: full: let
36 36 actualPrefix = builtins.substring 0 (builtins.stringLength prefix) full;
37 37 in actualPrefix == prefix;
38 38
39 39 src-filter = path: type: with pkgs.lib;
40 40 let
41 41 ext = last (splitString "." path);
42 42 in
43 43 !elem (basename path) [
44 44 ".git" ".hg" "__pycache__" ".eggs" "node_modules"
45 45 "build" "data" "tmp"] &&
46 46 !elem ext ["egg-info" "pyc"] &&
47 47 !startsWith "result" path;
48 48
49 sources = pkgs.config.rc.sources or {};
49 50 rhodecode-enterprise-ce-src = builtins.filterSource src-filter ./.;
50 51
51 52 # Load the generated node packages
52 53 nodePackages = pkgs.callPackage "${pkgs.path}/pkgs/top-level/node-packages.nix" rec {
53 54 self = nodePackages;
54 55 generated = pkgs.callPackage ./pkgs/node-packages.nix { inherit self; };
55 56 };
56 57
57 58 # TODO: Should be taken automatically out of the generates packages.
58 59 # apps.nix has one solution for this, although I'd prefer to have the deps
59 60 # from package.json mapped in here.
60 61 nodeDependencies = with nodePackages; [
61 62 grunt
62 63 grunt-contrib-concat
63 64 grunt-contrib-jshint
64 65 grunt-contrib-less
65 66 grunt-contrib-watch
66 67 jshint
67 68 ];
68 69
69 70 pythonGeneratedPackages = self: basePythonPackages.override (a: {
70 71 inherit self;
71 72 })
72 73 // (scopedImport {
73 74 self = self;
74 75 super = basePythonPackages;
75 76 inherit pkgs;
76 77 inherit (pkgs) fetchurl fetchgit;
77 78 } ./pkgs/python-packages.nix);
78 79
79 80 pythonOverrides = import ./pkgs/python-packages-overrides.nix {
80 81 inherit
81 82 basePythonPackages
82 83 pkgs;
83 84 };
84 85
85 86 pythonLocalOverrides = self: super: {
86 87 rhodecode-enterprise-ce =
87 88 let
88 89 version = builtins.readFile ./rhodecode/VERSION;
89 90 linkNodeModules = ''
90 91 echo "Link node packages"
91 92 # TODO: check if this adds stuff as a dependency, closure size
92 93 rm -fr node_modules
93 94 mkdir -p node_modules
94 95 ${pkgs.lib.concatMapStrings (dep: ''
95 96 ln -sfv ${dep}/lib/node_modules/${dep.pkgName} node_modules/
96 97 '') nodeDependencies}
97 98 echo "DONE: Link node packages"
98 99 '';
99 100 in super.rhodecode-enterprise-ce.override (attrs: {
100 101
101 102 inherit doCheck;
102 103 name = "rhodecode-enterprise-ce-${version}";
103 104 version = version;
104 105 src = rhodecode-enterprise-ce-src;
105 106
106 107 buildInputs =
107 108 attrs.buildInputs ++
108 109 (with self; [
109 110 pkgs.nodePackages.grunt-cli
110 111 pkgs.subversion
111 112 pytest-catchlog
112 113 rc_testdata
113 114 ]);
114 115
115 116 propagatedBuildInputs = attrs.propagatedBuildInputs ++ (with self; [
116 117 rhodecode-tools
117 118 ]);
118 119
119 120 # TODO: johbo: Make a nicer way to expose the parts. Maybe
120 121 # pkgs/default.nix?
121 122 passthru = {
122 123 inherit
123 124 pythonLocalOverrides
124 125 myPythonPackagesUnfix;
125 126 pythonPackages = self;
126 127 };
127 128
128 129 LC_ALL = "en_US.UTF-8";
129 130 LOCALE_ARCHIVE =
130 131 if pkgs.stdenv ? glibc
131 132 then "${pkgs.glibcLocales}/lib/locale/locale-archive"
132 133 else "";
133 134
134 135 # Somewhat snappier setup of the development environment
135 136 # TODO: move into shell.nix
136 137 # TODO: think of supporting a stable path again, so that multiple shells
137 138 # can share it.
138 139 shellHook = ''
139 140 tmp_path=$(mktemp -d)
140 141 export PATH="$tmp_path/bin:$PATH"
141 142 export PYTHONPATH="$tmp_path/${self.python.sitePackages}:$PYTHONPATH"
142 143 mkdir -p $tmp_path/${self.python.sitePackages}
143 144 python setup.py develop --prefix $tmp_path --allow-hosts ""
144 145 '' + linkNodeModules;
145 146
146 147 preCheck = ''
147 148 export PATH="$out/bin:$PATH"
148 149 '';
149 150
150 151 postCheck = ''
151 152 rm -rf $out/lib/${self.python.libPrefix}/site-packages/pytest_pylons
152 153 rm -rf $out/lib/${self.python.libPrefix}/site-packages/rhodecode/tests
153 154 '';
154 155
155 156 preBuild = linkNodeModules + ''
156 157 grunt
157 158 rm -fr node_modules
158 159 '';
159 160
160 161 postInstall = ''
161 162 # python based programs need to be wrapped
162 163 ln -s ${self.supervisor}/bin/supervisor* $out/bin/
163 164 ln -s ${self.gunicorn}/bin/gunicorn $out/bin/
164 165 ln -s ${self.PasteScript}/bin/paster $out/bin/
165 166 ln -s ${self.pyramid}/bin/* $out/bin/ #*/
166 167
167 168 # rhodecode-tools
168 169 # TODO: johbo: re-think this. Do the tools import anything from enterprise?
169 170 ln -s ${self.rhodecode-tools}/bin/rhodecode-* $out/bin/
170 171
171 172 # note that condition should be restricted when adding further tools
172 173 for file in $out/bin/*; do #*/
173 174 wrapProgram $file \
174 175 --prefix PYTHONPATH : $PYTHONPATH \
175 176 --prefix PATH : $PATH \
176 177 --set PYTHONHASHSEED random
177 178 done
178 179
179 180 mkdir $out/etc
180 181 cp configs/production.ini $out/etc
181 182
182 183 echo "Writing meta information for rccontrol to nix-support/rccontrol"
183 184 mkdir -p $out/nix-support/rccontrol
184 185 cp -v rhodecode/VERSION $out/nix-support/rccontrol/version
185 186 echo "DONE: Meta information for rccontrol written"
186 187
187 188 # TODO: johbo: Make part of ac-tests
188 189 if [ ! -f rhodecode/public/js/scripts.js ]; then
189 190 echo "Missing scripts.js"
190 191 exit 1
191 192 fi
192 193 if [ ! -f rhodecode/public/css/style.css ]; then
193 194 echo "Missing style.css"
194 195 exit 1
195 196 fi
196 197 '';
197 198
198 199 });
199 200
200 201 rc_testdata = self.buildPythonPackage rec {
201 202 name = "rc_testdata-0.7.0";
202 src = pkgs.fetchhg {
203 url = "https://code.rhodecode.com/upstream/rc_testdata";
204 rev = "v0.7.0";
205 sha256 = "0w3z0zn8lagr707v67lgys23sl6pbi4xg7pfvdbw58h3q384h6rx";
206 };
203 src = rhodecode-testdata-src;
207 204 };
208 205
209 206 };
210 207
208 rhodecode-testdata-src = sources.rhodecode-testdata or (
209 pkgs.fetchhg {
210 url = "https://code.rhodecode.com/upstream/rc_testdata";
211 rev = "v0.7.0";
212 sha256 = "0w3z0zn8lagr707v67lgys23sl6pbi4xg7pfvdbw58h3q384h6rx";
213 });
214
211 215 # Apply all overrides and fix the final package set
212 216 myPythonPackagesUnfix =
213 217 (extends pythonExternalOverrides
214 218 (extends pythonLocalOverrides
215 219 (extends pythonOverrides
216 220 pythonGeneratedPackages)));
217 221 myPythonPackages = (fix myPythonPackagesUnfix);
218 222
219 223 in myPythonPackages.rhodecode-enterprise-ce
General Comments 0
You need to be logged in to leave comments. Login now