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