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