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