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