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