##// END OF EJS Templates
nix: export CE sources path
ergo -
r743:61db3ea9 default
parent child Browse files
Show More
@@ -1,240 +1,241 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 buildBowerComponents =
34 34 pkgs.buildBowerComponents or
35 35 (import ./pkgs/backport-16.03-build-bower-components.nix { inherit pkgs; });
36 36
37 37 elem = builtins.elem;
38 38 basename = path: with pkgs.lib; last (splitString "/" path);
39 39 startsWith = prefix: full: let
40 40 actualPrefix = builtins.substring 0 (builtins.stringLength prefix) full;
41 41 in actualPrefix == prefix;
42 42
43 43 src-filter = path: type: with pkgs.lib;
44 44 let
45 45 ext = last (splitString "." path);
46 46 in
47 47 !elem (basename path) [
48 48 ".git" ".hg" "__pycache__" ".eggs"
49 49 "bower_components" "node_modules"
50 50 "build" "data" "result" "tmp"] &&
51 51 !elem ext ["egg-info" "pyc"] &&
52 52 # TODO: johbo: This check is wrong, since "path" contains an absolute path,
53 53 # it would still be good to restore it since we want to ignore "result-*".
54 54 !startsWith "result" path;
55 55
56 56 sources = pkgs.config.rc.sources or {};
57 57 version = builtins.readFile ./rhodecode/VERSION;
58 58 rhodecode-enterprise-ce-src = builtins.filterSource src-filter ./.;
59 59
60 60 nodeEnv = import ./pkgs/node-default.nix {
61 61 inherit pkgs;
62 62 };
63 63 nodeDependencies = nodeEnv.shell.nodeDependencies;
64 64
65 65 bowerComponents = buildBowerComponents {
66 66 name = "enterprise-ce-${version}";
67 67 generated = ./pkgs/bower-packages.nix;
68 68 src = rhodecode-enterprise-ce-src;
69 69 };
70 70
71 71 pythonGeneratedPackages = self: basePythonPackages.override (a: {
72 72 inherit self;
73 73 })
74 74 // (scopedImport {
75 75 self = self;
76 76 super = basePythonPackages;
77 77 inherit pkgs;
78 78 inherit (pkgs) fetchurl fetchgit;
79 79 } ./pkgs/python-packages.nix);
80 80
81 81 pythonOverrides = import ./pkgs/python-packages-overrides.nix {
82 82 inherit
83 83 basePythonPackages
84 84 pkgs;
85 85 };
86 86
87 87 pythonLocalOverrides = self: super: {
88 88 rhodecode-enterprise-ce =
89 89 let
90 90 linkNodeAndBowerPackages = ''
91 echo "Export RhodeCode CE path"
92 export RHODECODE_CE_PATH=${rhodecode-enterprise-ce-src}
91 93 echo "Link node packages"
92 94 rm -fr node_modules
93 95 mkdir node_modules
94
95 96 # johbo: Linking individual packages allows us to run "npm install"
96 97 # inside of a shell to try things out. Re-entering the shell will
97 98 # restore a clean environment.
98 99 ln -s ${nodeDependencies}/lib/node_modules/* node_modules/
99 100
100 101 echo "DONE: Link node packages"
101 102
102 103 echo "Link bower packages"
103 104 rm -fr bower_components
104 105 mkdir bower_components
105 106
106 107 ln -s ${bowerComponents}/bower_components/* bower_components/
107 108 echo "DONE: Link bower packages"
108 109 '';
109 110 in super.rhodecode-enterprise-ce.override (attrs: {
110 111
111 112 inherit
112 113 doCheck
113 114 version;
114 115 name = "rhodecode-enterprise-ce-${version}";
115 116 releaseName = "RhodeCodeEnterpriseCE-${version}";
116 117 src = rhodecode-enterprise-ce-src;
117 118
118 119 buildInputs =
119 120 attrs.buildInputs ++
120 121 (with self; [
121 122 pkgs.nodePackages.bower
122 123 pkgs.nodePackages.grunt-cli
123 124 pkgs.subversion
124 125 pytest-catchlog
125 126 rhodecode-testdata
126 127 ]);
127 128
128 129 propagatedBuildInputs = attrs.propagatedBuildInputs ++ (with self; [
129 130 rhodecode-tools
130 131 ]);
131 132
132 133 # TODO: johbo: Make a nicer way to expose the parts. Maybe
133 134 # pkgs/default.nix?
134 135 passthru = {
135 136 inherit
136 137 bowerComponents
137 138 linkNodeAndBowerPackages
138 139 myPythonPackagesUnfix
139 140 pythonLocalOverrides;
140 141 pythonPackages = self;
141 142 };
142 143
143 144 LC_ALL = "en_US.UTF-8";
144 145 LOCALE_ARCHIVE =
145 146 if pkgs.stdenv ? glibc
146 147 then "${pkgs.glibcLocales}/lib/locale/locale-archive"
147 148 else "";
148 149
149 150 # Somewhat snappier setup of the development environment
150 151 # TODO: move into shell.nix
151 152 # TODO: think of supporting a stable path again, so that multiple shells
152 153 # can share it.
153 154 shellHook = ''
154 155 tmp_path=$(mktemp -d)
155 156 export PATH="$tmp_path/bin:$PATH"
156 157 export PYTHONPATH="$tmp_path/${self.python.sitePackages}:$PYTHONPATH"
157 158 mkdir -p $tmp_path/${self.python.sitePackages}
158 159 python setup.py develop --prefix $tmp_path --allow-hosts ""
159 160 '' + linkNodeAndBowerPackages;
160 161
161 162 preCheck = ''
162 163 export PATH="$out/bin:$PATH"
163 164 '';
164 165
165 166 postCheck = ''
166 167 rm -rf $out/lib/${self.python.libPrefix}/site-packages/pytest_pylons
167 168 rm -rf $out/lib/${self.python.libPrefix}/site-packages/rhodecode/tests
168 169 '';
169 170
170 171 preBuild = linkNodeAndBowerPackages + ''
171 172 grunt
172 173 rm -fr node_modules
173 174 '';
174 175
175 176 postInstall = ''
176 177 # python based programs need to be wrapped
177 178 ln -s ${self.supervisor}/bin/supervisor* $out/bin/
178 179 ln -s ${self.gunicorn}/bin/gunicorn $out/bin/
179 180 ln -s ${self.PasteScript}/bin/paster $out/bin/
180 181 ln -s ${self.channelstream}/bin/channelstream $out/bin/
181 182 ln -s ${self.pyramid}/bin/* $out/bin/ #*/
182 183
183 184 # rhodecode-tools
184 185 # TODO: johbo: re-think this. Do the tools import anything from enterprise?
185 186 ln -s ${self.rhodecode-tools}/bin/rhodecode-* $out/bin/
186 187
187 188 # note that condition should be restricted when adding further tools
188 189 for file in $out/bin/*; do #*/
189 190 wrapProgram $file \
190 191 --prefix PYTHONPATH : $PYTHONPATH \
191 192 --prefix PATH : $PATH \
192 193 --set PYTHONHASHSEED random
193 194 done
194 195
195 196 mkdir $out/etc
196 197 cp configs/production.ini $out/etc
197 198
198 199 echo "Writing meta information for rccontrol to nix-support/rccontrol"
199 200 mkdir -p $out/nix-support/rccontrol
200 201 cp -v rhodecode/VERSION $out/nix-support/rccontrol/version
201 202 echo "DONE: Meta information for rccontrol written"
202 203
203 204 # TODO: johbo: Make part of ac-tests
204 205 if [ ! -f rhodecode/public/js/scripts.js ]; then
205 206 echo "Missing scripts.js"
206 207 exit 1
207 208 fi
208 209 if [ ! -f rhodecode/public/css/style.css ]; then
209 210 echo "Missing style.css"
210 211 exit 1
211 212 fi
212 213 '';
213 214
214 215 });
215 216
216 217 rhodecode-testdata = import "${rhodecode-testdata-src}/default.nix" {
217 218 inherit
218 219 doCheck
219 220 pkgs
220 221 pythonPackages;
221 222 };
222 223
223 224 };
224 225
225 226 rhodecode-testdata-src = sources.rhodecode-testdata or (
226 227 pkgs.fetchhg {
227 228 url = "https://code.rhodecode.com/upstream/rc_testdata";
228 229 rev = "v0.8.0";
229 230 sha256 = "0hy1ba134rq2f9si85yx7j4qhc9ky0hjzdk553s3q026i7km809m";
230 231 });
231 232
232 233 # Apply all overrides and fix the final package set
233 234 myPythonPackagesUnfix =
234 235 (extends pythonExternalOverrides
235 236 (extends pythonLocalOverrides
236 237 (extends pythonOverrides
237 238 pythonGeneratedPackages)));
238 239 myPythonPackages = (fix myPythonPackagesUnfix);
239 240
240 241 in myPythonPackages.rhodecode-enterprise-ce
General Comments 0
You need to be logged in to leave comments. Login now