Show More
@@ -1,215 +1,217 b'' | |||
|
1 | 1 | # Nix environment for the community edition |
|
2 | 2 | # |
|
3 | 3 | # This shall be as lean as possible, just producing the Enterprise |
|
4 | 4 | # derivation. For advanced tweaks to pimp up the development environment we use |
|
5 | 5 | # "shell.nix" so that it does not have to clutter this file. |
|
6 | 6 | |
|
7 | 7 | { pkgs ? (import <nixpkgs> {}) |
|
8 | 8 | , pythonPackages ? "python27Packages" |
|
9 | 9 | , pythonExternalOverrides ? self: super: {} |
|
10 | 10 | , doCheck ? true |
|
11 | 11 | }: |
|
12 | 12 | |
|
13 | 13 | let pkgs_ = pkgs; in |
|
14 | 14 | |
|
15 | 15 | let |
|
16 | 16 | pkgs = pkgs_.overridePackages (self: super: { |
|
17 | 17 | # Override subversion derivation to |
|
18 | 18 | # - activate python bindings |
|
19 | 19 | # - set version to 1.8 |
|
20 | 20 | subversion = super.subversion18.override { |
|
21 | 21 | httpSupport = true; |
|
22 | 22 | pythonBindings = true; |
|
23 | 23 | python = self.python27Packages.python; |
|
24 | 24 | }; |
|
25 | 25 | }); |
|
26 | 26 | |
|
27 | 27 | inherit (pkgs.lib) fix extends; |
|
28 | 28 | |
|
29 | 29 | basePythonPackages = with builtins; if isAttrs pythonPackages |
|
30 | 30 | then pythonPackages |
|
31 | 31 | else getAttr pythonPackages pkgs; |
|
32 | 32 | |
|
33 | 33 | elem = builtins.elem; |
|
34 | 34 | basename = path: with pkgs.lib; last (splitString "/" path); |
|
35 | 35 | startsWith = prefix: full: let |
|
36 | 36 | actualPrefix = builtins.substring 0 (builtins.stringLength prefix) full; |
|
37 | 37 | in actualPrefix == prefix; |
|
38 | 38 | |
|
39 | 39 | src-filter = path: type: with pkgs.lib; |
|
40 | 40 | let |
|
41 | 41 | ext = last (splitString "." path); |
|
42 | 42 | in |
|
43 | 43 | !elem (basename path) [ |
|
44 | 44 | ".git" ".hg" "__pycache__" ".eggs" "node_modules" |
|
45 | 45 | "build" "data" "tmp"] && |
|
46 | 46 | !elem ext ["egg-info" "pyc"] && |
|
47 | 47 | !startsWith "result" path; |
|
48 | 48 | |
|
49 | 49 | rhodecode-enterprise-ce-src = builtins.filterSource src-filter ./.; |
|
50 | 50 | |
|
51 | 51 | # Load the generated node packages |
|
52 | 52 | nodePackages = pkgs.callPackage "${pkgs.path}/pkgs/top-level/node-packages.nix" rec { |
|
53 | 53 | self = nodePackages; |
|
54 | 54 | generated = pkgs.callPackage ./pkgs/node-packages.nix { inherit self; }; |
|
55 | 55 | }; |
|
56 | 56 | |
|
57 | 57 | # TODO: Should be taken automatically out of the generates packages. |
|
58 | 58 | # apps.nix has one solution for this, although I'd prefer to have the deps |
|
59 | 59 | # from package.json mapped in here. |
|
60 | 60 | nodeDependencies = with nodePackages; [ |
|
61 | 61 | grunt |
|
62 | 62 | grunt-contrib-concat |
|
63 | 63 | grunt-contrib-jshint |
|
64 | 64 | grunt-contrib-less |
|
65 | 65 | grunt-contrib-watch |
|
66 | 66 | jshint |
|
67 | 67 | ]; |
|
68 | 68 | |
|
69 | 69 | pythonGeneratedPackages = self: basePythonPackages.override (a: { |
|
70 | 70 | inherit self; |
|
71 | 71 | }) |
|
72 | 72 | // (scopedImport { |
|
73 | 73 | self = self; |
|
74 | 74 | super = basePythonPackages; |
|
75 | 75 | inherit pkgs; |
|
76 | 76 | inherit (pkgs) fetchurl fetchgit; |
|
77 | 77 | } ./pkgs/python-packages.nix); |
|
78 | 78 | |
|
79 | 79 | pythonOverrides = import ./pkgs/python-packages-overrides.nix { |
|
80 | 80 | inherit |
|
81 | 81 | basePythonPackages |
|
82 | 82 | pkgs; |
|
83 | 83 | }; |
|
84 | 84 | |
|
85 | 85 | pythonLocalOverrides = self: super: { |
|
86 | 86 | rhodecode-enterprise-ce = |
|
87 | 87 | let |
|
88 | 88 | version = "${builtins.readFile ./rhodecode/VERSION}"; |
|
89 | 89 | linkNodeModules = '' |
|
90 | 90 | echo "Link node packages" |
|
91 | 91 | # TODO: check if this adds stuff as a dependency, closure size |
|
92 | 92 | rm -fr node_modules |
|
93 | 93 | mkdir -p node_modules |
|
94 | 94 | ${pkgs.lib.concatMapStrings (dep: '' |
|
95 | 95 | ln -sfv ${dep}/lib/node_modules/${dep.pkgName} node_modules/ |
|
96 | 96 | '') nodeDependencies} |
|
97 | 97 | echo "DONE: Link node packages" |
|
98 | 98 | ''; |
|
99 | 99 | in super.rhodecode-enterprise-ce.override (attrs: { |
|
100 | 100 | |
|
101 | 101 | inherit doCheck; |
|
102 | 102 | name = "rhodecode-enterprise-ce-${version}"; |
|
103 | 103 | version = version; |
|
104 | 104 | src = rhodecode-enterprise-ce-src; |
|
105 | 105 | |
|
106 | 106 | buildInputs = |
|
107 | 107 | attrs.buildInputs ++ |
|
108 | 108 | (with self; [ |
|
109 | 109 | pkgs.nodePackages.grunt-cli |
|
110 | 110 | pkgs.subversion |
|
111 | 111 | pytest-catchlog |
|
112 | 112 | rc_testdata |
|
113 | 113 | ]); |
|
114 | 114 | |
|
115 | 115 | propagatedBuildInputs = attrs.propagatedBuildInputs ++ (with self; [ |
|
116 | 116 | rhodecode-tools |
|
117 | 117 | ]); |
|
118 | 118 | |
|
119 | 119 | # TODO: johbo: Make a nicer way to expose the parts. Maybe |
|
120 | 120 | # pkgs/default.nix? |
|
121 | 121 | passthru = { |
|
122 | inherit myPythonPackagesUnfix; | |
|
122 | inherit | |
|
123 | pythonLocalOverrides | |
|
124 | myPythonPackagesUnfix; | |
|
123 | 125 | pythonPackages = self; |
|
124 | 126 | }; |
|
125 | 127 | |
|
126 | 128 | LC_ALL = "en_US.UTF-8"; |
|
127 | 129 | LOCALE_ARCHIVE = |
|
128 | 130 | if pkgs.stdenv ? glibc |
|
129 | 131 | then "${pkgs.glibcLocales}/lib/locale/locale-archive" |
|
130 | 132 | else ""; |
|
131 | 133 | |
|
132 | 134 | # Somewhat snappier setup of the development environment |
|
133 | 135 | # TODO: move into shell.nix |
|
134 | 136 | # TODO: think of supporting a stable path again, so that multiple shells |
|
135 | 137 | # can share it. |
|
136 | 138 | shellHook = '' |
|
137 | 139 | tmp_path=$(mktemp -d) |
|
138 | 140 | export PATH="$tmp_path/bin:$PATH" |
|
139 | 141 | export PYTHONPATH="$tmp_path/${self.python.sitePackages}:$PYTHONPATH" |
|
140 | 142 | mkdir -p $tmp_path/${self.python.sitePackages} |
|
141 | 143 | python setup.py develop --prefix $tmp_path --allow-hosts "" |
|
142 | 144 | '' + linkNodeModules; |
|
143 | 145 | |
|
144 | 146 | preCheck = '' |
|
145 | 147 | export PATH="$out/bin:$PATH" |
|
146 | 148 | ''; |
|
147 | 149 | |
|
148 | 150 | postCheck = '' |
|
149 | 151 | rm -rf $out/lib/${self.python.libPrefix}/site-packages/pytest_pylons |
|
150 | 152 | rm -rf $out/lib/${self.python.libPrefix}/site-packages/rhodecode/tests |
|
151 | 153 | ''; |
|
152 | 154 | |
|
153 | 155 | preBuild = linkNodeModules + '' |
|
154 | 156 | grunt |
|
155 | 157 | rm -fr node_modules |
|
156 | 158 | ''; |
|
157 | 159 | |
|
158 | 160 | postInstall = '' |
|
159 | 161 | # python based programs need to be wrapped |
|
160 | 162 | ln -s ${self.supervisor}/bin/supervisor* $out/bin/ |
|
161 | 163 | ln -s ${self.gunicorn}/bin/gunicorn $out/bin/ |
|
162 | 164 | ln -s ${self.PasteScript}/bin/paster $out/bin/ |
|
163 | 165 | |
|
164 | 166 | # rhodecode-tools |
|
165 | 167 | # TODO: johbo: re-think this. Do the tools import anything from enterprise? |
|
166 | 168 | ln -s ${self.rhodecode-tools}/bin/rhodecode-* $out/bin/ |
|
167 | 169 | |
|
168 | 170 | # note that condition should be restricted when adding further tools |
|
169 | 171 | for file in $out/bin/*; do #*/ |
|
170 | 172 | wrapProgram $file \ |
|
171 | 173 | --prefix PYTHONPATH : $PYTHONPATH \ |
|
172 | 174 | --set PYTHONHASHSEED random |
|
173 | 175 | done |
|
174 | 176 | |
|
175 | 177 | mkdir $out/etc |
|
176 | 178 | cp configs/production.ini $out/etc |
|
177 | 179 | |
|
178 | 180 | echo "Writing meta information for rccontrol to nix-support/rccontrol" |
|
179 | 181 | mkdir -p $out/nix-support/rccontrol |
|
180 | 182 | cp -v rhodecode/VERSION $out/nix-support/rccontrol/version |
|
181 | 183 | echo "DONE: Meta information for rccontrol written" |
|
182 | 184 | |
|
183 | 185 | # TODO: johbo: Make part of ac-tests |
|
184 | 186 | if [ ! -f rhodecode/public/js/scripts.js ]; then |
|
185 | 187 | echo "Missing scripts.js" |
|
186 | 188 | exit 1 |
|
187 | 189 | fi |
|
188 | 190 | if [ ! -f rhodecode/public/css/style.css ]; then |
|
189 | 191 | echo "Missing style.css" |
|
190 | 192 | exit 1 |
|
191 | 193 | fi |
|
192 | 194 | ''; |
|
193 | 195 | |
|
194 | 196 | }); |
|
195 | 197 | |
|
196 | 198 | rc_testdata = self.buildPythonPackage rec { |
|
197 | 199 | name = "rc_testdata-0.7.0"; |
|
198 | 200 | src = pkgs.fetchhg { |
|
199 | 201 | url = "https://code.rhodecode.com/upstream/rc_testdata"; |
|
200 | 202 | rev = "v0.7.0"; |
|
201 | 203 | sha256 = "0w3z0zn8lagr707v67lgys23sl6pbi4xg7pfvdbw58h3q384h6rx"; |
|
202 | 204 | }; |
|
203 | 205 | }; |
|
204 | 206 | |
|
205 | 207 | }; |
|
206 | 208 | |
|
207 | 209 | # Apply all overrides and fix the final package set |
|
208 | 210 | myPythonPackagesUnfix = |
|
209 | 211 | (extends pythonExternalOverrides |
|
210 | 212 | (extends pythonLocalOverrides |
|
211 | 213 | (extends pythonOverrides |
|
212 | 214 | pythonGeneratedPackages))); |
|
213 | 215 | myPythonPackages = (fix myPythonPackagesUnfix); |
|
214 | 216 | |
|
215 | 217 | in myPythonPackages.rhodecode-enterprise-ce |
General Comments 0
You need to be logged in to leave comments.
Login now