Show More
@@ -1,208 +1,220 b'' | |||
|
1 | 1 | # Nix environment for the community edition |
|
2 | 2 | # |
|
3 | 3 | # This shall be as lean as possible, just producing the rhodecode-vcsserver |
|
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 | args@ |
|
8 | 8 | { system ? builtins.currentSystem |
|
9 | 9 | , pythonPackages ? "python27Packages" |
|
10 | 10 | , pythonExternalOverrides ? self: super: {} |
|
11 | 11 | , doCheck ? false |
|
12 | 12 | , ... |
|
13 | 13 | }: |
|
14 | 14 | |
|
15 | 15 | let |
|
16 | 16 | pkgs_ = args.pkgs or (import <nixpkgs> { inherit system; }); |
|
17 | 17 | in |
|
18 | 18 | |
|
19 | 19 | let |
|
20 | 20 | pkgs = import <nixpkgs> { |
|
21 | 21 | overlays = [ |
|
22 | 22 | (import ./pkgs/overlays.nix) |
|
23 | 23 | ]; |
|
24 | 24 | inherit |
|
25 | 25 | (pkgs_) |
|
26 | 26 | system; |
|
27 | 27 | }; |
|
28 | 28 | |
|
29 | 29 | # Works with the new python-packages, still can fallback to the old |
|
30 | 30 | # variant. |
|
31 | 31 | basePythonPackagesUnfix = basePythonPackages.__unfix__ or ( |
|
32 | 32 | self: basePythonPackages.override (a: { inherit self; })); |
|
33 | 33 | |
|
34 | 34 | # Evaluates to the last segment of a file system path. |
|
35 | 35 | basename = path: with pkgs.lib; last (splitString "/" path); |
|
36 | 36 | startsWith = prefix: full: let |
|
37 | 37 | actualPrefix = builtins.substring 0 (builtins.stringLength prefix) full; |
|
38 | 38 | in actualPrefix == prefix; |
|
39 | 39 | |
|
40 | 40 | # source code filter used as arugment to builtins.filterSource. |
|
41 | 41 | src-filter = path: type: with pkgs.lib; |
|
42 | 42 | let |
|
43 | 43 | ext = last (splitString "." path); |
|
44 | 44 | parts = last (splitString "/" path); |
|
45 | 45 | in |
|
46 | 46 | !builtins.elem (basename path) [ |
|
47 | 47 | ".git" ".hg" "__pycache__" ".eggs" ".idea" ".dev" |
|
48 | 48 | "node_modules" "node_binaries" |
|
49 | 49 | "build" "data" "result" "tmp"] && |
|
50 | 50 | !builtins.elem ext ["egg-info" "pyc"] && |
|
51 | 51 | !startsWith "result" (basename path); |
|
52 | 52 | |
|
53 | 53 | sources = |
|
54 | 54 | let |
|
55 | 55 | inherit |
|
56 | 56 | (pkgs.lib) |
|
57 | 57 | all |
|
58 | 58 | isString |
|
59 | 59 | attrValues; |
|
60 | 60 | |
|
61 | 61 | sourcesConfig = pkgs.config.rc.sources or {}; |
|
62 | 62 | in |
|
63 | 63 | # Ensure that sources are configured as strings. Using a path |
|
64 | 64 | # would result in a copy into the nix store. |
|
65 | 65 | assert all isString (attrValues sourcesConfig); |
|
66 | 66 | sourcesConfig; |
|
67 | 67 | |
|
68 | rhodecode-vcsserver-src = builtins.filterSource src-filter ./.; | |
|
68 | 69 | version = builtins.readFile "${rhodecode-vcsserver-src}/vcsserver/VERSION"; |
|
69 | rhodecode-vcsserver-src = builtins.filterSource src-filter ./.; | |
|
70 | 70 | |
|
71 | 71 | pythonLocalOverrides = self: super: { |
|
72 | 72 | rhodecode-vcsserver = |
|
73 | 73 | let |
|
74 | 74 | releaseName = "RhodeCodeVCSServer-${version}"; |
|
75 | pythonWithEnv = | |
|
76 | self.python.buildEnv.override { | |
|
77 | extraLibs = [ ] ++ self.rhodecode-vcsserver.propagatedBuildInputs; | |
|
78 | ignoreCollisions = true; | |
|
79 | #--set PYTHONHASHSEED random TODO | |
|
80 | }; | |
|
75 | 81 | in super.rhodecode-vcsserver.override (attrs: { |
|
76 | 82 | inherit |
|
77 | 83 | doCheck |
|
78 | 84 | version; |
|
79 | 85 | |
|
80 | 86 | name = "rhodecode-vcsserver-${version}"; |
|
81 | 87 | releaseName = releaseName; |
|
82 | 88 | src = rhodecode-vcsserver-src; |
|
83 | 89 | dontStrip = true; # prevent strip, we don't need it. |
|
84 | 90 | |
|
85 | 91 | # expose following attributed outside |
|
86 | 92 | passthru = { |
|
87 | 93 | pythonPackages = self; |
|
88 | 94 | vcs_pkgs = pkgs; |
|
89 | 95 | }; |
|
90 | 96 | |
|
91 | 97 | buildInputs = |
|
92 | 98 | attrs.buildInputs or [] ++ [ |
|
93 | 99 | |
|
94 | 100 | ]; |
|
95 | 101 | |
|
96 | 102 | #NOTE: option to inject additional propagatedBuildInputs |
|
97 | 103 | propagatedBuildInputs = |
|
98 | 104 | attrs.propagatedBuildInputs or [] ++ [ |
|
99 | 105 | pkgs.git |
|
100 | 106 | pkgs.subversion |
|
101 | 107 | ]; |
|
102 | 108 | |
|
103 | 109 | preBuild = '' |
|
104 | 110 | export NIX_PATH=nixpkgs=${pkgs.path} |
|
105 | 111 | export SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt |
|
106 | 112 | ''; |
|
107 | 113 | |
|
108 | 114 | # Add bin directory to path so that tests can find 'vcsserver'. |
|
109 | 115 | preCheck = '' |
|
116 | echo "Expanding PATH with $out/bin directory" | |
|
110 | 117 | export PATH="$out/bin:$PATH" |
|
111 | 118 | ''; |
|
112 | 119 | |
|
113 | 120 | # custom check phase for testing |
|
114 | 121 | checkPhase = '' |
|
115 | 122 | runHook preCheck |
|
116 | 123 | PYTHONHASHSEED=random py.test -vv -p no:sugar -r xw --cov-config=.coveragerc --cov=vcsserver --cov-report=term-missing vcsserver |
|
117 | 124 | runHook postCheck |
|
118 | 125 | ''; |
|
119 | 126 | |
|
120 | 127 | postCheck = '' |
|
121 | 128 | echo "Cleanup of vcsserver/tests" |
|
122 | 129 | rm -rf $out/lib/${self.python.libPrefix}/site-packages/vcsserver/tests |
|
123 | 130 | ''; |
|
124 | 131 | |
|
125 | 132 | postInstall = '' |
|
126 | 133 | echo "Writing vcsserver meta information for rccontrol to nix-support/rccontrol" |
|
127 | 134 | mkdir -p $out/nix-support/rccontrol |
|
128 | 135 | cp -v vcsserver/VERSION $out/nix-support/rccontrol/version |
|
129 | 136 | echo "DONE: vcsserver meta information for rccontrol written" |
|
130 | 137 | |
|
131 | 138 | mkdir -p $out/etc |
|
132 | 139 | cp configs/production.ini $out/etc |
|
133 | 140 | echo "DONE: saved vcsserver production.ini into $out/etc" |
|
134 | 141 | |
|
135 | 142 | echo "saving env in $out/etc/env_vars.txt" |
|
136 | 143 | touch $out/etc/env_vars.txt |
|
137 | 144 | echo "# RhodeCode build env vars" >> $out/etc/env_vars.txt |
|
138 | 145 | echo "LOCALE_ARCHIVE=\"${pkgs.glibcLocales}/lib/locale/locale-archive\"" >> $out/etc/env_vars.txt |
|
139 | 146 | echo "LC_ALL=\"en_US.UTF-8\"" >> $out/etc/env_vars.txt |
|
140 | 147 | |
|
141 | 148 | # python based programs need to be wrapped |
|
142 | 149 | mkdir -p $out/bin |
|
143 | 150 | |
|
144 | 151 | # expose python |
|
145 |
ln -s ${ |
|
|
152 | ln -s ${pythonWithEnv}/bin/python $out/bin/ | |
|
146 | 153 | |
|
147 | 154 | # required binaries from dependencies |
|
148 |
ln -s ${ |
|
|
149 |
ln -s ${ |
|
|
150 |
ln -s ${ |
|
|
155 | ln -s ${pythonWithEnv}/bin/gunicorn $out/bin/ | |
|
156 | ln -s ${pythonWithEnv}/bin/prequest $out/bin/ | |
|
157 | ln -s ${pythonWithEnv}/bin/pserve $out/bin/ | |
|
151 | 158 | |
|
152 | 159 | # Symlink version control utilities |
|
153 | 160 | # We ensure that always the correct version is available as a symlink. |
|
154 | 161 | # So that users calling them via the profile path will always use the |
|
155 | 162 | # correct version. Wrapping is required so those can "import" |
|
156 | 163 | # vcsserver python hooks. |
|
157 | ||
|
158 | 164 | ln -s ${pkgs.git}/bin/git $out/bin |
|
159 | 165 | ln -s ${self.mercurial}/bin/hg $out/bin |
|
160 | 166 | ln -s ${pkgs.subversion}/bin/svn* $out/bin |
|
161 | 167 | |
|
162 | echo "DONE: created symlinks into $out/bin" | |
|
163 |
DEPS="$out/bin/ |
|
|
168 | echo "[DONE ]: created symlinks into $out/bin" | |
|
169 | DEPS="$out/bin/hg \ | |
|
170 | $out/bin/git \ | |
|
171 | $out/bin/svn \ | |
|
172 | $out/bin/svnserve \ | |
|
173 | $out/bin/svnadmin | |
|
174 | " | |
|
164 | 175 | |
|
165 | 176 | # wrap only dependency scripts, they require to have full PYTHONPATH set |
|
166 | 177 | # to be able to import all packages |
|
167 | 178 | for file in $DEPS; |
|
168 | 179 | do |
|
169 | 180 | wrapProgram $file \ |
|
170 | 181 | --prefix PATH : $PATH \ |
|
171 |
--prefix PYTHONPATH : $PYTHONPATH |
|
|
172 | --set PYTHONHASHSEED random | |
|
182 | --prefix PYTHONPATH : $PYTHONPATH | |
|
173 | 183 | done |
|
174 | 184 | |
|
175 | echo "DONE: vcsserver binary wrapping" | |
|
185 | echo "[DONE ]: vcsserver binary wrapping" | |
|
176 | 186 | |
|
187 | # expose sources of vcsserver | |
|
188 | ln -s $out $out/etc/rhodecode_vcsserver_source | |
|
177 | 189 | ''; |
|
178 | 190 | |
|
179 | 191 | }); |
|
180 | 192 | }; |
|
181 | 193 | |
|
182 | 194 | |
|
183 | 195 | basePythonPackages = with builtins; |
|
184 | 196 | if isAttrs pythonPackages then |
|
185 | 197 | pythonPackages |
|
186 | 198 | else |
|
187 | 199 | getAttr pythonPackages pkgs; |
|
188 | 200 | |
|
189 | 201 | pythonGeneratedPackages = import ./pkgs/python-packages.nix { |
|
190 | 202 | inherit pkgs; |
|
191 | 203 | inherit (pkgs) fetchurl fetchgit fetchhg; |
|
192 | 204 | }; |
|
193 | 205 | |
|
194 | 206 | pythonVCSServerOverrides = import ./pkgs/python-packages-overrides.nix { |
|
195 | 207 | inherit pkgs basePythonPackages; |
|
196 | 208 | }; |
|
197 | 209 | |
|
198 | 210 | # Apply all overrides and fix the final package set |
|
199 | 211 | myPythonPackagesUnfix = with pkgs.lib; |
|
200 | 212 | (extends pythonExternalOverrides |
|
201 | 213 | (extends pythonLocalOverrides |
|
202 | 214 | (extends pythonVCSServerOverrides |
|
203 | 215 | (extends pythonGeneratedPackages |
|
204 | 216 | basePythonPackagesUnfix)))); |
|
205 | 217 | |
|
206 | 218 | myPythonPackages = (pkgs.lib.fix myPythonPackagesUnfix); |
|
207 | 219 | |
|
208 | 220 | in myPythonPackages.rhodecode-vcsserver |
@@ -1,75 +1,71 b'' | |||
|
1 | 1 | self: super: { |
|
2 | 2 | |
|
3 | pythonWithSetuptools = self.python.withPackages(ps: with ps; [ | |
|
4 | setuptools | |
|
5 | ]); | |
|
6 | ||
|
7 | 3 | # change GIT version |
|
8 | 4 | # latest supported are in: https://github.com/NixOS/nixpkgs/tree/master/pkgs/applications/version-management/git-and-tools/git |
|
9 | 5 | git = super.lib.overrideDerivation super.git (oldAttrs: { |
|
10 | 6 | name = "git-2.25.3"; |
|
11 | 7 | src = self.fetchurl { |
|
12 | 8 | url = "https://www.kernel.org/pub/software/scm/git/git-2.25.3.tar.xz"; |
|
13 | 9 | sha256 = "0yvr97cl0dvj3fwblq1mb0cp97v8hrn9l98p8b1jx8815mbsnz9h"; |
|
14 | 10 | }; |
|
15 | 11 | |
|
16 | 12 | # patches come from: https://github.com/NixOS/nixpkgs/tree/master/pkgs/applications/version-management/git-and-tools/git |
|
17 | 13 | patches = [ |
|
18 | 14 | ./patches/git/docbook2texi.patch |
|
19 | 15 | ./patches/git/git-sh-i18n.patch |
|
20 | 16 | ./patches/git/ssh-path.patch |
|
21 | 17 | ./patches/git/git-send-email-honor-PATH.patch |
|
22 | 18 | ./patches/git/installCheck-path.patch |
|
23 | 19 | ]; |
|
24 | 20 | |
|
25 | 21 | }); |
|
26 | 22 | |
|
27 | 23 | libgit2rc = super.lib.overrideDerivation super.libgit2 (oldAttrs: { |
|
28 | 24 | name = "libgit2-0.28.2"; |
|
29 | 25 | version = "0.28.2"; |
|
30 | 26 | |
|
31 | 27 | src = self.fetchFromGitHub { |
|
32 | 28 | owner = "libgit2"; |
|
33 | 29 | repo = "libgit2"; |
|
34 | 30 | rev = "v0.28.2"; |
|
35 | 31 | sha256 = "0cm8fvs05rj0baigs2133q5a0sm3pa234y8h6hmwhl2bz9xq3k4b"; |
|
36 | 32 | }; |
|
37 | 33 | |
|
38 | 34 | cmakeFlags = [ "-DTHREADSAFE=ON" "-DUSE_HTTPS=no"]; |
|
39 | 35 | |
|
40 | 36 | buildInputs = [ |
|
41 | 37 | super.zlib |
|
42 | 38 | super.libssh2 |
|
43 | 39 | super.openssl |
|
44 | 40 | super.curl |
|
45 | 41 | ]; |
|
46 | 42 | |
|
47 | 43 | |
|
48 | 44 | }); |
|
49 | 45 | |
|
50 | 46 | # Override subversion derivation to |
|
51 | 47 | # - activate python bindings |
|
52 | 48 | subversion = |
|
53 | 49 | let |
|
54 | 50 | subversionWithPython = super.subversion.override { |
|
55 | 51 | httpSupport = true; |
|
56 | 52 | pythonBindings = true; |
|
57 | 53 | python = self.python27Packages.python; |
|
58 | 54 | }; |
|
59 | 55 | in |
|
60 | 56 | super.lib.overrideDerivation subversionWithPython (oldAttrs: { |
|
61 | 57 | name = "subversion-1.13.0"; |
|
62 | 58 | src = self.fetchurl { |
|
63 | 59 | url = "https://archive.apache.org/dist/subversion/subversion-1.13.0.tar.gz"; |
|
64 | 60 | sha256 = "0cb9p7f5hg0l4k32hz8vmvy2r45igchq5sh4m366za5q0c649bfs"; |
|
65 | 61 | }; |
|
66 | 62 | |
|
67 | 63 | ## use internal lz4/utf8proc because it is stable and shipped with SVN |
|
68 | 64 | configureFlags = oldAttrs.configureFlags ++ [ |
|
69 | 65 | " --with-lz4=internal" |
|
70 | 66 | " --with-utf8proc=internal" |
|
71 | 67 | ]; |
|
72 | 68 | |
|
73 | 69 | }); |
|
74 | 70 | |
|
75 | 71 | } |
General Comments 0
You need to be logged in to leave comments.
Login now