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