##// END OF EJS Templates
packaging: don't wrap rhodecode tools since they are fully standalone.
marcink -
r3121:0c8c3c35 default
parent child Browse files
Show More
@@ -1,258 +1,260 b''
1 1 # Nix environment for the community edition
2 2 #
3 3 # This shall be as lean as possible, just producing the enterprise-ce
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 # Configuration, set values in "~/.nixpkgs/config.nix".
8 8 # example
9 9 # {
10 10 # # Thoughts on how to configure the dev environment
11 11 # rc = {
12 12 # codeInternalUrl = "https://usr:token@internal-code.rhodecode.com";
13 13 # sources = {
14 14 # rhodecode-vcsserver = "/home/user/work/rhodecode-vcsserver";
15 15 # rhodecode-enterprise-ce = "/home/user/work/rhodecode-enterprise-ce";
16 16 # rhodecode-enterprise-ee = "/home/user/work/rhodecode-enterprise-ee";
17 17 # };
18 18 # };
19 19 # }
20 20
21 21 args@
22 22 { pythonPackages ? "python27Packages"
23 23 , pythonExternalOverrides ? self: super: {}
24 24 , doCheck ? false
25 25 , ...
26 26 }:
27 27
28 28 let
29 29 # Use nixpkgs from args or import them. We use this indirect approach
30 30 # through args to be able to use the name `pkgs` for our customized packages.
31 31 # Otherwise we will end up with an infinite recursion.
32 32 pkgs = args.pkgs or (import <nixpkgs> { });
33 33
34 34 # Works with the new python-packages, still can fallback to the old
35 35 # variant.
36 36 basePythonPackagesUnfix = basePythonPackages.__unfix__ or (
37 37 self: basePythonPackages.override (a: { inherit self; }));
38 38
39 39 # Evaluates to the last segment of a file system path.
40 40 basename = path: with pkgs.lib; last (splitString "/" path);
41 41
42 42 # source code filter used as arugment to builtins.filterSource.
43 43 src-filter = path: type: with pkgs.lib;
44 44 let
45 45 ext = last (splitString "." path);
46 46 in
47 47 !builtins.elem (basename path) [
48 48 ".git" ".hg" "__pycache__" ".eggs" ".idea" ".dev"
49 49 "bower_components" "node_modules"
50 50 "build" "data" "result" "tmp"] &&
51 51 !builtins.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 !hasPrefix "result" path;
55 55
56 56 sources =
57 57 let
58 58 inherit (pkgs.lib) all isString attrValues;
59 59 sourcesConfig = pkgs.config.rc.sources or {};
60 60 in
61 61 # Ensure that sources are configured as strings. Using a path
62 62 # would result in a copy into the nix store.
63 63 assert all isString (attrValues sourcesConfig);
64 64 sourcesConfig;
65 65
66 66 version = builtins.readFile "${rhodecode-enterprise-ce-src}/rhodecode/VERSION";
67 67 rhodecode-enterprise-ce-src = builtins.filterSource src-filter ./.;
68 68
69 69 buildBowerComponents = pkgs.buildBowerComponents;
70 70 nodeEnv = import ./pkgs/node-default.nix {
71 71 inherit pkgs;
72 72 };
73 73 nodeDependencies = nodeEnv.shell.nodeDependencies;
74 74
75 75 bowerComponents = buildBowerComponents {
76 76 name = "enterprise-ce-${version}";
77 77 generated = ./pkgs/bower-packages.nix;
78 78 src = rhodecode-enterprise-ce-src;
79 79 };
80 80
81 81 rhodecode-testdata-src = sources.rhodecode-testdata or (
82 82 pkgs.fetchhg {
83 83 url = "https://code.rhodecode.com/upstream/rc_testdata";
84 84 rev = "v0.10.0";
85 85 sha256 = "0zn9swwvx4vgw4qn8q3ri26vvzgrxn15x6xnjrysi1bwmz01qjl0";
86 86 });
87 87
88 88 rhodecode-testdata = import "${rhodecode-testdata-src}/default.nix" {
89 89 inherit
90 90 doCheck
91 91 pkgs
92 92 pythonPackages;
93 93 };
94 94
95 95 pythonLocalOverrides = self: super: {
96 96 rhodecode-enterprise-ce =
97 97 let
98 98 linkNodeAndBowerPackages = ''
99 99 export RHODECODE_CE_PATH=${rhodecode-enterprise-ce-src}
100 100
101 101 echo "[BEGIN]: Link node packages"
102 102 rm -fr node_modules
103 103 mkdir node_modules
104 104 # johbo: Linking individual packages allows us to run "npm install"
105 105 # inside of a shell to try things out. Re-entering the shell will
106 106 # restore a clean environment.
107 107 ln -s ${nodeDependencies}/lib/node_modules/* node_modules/
108 108 echo "[DONE]: Link node packages"
109 109
110 110 echo "[BEGIN]: Link bower packages"
111 111 rm -fr bower_components
112 112 mkdir bower_components
113 113 ln -s ${bowerComponents}/bower_components/* bower_components/
114 114 echo "[DONE]: Link bower packages"
115 115 '';
116 116
117 117 releaseName = "RhodeCodeEnterpriseCE-${version}";
118 118 in super.rhodecode-enterprise-ce.override (attrs: {
119 119 inherit
120 120 doCheck
121 121 version;
122 122
123 123 name = "rhodecode-enterprise-ce-${version}";
124 124 releaseName = releaseName;
125 125 src = rhodecode-enterprise-ce-src;
126 126 dontStrip = true; # prevent strip, we don't need it.
127 127
128 128 # expose following attributed outside
129 129 passthru = {
130 130 inherit
131 131 rhodecode-testdata
132 132 bowerComponents
133 133 linkNodeAndBowerPackages
134 134 myPythonPackagesUnfix
135 135 pythonLocalOverrides
136 136 pythonCommunityOverrides;
137 137
138 138 pythonPackages = self;
139 139 };
140 140
141 141 buildInputs =
142 142 attrs.buildInputs or [] ++ [
143 143 rhodecode-testdata
144 144 pkgs.nodePackages.bower
145 145 pkgs.nodePackages.grunt-cli
146 146 ];
147 147
148 148 #NOTE: option to inject additional propagatedBuildInputs
149 149 propagatedBuildInputs =
150 150 attrs.propagatedBuildInputs or [] ++ [
151 151
152 152 ];
153 153
154 154 LC_ALL = "en_US.UTF-8";
155 155 LOCALE_ARCHIVE =
156 156 if pkgs.stdenv.isLinux
157 157 then "${pkgs.glibcLocales}/lib/locale/locale-archive"
158 158 else "";
159 159
160 160 # Add bin directory to path so that tests can find 'rhodecode'.
161 161 preCheck = ''
162 162 export PATH="$out/bin:$PATH"
163 163 '';
164 164
165 165 # custom check phase for testing
166 166 checkPhase = ''
167 167 runHook preCheck
168 168 PYTHONHASHSEED=random py.test -vv -p no:sugar -r xw --cov-config=.coveragerc --cov=rhodecode --cov-report=term-missing rhodecode
169 169 runHook postCheck
170 170 '';
171 171
172 172 postCheck = ''
173 173 echo "Cleanup of rhodecode/tests"
174 174 rm -rf $out/lib/${self.python.libPrefix}/site-packages/rhodecode/tests
175 175 '';
176 176
177 177 preBuild = ''
178
179 178 echo "Building frontend assets"
180 179 ${linkNodeAndBowerPackages}
181 180 grunt
182 181 rm -fr node_modules
183 182 '';
184 183
185 184 postInstall = ''
185 # check required files
186 if [ ! -f rhodecode/public/js/scripts.js ]; then
187 echo "Missing scripts.js"
188 exit 1
189 fi
190 if [ ! -f rhodecode/public/css/style.css ]; then
191 echo "Missing style.css"
192 exit 1
193 fi
194
186 195 echo "Writing enterprise-ce meta information for rccontrol to nix-support/rccontrol"
187 196 mkdir -p $out/nix-support/rccontrol
188 197 cp -v rhodecode/VERSION $out/nix-support/rccontrol/version
189 198 echo "[DONE]: enterprise-ce meta information for rccontrol written"
190 199
191 200 mkdir -p $out/etc
192 201 cp configs/production.ini $out/etc
193 202 echo "[DONE]: saved enterprise-ce production.ini into $out/etc"
194 203
195 204 # python based programs need to be wrapped
196 205 mkdir -p $out/bin
197 # rhodecode-tools
198 ln -s ${self.rhodecode-tools}/bin/rhodecode-* $out/bin/
199 206
200 207 # required binaries from dependencies
201 208 #ln -s ${self.python}/bin/python $out/bin
202 209 ln -s ${self.pyramid}/bin/* $out/bin/
203 210 ln -s ${self.gunicorn}/bin/gunicorn $out/bin/
204 211 ln -s ${self.supervisor}/bin/supervisor* $out/bin/
205 212 ln -s ${self.pastescript}/bin/paster $out/bin/
206 213 ln -s ${self.channelstream}/bin/channelstream $out/bin/
207 214 ln -s ${self.celery}/bin/celery $out/bin/
208 215 echo "[DONE]: created symlinks into $out/bin"
209 216
210 217 for file in $out/bin/*;
211 218 do
212 219 wrapProgram $file \
213 220 --prefix PATH : $PATH \
214 221 --prefix PYTHONPATH : $PYTHONPATH \
215 222 --set PYTHONHASHSEED random
216 223 done
217 224
218 225 echo "[DONE]: enterprise-ce binary wrapping"
219 226
220 if [ ! -f rhodecode/public/js/scripts.js ]; then
221 echo "Missing scripts.js"
222 exit 1
223 fi
224 if [ ! -f rhodecode/public/css/style.css ]; then
225 echo "Missing style.css"
226 exit 1
227 fi
227 # rhodecode-tools don't need wrapping
228 ln -s ${self.rhodecode-tools}/bin/rhodecode-* $out/bin/
229
228 230 '';
229 231 });
230 232
231 233 };
232 234
233 235 basePythonPackages = with builtins;
234 236 if isAttrs pythonPackages then
235 237 pythonPackages
236 238 else
237 239 getAttr pythonPackages pkgs;
238 240
239 241 pythonGeneratedPackages = import ./pkgs/python-packages.nix {
240 242 inherit pkgs;
241 243 inherit (pkgs) fetchurl fetchgit fetchhg;
242 244 };
243 245
244 246 pythonCommunityOverrides = import ./pkgs/python-packages-overrides.nix {
245 247 inherit pkgs basePythonPackages;
246 248 };
247 249
248 250 # Apply all overrides and fix the final package set
249 251 myPythonPackagesUnfix = with pkgs.lib;
250 252 (extends pythonExternalOverrides
251 253 (extends pythonLocalOverrides
252 254 (extends pythonCommunityOverrides
253 255 (extends pythonGeneratedPackages
254 256 basePythonPackagesUnfix))));
255 257
256 258 myPythonPackages = (pkgs.lib.fix myPythonPackagesUnfix);
257 259
258 260 in myPythonPackages.rhodecode-enterprise-ce
General Comments 0
You need to be logged in to leave comments. Login now