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