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