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