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