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