##// END OF EJS Templates
packaging: new wrapping logic on binary scripts:...
marcink -
r567:956bb6e4 default
parent child Browse files
Show More
@@ -1,178 +1,185 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 88 # set some default locale env variables
89 89 LC_ALL = "en_US.UTF-8";
90 90 LOCALE_ARCHIVE =
91 91 if pkgs.stdenv.isLinux
92 92 then "${pkgs.glibcLocales}/lib/locale/locale-archive"
93 93 else "";
94 94
95 95 # Add bin directory to path so that tests can find 'vcsserver'.
96 96 preCheck = ''
97 97 export PATH="$out/bin:$PATH"
98 98 '';
99 99
100 100 # custom check phase for testing
101 101 checkPhase = ''
102 102 runHook preCheck
103 103 PYTHONHASHSEED=random py.test -vv -p no:sugar -r xw --cov-config=.coveragerc --cov=vcsserver --cov-report=term-missing vcsserver
104 104 runHook postCheck
105 105 '';
106 106
107 107 postCheck = ''
108 108 echo "Cleanup of vcsserver/tests"
109 109 rm -rf $out/lib/${self.python.libPrefix}/site-packages/vcsserver/tests
110 110 '';
111 111
112 112 postInstall = ''
113 113 echo "Writing vcsserver meta information for rccontrol to nix-support/rccontrol"
114 114 mkdir -p $out/nix-support/rccontrol
115 115 cp -v vcsserver/VERSION $out/nix-support/rccontrol/version
116 116 echo "DONE: vcsserver meta information for rccontrol written"
117 117
118 118 mkdir -p $out/etc
119 119 cp configs/production.ini $out/etc
120 120 echo "DONE: saved vcsserver production.ini into $out/etc"
121 121
122 122 # python based programs need to be wrapped
123 123 mkdir -p $out/bin
124 ln -s ${self.python}/bin/python $out/bin
125 ln -s ${self.pyramid}/bin/* $out/bin/
124 ln -s ${self.python}/bin/python $out/bin/
126 125 ln -s ${self.gunicorn}/bin/gunicorn $out/bin/
126 ln -s ${self.pyramid}/bin/prequest $out/bin/
127 ln -s ${self.pyramid}/bin/pserve $out/bin/
127 128
128 129 # Symlink version control utilities
129 130 # We ensure that always the correct version is available as a symlink.
130 131 # So that users calling them via the profile path will always use the
131 # correct version.
132 # correct version. Wrapping is required so those can "import"
133 # vcsserver python hooks.
132 134
133 135 ln -s ${pkgs.git}/bin/git $out/bin
134 136 ln -s ${self.mercurial}/bin/hg $out/bin
135 137 ln -s ${pkgs.subversion}/bin/svn* $out/bin
138
136 139 echo "DONE: created symlinks into $out/bin"
140 DEPS="$out/bin/*"
137 141
138 for file in $out/bin/*;
142 # wrap only dependency scripts, they require to have full PYTHONPATH set
143 # to be able to import all packages
144 for file in $DEPS;
139 145 do
140 146 wrapProgram $file \
141 147 --prefix PATH : $PATH \
142 148 --prefix PYTHONPATH : $PYTHONPATH \
143 149 --set PYTHONHASHSEED random
144 150 done
151
145 152 echo "DONE: vcsserver binary wrapping"
146 153
147 154 '';
148 155
149 156 });
150 157 };
151 158
152 159 basePythonPackages = with builtins;
153 160 if isAttrs pythonPackages then
154 161 pythonPackages
155 162 else
156 163 getAttr pythonPackages pkgs;
157 164
158 165 pythonGeneratedPackages = import ./pkgs/python-packages.nix {
159 166 inherit pkgs;
160 167 inherit (pkgs) fetchurl fetchgit fetchhg;
161 168 };
162 169
163 170 pythonVCSServerOverrides = import ./pkgs/python-packages-overrides.nix {
164 171 inherit pkgs basePythonPackages;
165 172 };
166 173
167 174
168 175 # Apply all overrides and fix the final package set
169 176 myPythonPackagesUnfix = with pkgs.lib;
170 177 (extends pythonExternalOverrides
171 178 (extends pythonLocalOverrides
172 179 (extends pythonVCSServerOverrides
173 180 (extends pythonGeneratedPackages
174 181 basePythonPackagesUnfix))));
175 182
176 183 myPythonPackages = (pkgs.lib.fix myPythonPackagesUnfix);
177 184
178 185 in myPythonPackages.rhodecode-vcsserver
General Comments 0
You need to be logged in to leave comments. Login now