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