##// END OF EJS Templates
packaging: Backport bower support utilities...
johbo -
r725:57489056 default
parent child Browse files
Show More
@@ -0,0 +1,60 b''
1 # Backported buildBowerComponents so that we can also use it with the version
2 # 16.03 which is the current stable at the time of this writing.
3 #
4 # This file can be removed once building with 16.03 is not needed anymore.
5
6 { pkgs }:
7
8 { buildInputs ? [], generated, ... } @ attrs:
9
10 let
11 fetchbower = import ./backport-16.03-fetchbower.nix {
12 inherit (pkgs) stdenv lib;
13 inherit (pkgs.nodePackages) bower2nix;
14 };
15
16 # Fetches the bower packages. `generated` should be the result of a
17 # `bower2nix` command.
18 bowerPackages = import generated {
19 inherit (pkgs) buildEnv;
20 inherit fetchbower;
21 };
22
23 in pkgs.stdenv.mkDerivation (
24 attrs
25 //
26 {
27 name = "bower_components-" + attrs.name;
28
29 inherit bowerPackages;
30
31 builder = builtins.toFile "builder.sh" ''
32 source $stdenv/setup
33
34 # The project's bower.json is required
35 cp $src/bower.json .
36
37 # Dereference symlinks -- bower doesn't like them
38 cp --recursive --reflink=auto \
39 --dereference --no-preserve=mode \
40 $bowerPackages bc
41
42 # Bower install in offline mode -- links together the fetched
43 # bower packages.
44 HOME=$PWD bower \
45 --config.storage.packages=bc/packages \
46 --config.storage.registry=bc/registry \
47 --offline install
48
49 # Sets up a single bower_components directory within
50 # the output derivation.
51 mkdir -p $out
52 mv bower_components $out
53 '';
54
55 buildInputs = buildInputs ++ [
56 pkgs.git
57 pkgs.nodePackages.bower
58 ];
59 }
60 )
@@ -0,0 +1,26 b''
1 { stdenv, lib, bower2nix }:
2 let
3 bowerVersion = version:
4 let
5 components = lib.splitString "#" version;
6 hash = lib.last components;
7 ver = if builtins.length components == 1 then version else hash;
8 in ver;
9
10 fetchbower = name: version: target: outputHash: stdenv.mkDerivation {
11 name = "${name}-${bowerVersion version}";
12 buildCommand = ''
13 fetch-bower --quiet --out=$PWD/out "${name}" "${target}" "${version}"
14 # In some cases, the result of fetchBower is different depending
15 # on the output directory (e.g. if the bower package contains
16 # symlinks). So use a local output directory before copying to
17 # $out.
18 cp -R out $out
19 '';
20 outputHashMode = "recursive";
21 outputHashAlgo = "sha256";
22 inherit outputHash;
23 buildInputs = [ bower2nix ];
24 };
25
26 in fetchbower
@@ -1,239 +1,243 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 buildBowerComponents =
34 pkgs.buildBowerComponents or
35 (import ./pkgs/backport-16.03-build-bower-components.nix { inherit pkgs; });
36
33 37 elem = builtins.elem;
34 38 basename = path: with pkgs.lib; last (splitString "/" path);
35 39 startsWith = prefix: full: let
36 40 actualPrefix = builtins.substring 0 (builtins.stringLength prefix) full;
37 41 in actualPrefix == prefix;
38 42
39 43 src-filter = path: type: with pkgs.lib;
40 44 let
41 45 ext = last (splitString "." path);
42 46 in
43 47 !elem (basename path) [
44 48 ".git" ".hg" "__pycache__" ".eggs"
45 49 "bower_components" "node_modules"
46 50 "build" "data" "result" "tmp"] &&
47 51 !elem ext ["egg-info" "pyc"] &&
48 52 # TODO: johbo: This check is wrong, since "path" contains an absolute path,
49 53 # it would still be good to restore it since we want to ignore "result-*".
50 54 !startsWith "result" path;
51 55
52 56 sources = pkgs.config.rc.sources or {};
53 57 version = builtins.readFile ./rhodecode/VERSION;
54 58 rhodecode-enterprise-ce-src = builtins.filterSource src-filter ./.;
55 59
56 60 nodeEnv = import ./pkgs/node-default.nix {
57 61 inherit pkgs;
58 62 };
59 63 nodeDependencies = nodeEnv.shell.nodeDependencies;
60 64
61 bowerComponents = pkgs.buildBowerComponents {
65 bowerComponents = buildBowerComponents {
62 66 name = "enterprise-ce-${version}";
63 67 generated = ./pkgs/bower-packages.nix;
64 68 src = rhodecode-enterprise-ce-src;
65 69 };
66 70
67 71 pythonGeneratedPackages = self: basePythonPackages.override (a: {
68 72 inherit self;
69 73 })
70 74 // (scopedImport {
71 75 self = self;
72 76 super = basePythonPackages;
73 77 inherit pkgs;
74 78 inherit (pkgs) fetchurl fetchgit;
75 79 } ./pkgs/python-packages.nix);
76 80
77 81 pythonOverrides = import ./pkgs/python-packages-overrides.nix {
78 82 inherit
79 83 basePythonPackages
80 84 pkgs;
81 85 };
82 86
83 87 pythonLocalOverrides = self: super: {
84 88 rhodecode-enterprise-ce =
85 89 let
86 90 linkNodeAndBowerPackages = ''
87 91 echo "Link node packages"
88 92 rm -fr node_modules
89 93 mkdir node_modules
90 94
91 95 # johbo: Linking individual packages allows us to run "npm install"
92 96 # inside of a shell to try things out. Re-entering the shell will
93 97 # restore a clean environment.
94 98 ln -s ${nodeDependencies}/lib/node_modules/* node_modules/
95 99
96 100 echo "DONE: Link node packages"
97 101
98 102 echo "Link bower packages"
99 103 rm -fr bower_components
100 104 mkdir bower_components
101 105
102 106 ln -s ${bowerComponents}/bower_components/* bower_components/
103 107 echo "DONE: Link bower packages"
104 108 '';
105 109 in super.rhodecode-enterprise-ce.override (attrs: {
106 110
107 111 inherit
108 112 doCheck
109 113 version;
110 114 name = "rhodecode-enterprise-ce-${version}";
111 115 releaseName = "RhodeCodeEnterpriseCE-${version}";
112 116 src = rhodecode-enterprise-ce-src;
113 117
114 118 buildInputs =
115 119 attrs.buildInputs ++
116 120 (with self; [
117 121 pkgs.nodePackages.bower
118 122 pkgs.nodePackages.grunt-cli
119 123 pkgs.subversion
120 124 pytest-catchlog
121 125 rhodecode-testdata
122 126 ]);
123 127
124 128 propagatedBuildInputs = attrs.propagatedBuildInputs ++ (with self; [
125 129 rhodecode-tools
126 130 ]);
127 131
128 132 # TODO: johbo: Make a nicer way to expose the parts. Maybe
129 133 # pkgs/default.nix?
130 134 passthru = {
131 135 inherit
132 136 bowerComponents
133 137 linkNodeAndBowerPackages
134 138 myPythonPackagesUnfix
135 139 pythonLocalOverrides;
136 140 pythonPackages = self;
137 141
138 142 # johbo: Legacy support for the EE build mechanisms
139 143 linkNodeModules = linkNodeAndBowerPackages;
140 144 };
141 145
142 146 LC_ALL = "en_US.UTF-8";
143 147 LOCALE_ARCHIVE =
144 148 if pkgs.stdenv ? glibc
145 149 then "${pkgs.glibcLocales}/lib/locale/locale-archive"
146 150 else "";
147 151
148 152 # Somewhat snappier setup of the development environment
149 153 # TODO: move into shell.nix
150 154 # TODO: think of supporting a stable path again, so that multiple shells
151 155 # can share it.
152 156 shellHook = ''
153 157 tmp_path=$(mktemp -d)
154 158 export PATH="$tmp_path/bin:$PATH"
155 159 export PYTHONPATH="$tmp_path/${self.python.sitePackages}:$PYTHONPATH"
156 160 mkdir -p $tmp_path/${self.python.sitePackages}
157 161 python setup.py develop --prefix $tmp_path --allow-hosts ""
158 162 '' + linkNodeAndBowerPackages;
159 163
160 164 preCheck = ''
161 165 export PATH="$out/bin:$PATH"
162 166 '';
163 167
164 168 postCheck = ''
165 169 rm -rf $out/lib/${self.python.libPrefix}/site-packages/pytest_pylons
166 170 rm -rf $out/lib/${self.python.libPrefix}/site-packages/rhodecode/tests
167 171 '';
168 172
169 173 preBuild = linkNodeAndBowerPackages + ''
170 174 grunt
171 175 rm -fr node_modules
172 176 '';
173 177
174 178 postInstall = ''
175 179 # python based programs need to be wrapped
176 180 ln -s ${self.supervisor}/bin/supervisor* $out/bin/
177 181 ln -s ${self.gunicorn}/bin/gunicorn $out/bin/
178 182 ln -s ${self.PasteScript}/bin/paster $out/bin/
179 183 ln -s ${self.channelstream}/bin/channelstream $out/bin/
180 184 ln -s ${self.pyramid}/bin/* $out/bin/ #*/
181 185
182 186 # rhodecode-tools
183 187 # TODO: johbo: re-think this. Do the tools import anything from enterprise?
184 188 ln -s ${self.rhodecode-tools}/bin/rhodecode-* $out/bin/
185 189
186 190 # note that condition should be restricted when adding further tools
187 191 for file in $out/bin/*; do #*/
188 192 wrapProgram $file \
189 193 --prefix PYTHONPATH : $PYTHONPATH \
190 194 --prefix PATH : $PATH \
191 195 --set PYTHONHASHSEED random
192 196 done
193 197
194 198 mkdir $out/etc
195 199 cp configs/production.ini $out/etc
196 200
197 201 echo "Writing meta information for rccontrol to nix-support/rccontrol"
198 202 mkdir -p $out/nix-support/rccontrol
199 203 cp -v rhodecode/VERSION $out/nix-support/rccontrol/version
200 204 echo "DONE: Meta information for rccontrol written"
201 205
202 206 # TODO: johbo: Make part of ac-tests
203 207 if [ ! -f rhodecode/public/js/scripts.js ]; then
204 208 echo "Missing scripts.js"
205 209 exit 1
206 210 fi
207 211 if [ ! -f rhodecode/public/css/style.css ]; then
208 212 echo "Missing style.css"
209 213 exit 1
210 214 fi
211 215 '';
212 216
213 217 });
214 218
215 219 rhodecode-testdata = import "${rhodecode-testdata-src}/default.nix" {
216 220 inherit
217 221 doCheck
218 222 pkgs
219 223 pythonPackages;
220 224 };
221 225
222 226 };
223 227
224 228 rhodecode-testdata-src = sources.rhodecode-testdata or (
225 229 pkgs.fetchhg {
226 230 url = "https://code.rhodecode.com/upstream/rc_testdata";
227 231 rev = "v0.8.0";
228 232 sha256 = "0hy1ba134rq2f9si85yx7j4qhc9ky0hjzdk553s3q026i7km809m";
229 233 });
230 234
231 235 # Apply all overrides and fix the final package set
232 236 myPythonPackagesUnfix =
233 237 (extends pythonExternalOverrides
234 238 (extends pythonLocalOverrides
235 239 (extends pythonOverrides
236 240 pythonGeneratedPackages)));
237 241 myPythonPackages = (fix myPythonPackagesUnfix);
238 242
239 243 in myPythonPackages.rhodecode-enterprise-ce
General Comments 0
You need to be logged in to leave comments. Login now