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