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