##// END OF EJS Templates
nix: use some more consistent formatting
marcink -
r570:36df69b0 default
parent child Browse files
Show More
@@ -1,183 +1,195 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 { pythonPackages ? "python27Packages"
8 { pythonPackages ? "python27Packages"
9 , pythonExternalOverrides ? self: super: {}
9 , pythonExternalOverrides ? self: super: {}
10 , doCheck ? false
10 , doCheck ? false
11 , ...
11 , ...
12 }:
12 }:
13
13
14 let pkgs_ = (import <nixpkgs> {}); in
14 let pkgs_ = (import <nixpkgs> {}); in
15
15
16 let
16 let
17
17
18 pkgs = args.pkgs or (import <nixpkgs> {
18 pkgs = args.pkgs or (import <nixpkgs> {
19 overlays = [
19 overlays = [
20 (import ./pkgs/overlays.nix)
20 (import ./pkgs/overlays.nix)
21 ];
21 ];
22 inherit (pkgs_)
22 inherit
23 (pkgs_)
23 system;
24 system;
24 });
25 });
25
26
26 # Works with the new python-packages, still can fallback to the old
27 # Works with the new python-packages, still can fallback to the old
27 # variant.
28 # variant.
28 basePythonPackagesUnfix = basePythonPackages.__unfix__ or (
29 basePythonPackagesUnfix = basePythonPackages.__unfix__ or (
29 self: basePythonPackages.override (a: { inherit self; }));
30 self: basePythonPackages.override (a: { inherit self; }));
30
31
31 # Evaluates to the last segment of a file system path.
32 # Evaluates to the last segment of a file system path.
32 basename = path: with pkgs.lib; last (splitString "/" path);
33 basename = path: with pkgs.lib; last (splitString "/" path);
33
34
34 # source code filter used as arugment to builtins.filterSource.
35 # source code filter used as arugment to builtins.filterSource.
35 src-filter = path: type: with pkgs.lib;
36 src-filter = path: type: with pkgs.lib;
36 let
37 let
37 ext = last (splitString "." path);
38 ext = last (splitString "." path);
38 in
39 in
39 !builtins.elem (basename path) [
40 !builtins.elem (basename path) [
40 ".git" ".hg" "__pycache__" ".eggs" ".idea" ".dev"
41 ".git" ".hg" "__pycache__" ".eggs" ".idea" ".dev"
41 "bower_components" "node_modules"
42 "bower_components" "node_modules"
42 "build" "data" "result" "tmp"] &&
43 "build" "data" "result" "tmp"] &&
43 !builtins.elem ext ["egg-info" "pyc"] &&
44 !builtins.elem ext ["egg-info" "pyc"] &&
44 # TODO: johbo: This check is wrong, since "path" contains an absolute path,
45 # TODO: johbo: This check is wrong, since "path" contains an absolute path,
45 # it would still be good to restore it since we want to ignore "result-*".
46 # it would still be good to restore it since we want to ignore "result-*".
46 !hasPrefix "result" path;
47 !hasPrefix "result" path;
47
48
48 sources =
49 sources =
49 let
50 let
50 inherit (pkgs.lib) all isString attrValues;
51 inherit
52 (pkgs.lib)
53 all
54 isString
55 attrValues;
51 sourcesConfig = pkgs.config.rc.sources or {};
56 sourcesConfig = pkgs.config.rc.sources or {};
52 in
57 in
53 # Ensure that sources are configured as strings. Using a path
58 # Ensure that sources are configured as strings. Using a path
54 # would result in a copy into the nix store.
59 # would result in a copy into the nix store.
55 assert all isString (attrValues sourcesConfig);
60 assert all isString (attrValues sourcesConfig);
56 sourcesConfig;
61 sourcesConfig;
57
62
58 version = builtins.readFile "${rhodecode-vcsserver-src}/vcsserver/VERSION";
63 version = builtins.readFile "${rhodecode-vcsserver-src}/vcsserver/VERSION";
59 rhodecode-vcsserver-src = builtins.filterSource src-filter ./.;
64 rhodecode-vcsserver-src = builtins.filterSource src-filter ./.;
60
65
61 pythonLocalOverrides = self: super: {
66 pythonLocalOverrides = self: super: {
62 rhodecode-vcsserver =
67 rhodecode-vcsserver =
63 let
68 let
64 releaseName = "RhodeCodeVCSServer-${version}";
69 releaseName = "RhodeCodeVCSServer-${version}";
65 in super.rhodecode-vcsserver.override (attrs: {
70 in super.rhodecode-vcsserver.override (attrs: {
66 inherit
71 inherit
67 doCheck
72 doCheck
68 version;
73 version;
69
74
70 name = "rhodecode-vcsserver-${version}";
75 name = "rhodecode-vcsserver-${version}";
71 releaseName = releaseName;
76 releaseName = releaseName;
72 src = rhodecode-vcsserver-src;
77 src = rhodecode-vcsserver-src;
73 dontStrip = true; # prevent strip, we don't need it.
78 dontStrip = true; # prevent strip, we don't need it.
74
79
75 # expose following attributed outside
80 # expose following attributed outside
76 passthru = {
81 passthru = {
77 pythonPackages = self;
82 pythonPackages = self;
78 };
83 };
79
84
80 propagatedBuildInputs =
85 propagatedBuildInputs =
81 attrs.propagatedBuildInputs or [] ++ [
86 attrs.propagatedBuildInputs or [] ++ [
82 pkgs.git
87 pkgs.git
83 pkgs.subversion
88 pkgs.subversion
84 ];
89 ];
85
90
86 # set some default locale env variables
91 # set some default locale env variables
87 LC_ALL = "en_US.UTF-8";
92 LC_ALL = "en_US.UTF-8";
88 LOCALE_ARCHIVE =
93 LOCALE_ARCHIVE =
89 if pkgs.stdenv.isLinux
94 if pkgs.stdenv.isLinux
90 then "${pkgs.glibcLocales}/lib/locale/locale-archive"
95 then "${pkgs.glibcLocales}/lib/locale/locale-archive"
91 else "";
96 else "";
92
97
93 # Add bin directory to path so that tests can find 'vcsserver'.
98 # Add bin directory to path so that tests can find 'vcsserver'.
94 preCheck = ''
99 preCheck = ''
95 export PATH="$out/bin:$PATH"
100 export PATH="$out/bin:$PATH"
96 '';
101 '';
97
102
98 # custom check phase for testing
103 # custom check phase for testing
99 checkPhase = ''
104 checkPhase = ''
100 runHook preCheck
105 runHook preCheck
101 PYTHONHASHSEED=random py.test -vv -p no:sugar -r xw --cov-config=.coveragerc --cov=vcsserver --cov-report=term-missing vcsserver
106 PYTHONHASHSEED=random py.test -vv -p no:sugar -r xw --cov-config=.coveragerc --cov=vcsserver --cov-report=term-missing vcsserver
102 runHook postCheck
107 runHook postCheck
103 '';
108 '';
104
109
105 postCheck = ''
110 postCheck = ''
106 echo "Cleanup of vcsserver/tests"
111 echo "Cleanup of vcsserver/tests"
107 rm -rf $out/lib/${self.python.libPrefix}/site-packages/vcsserver/tests
112 rm -rf $out/lib/${self.python.libPrefix}/site-packages/vcsserver/tests
108 '';
113 '';
109
114
110 postInstall = ''
115 postInstall = ''
111 echo "Writing vcsserver meta information for rccontrol to nix-support/rccontrol"
116 echo "Writing vcsserver meta information for rccontrol to nix-support/rccontrol"
112 mkdir -p $out/nix-support/rccontrol
117 mkdir -p $out/nix-support/rccontrol
113 cp -v vcsserver/VERSION $out/nix-support/rccontrol/version
118 cp -v vcsserver/VERSION $out/nix-support/rccontrol/version
114 echo "DONE: vcsserver meta information for rccontrol written"
119 echo "DONE: vcsserver meta information for rccontrol written"
115
120
116 mkdir -p $out/etc
121 mkdir -p $out/etc
117 cp configs/production.ini $out/etc
122 cp configs/production.ini $out/etc
118 echo "DONE: saved vcsserver production.ini into $out/etc"
123 echo "DONE: saved vcsserver production.ini into $out/etc"
119
124
120 # python based programs need to be wrapped
125 # python based programs need to be wrapped
121 mkdir -p $out/bin
126 mkdir -p $out/bin
122 ln -s ${self.python}/bin/python $out/bin/
127 ln -s ${self.python}/bin/python $out/bin/
123 ln -s ${self.gunicorn}/bin/gunicorn $out/bin/
128 ln -s ${self.gunicorn}/bin/gunicorn $out/bin/
124 ln -s ${self.pyramid}/bin/prequest $out/bin/
129 ln -s ${self.pyramid}/bin/prequest $out/bin/
125 ln -s ${self.pyramid}/bin/pserve $out/bin/
130 ln -s ${self.pyramid}/bin/pserve $out/bin/
126
131
127 # Symlink version control utilities
132 # Symlink version control utilities
128 # We ensure that always the correct version is available as a symlink.
133 # We ensure that always the correct version is available as a symlink.
129 # So that users calling them via the profile path will always use the
134 # So that users calling them via the profile path will always use the
130 # correct version. Wrapping is required so those can "import"
135 # correct version. Wrapping is required so those can "import"
131 # vcsserver python hooks.
136 # vcsserver python hooks.
132
137
133 ln -s ${pkgs.git}/bin/git $out/bin
138 ln -s ${pkgs.git}/bin/git $out/bin
134 ln -s ${self.mercurial}/bin/hg $out/bin
139 ln -s ${self.mercurial}/bin/hg $out/bin
135 ln -s ${pkgs.subversion}/bin/svn* $out/bin
140 ln -s ${pkgs.subversion}/bin/svn* $out/bin
136
141
137 echo "DONE: created symlinks into $out/bin"
142 echo "DONE: created symlinks into $out/bin"
138 DEPS="$out/bin/*"
143 DEPS="$out/bin/*"
139
144
140 # wrap only dependency scripts, they require to have full PYTHONPATH set
145 # wrap only dependency scripts, they require to have full PYTHONPATH set
141 # to be able to import all packages
146 # to be able to import all packages
142 for file in $DEPS;
147 for file in $DEPS;
143 do
148 do
144 wrapProgram $file \
149 wrapProgram $file \
145 --prefix PATH : $PATH \
150 --prefix PATH : $PATH \
146 --prefix PYTHONPATH : $PYTHONPATH \
151 --prefix PYTHONPATH : $PYTHONPATH \
147 --set PYTHONHASHSEED random
152 --set PYTHONHASHSEED random
148 done
153 done
149
154
150 echo "DONE: vcsserver binary wrapping"
155 echo "DONE: vcsserver binary wrapping"
151
156
152 '';
157 '';
153
158
154 });
159 });
155 };
160 };
156
161
157 basePythonPackages = with builtins;
162 basePythonPackages = with builtins;
158 if isAttrs pythonPackages then
163 if isAttrs pythonPackages then
159 pythonPackages
164 pythonPackages
160 else
165 else
161 getAttr pythonPackages pkgs;
166 getAttr pythonPackages pkgs;
162
167
163 pythonGeneratedPackages = import ./pkgs/python-packages.nix {
168 pythonGeneratedPackages = import ./pkgs/python-packages.nix {
164 inherit pkgs;
169 inherit
165 inherit (pkgs) fetchurl fetchgit fetchhg;
170 pkgs;
171 inherit
172 (pkgs)
173 fetchurl
174 fetchgit
175 fetchhg;
166 };
176 };
167
177
168 pythonVCSServerOverrides = import ./pkgs/python-packages-overrides.nix {
178 pythonVCSServerOverrides = import ./pkgs/python-packages-overrides.nix {
169 inherit pkgs basePythonPackages;
179 inherit
180 pkgs
181 basePythonPackages;
170 };
182 };
171
183
172
184
173 # Apply all overrides and fix the final package set
185 # Apply all overrides and fix the final package set
174 myPythonPackagesUnfix = with pkgs.lib;
186 myPythonPackagesUnfix = with pkgs.lib;
175 (extends pythonExternalOverrides
187 (extends pythonExternalOverrides
176 (extends pythonLocalOverrides
188 (extends pythonLocalOverrides
177 (extends pythonVCSServerOverrides
189 (extends pythonVCSServerOverrides
178 (extends pythonGeneratedPackages
190 (extends pythonGeneratedPackages
179 basePythonPackagesUnfix))));
191 basePythonPackagesUnfix))));
180
192
181 myPythonPackages = (pkgs.lib.fix myPythonPackagesUnfix);
193 myPythonPackages = (pkgs.lib.fix myPythonPackagesUnfix);
182
194
183 in myPythonPackages.rhodecode-vcsserver
195 in myPythonPackages.rhodecode-vcsserver
General Comments 0
You need to be logged in to leave comments. Login now