##// END OF EJS Templates
packaging: Expose the local overrides via passthru.
johbo -
r74:6d3db5be default
parent child
Show More
@@ -1,215 +1,217
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 rhodecode-enterprise-ce-src = builtins.filterSource src-filter ./.;
49 rhodecode-enterprise-ce-src = builtins.filterSource src-filter ./.;
50
50
51 # Load the generated node packages
51 # Load the generated node packages
52 nodePackages = pkgs.callPackage "${pkgs.path}/pkgs/top-level/node-packages.nix" rec {
52 nodePackages = pkgs.callPackage "${pkgs.path}/pkgs/top-level/node-packages.nix" rec {
53 self = nodePackages;
53 self = nodePackages;
54 generated = pkgs.callPackage ./pkgs/node-packages.nix { inherit self; };
54 generated = pkgs.callPackage ./pkgs/node-packages.nix { inherit self; };
55 };
55 };
56
56
57 # TODO: Should be taken automatically out of the generates packages.
57 # TODO: Should be taken automatically out of the generates packages.
58 # apps.nix has one solution for this, although I'd prefer to have the deps
58 # apps.nix has one solution for this, although I'd prefer to have the deps
59 # from package.json mapped in here.
59 # from package.json mapped in here.
60 nodeDependencies = with nodePackages; [
60 nodeDependencies = with nodePackages; [
61 grunt
61 grunt
62 grunt-contrib-concat
62 grunt-contrib-concat
63 grunt-contrib-jshint
63 grunt-contrib-jshint
64 grunt-contrib-less
64 grunt-contrib-less
65 grunt-contrib-watch
65 grunt-contrib-watch
66 jshint
66 jshint
67 ];
67 ];
68
68
69 pythonGeneratedPackages = self: basePythonPackages.override (a: {
69 pythonGeneratedPackages = self: basePythonPackages.override (a: {
70 inherit self;
70 inherit self;
71 })
71 })
72 // (scopedImport {
72 // (scopedImport {
73 self = self;
73 self = self;
74 super = basePythonPackages;
74 super = basePythonPackages;
75 inherit pkgs;
75 inherit pkgs;
76 inherit (pkgs) fetchurl fetchgit;
76 inherit (pkgs) fetchurl fetchgit;
77 } ./pkgs/python-packages.nix);
77 } ./pkgs/python-packages.nix);
78
78
79 pythonOverrides = import ./pkgs/python-packages-overrides.nix {
79 pythonOverrides = import ./pkgs/python-packages-overrides.nix {
80 inherit
80 inherit
81 basePythonPackages
81 basePythonPackages
82 pkgs;
82 pkgs;
83 };
83 };
84
84
85 pythonLocalOverrides = self: super: {
85 pythonLocalOverrides = self: super: {
86 rhodecode-enterprise-ce =
86 rhodecode-enterprise-ce =
87 let
87 let
88 version = "${builtins.readFile ./rhodecode/VERSION}";
88 version = "${builtins.readFile ./rhodecode/VERSION}";
89 linkNodeModules = ''
89 linkNodeModules = ''
90 echo "Link node packages"
90 echo "Link node packages"
91 # TODO: check if this adds stuff as a dependency, closure size
91 # TODO: check if this adds stuff as a dependency, closure size
92 rm -fr node_modules
92 rm -fr node_modules
93 mkdir -p node_modules
93 mkdir -p node_modules
94 ${pkgs.lib.concatMapStrings (dep: ''
94 ${pkgs.lib.concatMapStrings (dep: ''
95 ln -sfv ${dep}/lib/node_modules/${dep.pkgName} node_modules/
95 ln -sfv ${dep}/lib/node_modules/${dep.pkgName} node_modules/
96 '') nodeDependencies}
96 '') nodeDependencies}
97 echo "DONE: Link node packages"
97 echo "DONE: Link node packages"
98 '';
98 '';
99 in super.rhodecode-enterprise-ce.override (attrs: {
99 in super.rhodecode-enterprise-ce.override (attrs: {
100
100
101 inherit doCheck;
101 inherit doCheck;
102 name = "rhodecode-enterprise-ce-${version}";
102 name = "rhodecode-enterprise-ce-${version}";
103 version = version;
103 version = version;
104 src = rhodecode-enterprise-ce-src;
104 src = rhodecode-enterprise-ce-src;
105
105
106 buildInputs =
106 buildInputs =
107 attrs.buildInputs ++
107 attrs.buildInputs ++
108 (with self; [
108 (with self; [
109 pkgs.nodePackages.grunt-cli
109 pkgs.nodePackages.grunt-cli
110 pkgs.subversion
110 pkgs.subversion
111 pytest-catchlog
111 pytest-catchlog
112 rc_testdata
112 rc_testdata
113 ]);
113 ]);
114
114
115 propagatedBuildInputs = attrs.propagatedBuildInputs ++ (with self; [
115 propagatedBuildInputs = attrs.propagatedBuildInputs ++ (with self; [
116 rhodecode-tools
116 rhodecode-tools
117 ]);
117 ]);
118
118
119 # TODO: johbo: Make a nicer way to expose the parts. Maybe
119 # TODO: johbo: Make a nicer way to expose the parts. Maybe
120 # pkgs/default.nix?
120 # pkgs/default.nix?
121 passthru = {
121 passthru = {
122 inherit myPythonPackagesUnfix;
122 inherit
123 pythonLocalOverrides
124 myPythonPackagesUnfix;
123 pythonPackages = self;
125 pythonPackages = self;
124 };
126 };
125
127
126 LC_ALL = "en_US.UTF-8";
128 LC_ALL = "en_US.UTF-8";
127 LOCALE_ARCHIVE =
129 LOCALE_ARCHIVE =
128 if pkgs.stdenv ? glibc
130 if pkgs.stdenv ? glibc
129 then "${pkgs.glibcLocales}/lib/locale/locale-archive"
131 then "${pkgs.glibcLocales}/lib/locale/locale-archive"
130 else "";
132 else "";
131
133
132 # Somewhat snappier setup of the development environment
134 # Somewhat snappier setup of the development environment
133 # TODO: move into shell.nix
135 # TODO: move into shell.nix
134 # TODO: think of supporting a stable path again, so that multiple shells
136 # TODO: think of supporting a stable path again, so that multiple shells
135 # can share it.
137 # can share it.
136 shellHook = ''
138 shellHook = ''
137 tmp_path=$(mktemp -d)
139 tmp_path=$(mktemp -d)
138 export PATH="$tmp_path/bin:$PATH"
140 export PATH="$tmp_path/bin:$PATH"
139 export PYTHONPATH="$tmp_path/${self.python.sitePackages}:$PYTHONPATH"
141 export PYTHONPATH="$tmp_path/${self.python.sitePackages}:$PYTHONPATH"
140 mkdir -p $tmp_path/${self.python.sitePackages}
142 mkdir -p $tmp_path/${self.python.sitePackages}
141 python setup.py develop --prefix $tmp_path --allow-hosts ""
143 python setup.py develop --prefix $tmp_path --allow-hosts ""
142 '' + linkNodeModules;
144 '' + linkNodeModules;
143
145
144 preCheck = ''
146 preCheck = ''
145 export PATH="$out/bin:$PATH"
147 export PATH="$out/bin:$PATH"
146 '';
148 '';
147
149
148 postCheck = ''
150 postCheck = ''
149 rm -rf $out/lib/${self.python.libPrefix}/site-packages/pytest_pylons
151 rm -rf $out/lib/${self.python.libPrefix}/site-packages/pytest_pylons
150 rm -rf $out/lib/${self.python.libPrefix}/site-packages/rhodecode/tests
152 rm -rf $out/lib/${self.python.libPrefix}/site-packages/rhodecode/tests
151 '';
153 '';
152
154
153 preBuild = linkNodeModules + ''
155 preBuild = linkNodeModules + ''
154 grunt
156 grunt
155 rm -fr node_modules
157 rm -fr node_modules
156 '';
158 '';
157
159
158 postInstall = ''
160 postInstall = ''
159 # python based programs need to be wrapped
161 # python based programs need to be wrapped
160 ln -s ${self.supervisor}/bin/supervisor* $out/bin/
162 ln -s ${self.supervisor}/bin/supervisor* $out/bin/
161 ln -s ${self.gunicorn}/bin/gunicorn $out/bin/
163 ln -s ${self.gunicorn}/bin/gunicorn $out/bin/
162 ln -s ${self.PasteScript}/bin/paster $out/bin/
164 ln -s ${self.PasteScript}/bin/paster $out/bin/
163
165
164 # rhodecode-tools
166 # rhodecode-tools
165 # TODO: johbo: re-think this. Do the tools import anything from enterprise?
167 # TODO: johbo: re-think this. Do the tools import anything from enterprise?
166 ln -s ${self.rhodecode-tools}/bin/rhodecode-* $out/bin/
168 ln -s ${self.rhodecode-tools}/bin/rhodecode-* $out/bin/
167
169
168 # note that condition should be restricted when adding further tools
170 # note that condition should be restricted when adding further tools
169 for file in $out/bin/*; do #*/
171 for file in $out/bin/*; do #*/
170 wrapProgram $file \
172 wrapProgram $file \
171 --prefix PYTHONPATH : $PYTHONPATH \
173 --prefix PYTHONPATH : $PYTHONPATH \
172 --set PYTHONHASHSEED random
174 --set PYTHONHASHSEED random
173 done
175 done
174
176
175 mkdir $out/etc
177 mkdir $out/etc
176 cp configs/production.ini $out/etc
178 cp configs/production.ini $out/etc
177
179
178 echo "Writing meta information for rccontrol to nix-support/rccontrol"
180 echo "Writing meta information for rccontrol to nix-support/rccontrol"
179 mkdir -p $out/nix-support/rccontrol
181 mkdir -p $out/nix-support/rccontrol
180 cp -v rhodecode/VERSION $out/nix-support/rccontrol/version
182 cp -v rhodecode/VERSION $out/nix-support/rccontrol/version
181 echo "DONE: Meta information for rccontrol written"
183 echo "DONE: Meta information for rccontrol written"
182
184
183 # TODO: johbo: Make part of ac-tests
185 # TODO: johbo: Make part of ac-tests
184 if [ ! -f rhodecode/public/js/scripts.js ]; then
186 if [ ! -f rhodecode/public/js/scripts.js ]; then
185 echo "Missing scripts.js"
187 echo "Missing scripts.js"
186 exit 1
188 exit 1
187 fi
189 fi
188 if [ ! -f rhodecode/public/css/style.css ]; then
190 if [ ! -f rhodecode/public/css/style.css ]; then
189 echo "Missing style.css"
191 echo "Missing style.css"
190 exit 1
192 exit 1
191 fi
193 fi
192 '';
194 '';
193
195
194 });
196 });
195
197
196 rc_testdata = self.buildPythonPackage rec {
198 rc_testdata = self.buildPythonPackage rec {
197 name = "rc_testdata-0.7.0";
199 name = "rc_testdata-0.7.0";
198 src = pkgs.fetchhg {
200 src = pkgs.fetchhg {
199 url = "https://code.rhodecode.com/upstream/rc_testdata";
201 url = "https://code.rhodecode.com/upstream/rc_testdata";
200 rev = "v0.7.0";
202 rev = "v0.7.0";
201 sha256 = "0w3z0zn8lagr707v67lgys23sl6pbi4xg7pfvdbw58h3q384h6rx";
203 sha256 = "0w3z0zn8lagr707v67lgys23sl6pbi4xg7pfvdbw58h3q384h6rx";
202 };
204 };
203 };
205 };
204
206
205 };
207 };
206
208
207 # Apply all overrides and fix the final package set
209 # Apply all overrides and fix the final package set
208 myPythonPackagesUnfix =
210 myPythonPackagesUnfix =
209 (extends pythonExternalOverrides
211 (extends pythonExternalOverrides
210 (extends pythonLocalOverrides
212 (extends pythonLocalOverrides
211 (extends pythonOverrides
213 (extends pythonOverrides
212 pythonGeneratedPackages)));
214 pythonGeneratedPackages)));
213 myPythonPackages = (fix myPythonPackagesUnfix);
215 myPythonPackages = (fix myPythonPackagesUnfix);
214
216
215 in myPythonPackages.rhodecode-enterprise-ce
217 in myPythonPackages.rhodecode-enterprise-ce
General Comments 0
You need to be logged in to leave comments. Login now