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