##// END OF EJS Templates
packaging: Clean up call to read the version...
johbo -
r145:fe085dfd default
parent child Browse files
Show More
@@ -1,217 +1,217 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 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
122 inherit
123 pythonLocalOverrides
123 pythonLocalOverrides
124 myPythonPackagesUnfix;
124 myPythonPackagesUnfix;
125 pythonPackages = self;
125 pythonPackages = self;
126 };
126 };
127
127
128 LC_ALL = "en_US.UTF-8";
128 LC_ALL = "en_US.UTF-8";
129 LOCALE_ARCHIVE =
129 LOCALE_ARCHIVE =
130 if pkgs.stdenv ? glibc
130 if pkgs.stdenv ? glibc
131 then "${pkgs.glibcLocales}/lib/locale/locale-archive"
131 then "${pkgs.glibcLocales}/lib/locale/locale-archive"
132 else "";
132 else "";
133
133
134 # Somewhat snappier setup of the development environment
134 # Somewhat snappier setup of the development environment
135 # TODO: move into shell.nix
135 # TODO: move into shell.nix
136 # 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
137 # can share it.
137 # can share it.
138 shellHook = ''
138 shellHook = ''
139 tmp_path=$(mktemp -d)
139 tmp_path=$(mktemp -d)
140 export PATH="$tmp_path/bin:$PATH"
140 export PATH="$tmp_path/bin:$PATH"
141 export PYTHONPATH="$tmp_path/${self.python.sitePackages}:$PYTHONPATH"
141 export PYTHONPATH="$tmp_path/${self.python.sitePackages}:$PYTHONPATH"
142 mkdir -p $tmp_path/${self.python.sitePackages}
142 mkdir -p $tmp_path/${self.python.sitePackages}
143 python setup.py develop --prefix $tmp_path --allow-hosts ""
143 python setup.py develop --prefix $tmp_path --allow-hosts ""
144 '' + linkNodeModules;
144 '' + linkNodeModules;
145
145
146 preCheck = ''
146 preCheck = ''
147 export PATH="$out/bin:$PATH"
147 export PATH="$out/bin:$PATH"
148 '';
148 '';
149
149
150 postCheck = ''
150 postCheck = ''
151 rm -rf $out/lib/${self.python.libPrefix}/site-packages/pytest_pylons
151 rm -rf $out/lib/${self.python.libPrefix}/site-packages/pytest_pylons
152 rm -rf $out/lib/${self.python.libPrefix}/site-packages/rhodecode/tests
152 rm -rf $out/lib/${self.python.libPrefix}/site-packages/rhodecode/tests
153 '';
153 '';
154
154
155 preBuild = linkNodeModules + ''
155 preBuild = linkNodeModules + ''
156 grunt
156 grunt
157 rm -fr node_modules
157 rm -fr node_modules
158 '';
158 '';
159
159
160 postInstall = ''
160 postInstall = ''
161 # python based programs need to be wrapped
161 # python based programs need to be wrapped
162 ln -s ${self.supervisor}/bin/supervisor* $out/bin/
162 ln -s ${self.supervisor}/bin/supervisor* $out/bin/
163 ln -s ${self.gunicorn}/bin/gunicorn $out/bin/
163 ln -s ${self.gunicorn}/bin/gunicorn $out/bin/
164 ln -s ${self.PasteScript}/bin/paster $out/bin/
164 ln -s ${self.PasteScript}/bin/paster $out/bin/
165
165
166 # rhodecode-tools
166 # rhodecode-tools
167 # 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?
168 ln -s ${self.rhodecode-tools}/bin/rhodecode-* $out/bin/
168 ln -s ${self.rhodecode-tools}/bin/rhodecode-* $out/bin/
169
169
170 # note that condition should be restricted when adding further tools
170 # note that condition should be restricted when adding further tools
171 for file in $out/bin/*; do #*/
171 for file in $out/bin/*; do #*/
172 wrapProgram $file \
172 wrapProgram $file \
173 --prefix PYTHONPATH : $PYTHONPATH \
173 --prefix PYTHONPATH : $PYTHONPATH \
174 --set PYTHONHASHSEED random
174 --set PYTHONHASHSEED random
175 done
175 done
176
176
177 mkdir $out/etc
177 mkdir $out/etc
178 cp configs/production.ini $out/etc
178 cp configs/production.ini $out/etc
179
179
180 echo "Writing meta information for rccontrol to nix-support/rccontrol"
180 echo "Writing meta information for rccontrol to nix-support/rccontrol"
181 mkdir -p $out/nix-support/rccontrol
181 mkdir -p $out/nix-support/rccontrol
182 cp -v rhodecode/VERSION $out/nix-support/rccontrol/version
182 cp -v rhodecode/VERSION $out/nix-support/rccontrol/version
183 echo "DONE: Meta information for rccontrol written"
183 echo "DONE: Meta information for rccontrol written"
184
184
185 # TODO: johbo: Make part of ac-tests
185 # TODO: johbo: Make part of ac-tests
186 if [ ! -f rhodecode/public/js/scripts.js ]; then
186 if [ ! -f rhodecode/public/js/scripts.js ]; then
187 echo "Missing scripts.js"
187 echo "Missing scripts.js"
188 exit 1
188 exit 1
189 fi
189 fi
190 if [ ! -f rhodecode/public/css/style.css ]; then
190 if [ ! -f rhodecode/public/css/style.css ]; then
191 echo "Missing style.css"
191 echo "Missing style.css"
192 exit 1
192 exit 1
193 fi
193 fi
194 '';
194 '';
195
195
196 });
196 });
197
197
198 rc_testdata = self.buildPythonPackage rec {
198 rc_testdata = self.buildPythonPackage rec {
199 name = "rc_testdata-0.7.0";
199 name = "rc_testdata-0.7.0";
200 src = pkgs.fetchhg {
200 src = pkgs.fetchhg {
201 url = "https://code.rhodecode.com/upstream/rc_testdata";
201 url = "https://code.rhodecode.com/upstream/rc_testdata";
202 rev = "v0.7.0";
202 rev = "v0.7.0";
203 sha256 = "0w3z0zn8lagr707v67lgys23sl6pbi4xg7pfvdbw58h3q384h6rx";
203 sha256 = "0w3z0zn8lagr707v67lgys23sl6pbi4xg7pfvdbw58h3q384h6rx";
204 };
204 };
205 };
205 };
206
206
207 };
207 };
208
208
209 # Apply all overrides and fix the final package set
209 # Apply all overrides and fix the final package set
210 myPythonPackagesUnfix =
210 myPythonPackagesUnfix =
211 (extends pythonExternalOverrides
211 (extends pythonExternalOverrides
212 (extends pythonLocalOverrides
212 (extends pythonLocalOverrides
213 (extends pythonOverrides
213 (extends pythonOverrides
214 pythonGeneratedPackages)));
214 pythonGeneratedPackages)));
215 myPythonPackages = (fix myPythonPackagesUnfix);
215 myPythonPackages = (fix myPythonPackagesUnfix);
216
216
217 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