##// END OF EJS Templates
nix: Use --set instead of --prefix for setting the PATH / PYTHONPATH...
Martin Bornhold -
r89:980afc58 stable
parent child Browse files
Show More
@@ -1,145 +1,146 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 { pkgs ? (import <nixpkgs> {})
8 8 , pythonPackages ? "python27Packages"
9 9 , pythonExternalOverrides ? self: super: {}
10 10 , doCheck ? true
11 11 }:
12 12
13 13 let pkgs_ = pkgs; in
14 14
15 15 let
16 16 pkgs = pkgs_.overridePackages (self: super: {
17 17 # Override subversion derivation to
18 18 # - activate python bindings
19 19 # - set version to 1.8
20 20 subversion = super.subversion18.override {
21 21 httpSupport = true;
22 22 pythonBindings = true;
23 23 python = self.python27Packages.python;
24 24 };
25 25 });
26 26
27 27 inherit (pkgs.lib) fix extends;
28 28
29 29 basePythonPackages = with builtins; if isAttrs pythonPackages
30 30 then pythonPackages
31 31 else getAttr pythonPackages pkgs;
32 32
33 33 elem = builtins.elem;
34 34 basename = path: with pkgs.lib; last (splitString "/" path);
35 35 startsWith = prefix: full: let
36 36 actualPrefix = builtins.substring 0 (builtins.stringLength prefix) full;
37 37 in actualPrefix == prefix;
38 38
39 39 src-filter = path: type: with pkgs.lib;
40 40 let
41 41 ext = last (splitString "." path);
42 42 in
43 43 !elem (basename path) [
44 44 ".git" ".hg" "__pycache__" ".eggs" "node_modules"
45 45 "build" "data" "tmp"] &&
46 46 !elem ext ["egg-info" "pyc"] &&
47 47 !startsWith "result" path;
48 48
49 49 rhodecode-vcsserver-src = builtins.filterSource src-filter ./.;
50 50
51 51 pythonGeneratedPackages = self: basePythonPackages.override (a: {
52 52 inherit self;
53 53 })
54 54 // (scopedImport {
55 55 self = self;
56 56 super = basePythonPackages;
57 57 inherit pkgs;
58 58 inherit (pkgs) fetchurl fetchgit;
59 59 } ./pkgs/python-packages.nix);
60 60
61 61 pythonOverrides = import ./pkgs/python-packages-overrides.nix {
62 62 inherit
63 63 basePythonPackages
64 64 pkgs;
65 65 };
66 66
67 67 version = builtins.readFile ./vcsserver/VERSION;
68 68
69 69 pythonLocalOverrides = self: super: {
70 70 rhodecode-vcsserver = super.rhodecode-vcsserver.override (attrs: {
71 71 inherit
72 72 doCheck
73 73 version;
74 74 name = "rhodecode-vcsserver-${version}";
75 75 releaseName = "RhodeCodeVCSServer-${version}";
76 76 src = rhodecode-vcsserver-src;
77 77
78 78 propagatedBuildInputs = attrs.propagatedBuildInputs ++ ([
79 79 pkgs.git
80 80 pkgs.subversion
81 81 ]);
82 82
83 83 # TODO: johbo: Make a nicer way to expose the parts. Maybe
84 84 # pkgs/default.nix?
85 85 passthru = {
86 86 pythonPackages = self;
87 87 };
88 88
89 89 # Somewhat snappier setup of the development environment
90 90 # TODO: move into shell.nix
91 91 # TODO: think of supporting a stable path again, so that multiple shells
92 92 # can share it.
93 93 shellHook = ''
94 94 # Set locale
95 95 export LC_ALL="en_US.UTF-8"
96 96
97 97 tmp_path=$(mktemp -d)
98 98 export PATH="$tmp_path/bin:$PATH"
99 99 export PYTHONPATH="$tmp_path/${self.python.sitePackages}:$PYTHONPATH"
100 100 mkdir -p $tmp_path/${self.python.sitePackages}
101 101 python setup.py develop --prefix $tmp_path --allow-hosts ""
102 102 '';
103 103
104 104 # Add VCSServer bin directory to path so that tests can find 'vcsserver'.
105 105 preCheck = ''
106 106 export PATH="$out/bin:$PATH"
107 107 '';
108 108
109 109 postInstall = ''
110 110 echo "Writing meta information for rccontrol to nix-support/rccontrol"
111 111 mkdir -p $out/nix-support/rccontrol
112 112 cp -v vcsserver/VERSION $out/nix-support/rccontrol/version
113 113 echo "DONE: Meta information for rccontrol written"
114 114
115 ln -s ${self.pyramid}/bin/* $out/bin #*/
115 ln -s ${self.pyramid}/bin/* $out/bin/
116 116 ln -s ${self.gunicorn}/bin/gunicorn $out/bin/
117 117
118 118 # Symlink version control utilities
119 119 #
120 120 # We ensure that always the correct version is available as a symlink.
121 121 # So that users calling them via the profile path will always use the
122 122 # correct version.
123 123 ln -s ${pkgs.git}/bin/git $out/bin
124 124 ln -s ${self.mercurial}/bin/hg $out/bin
125 125 ln -s ${pkgs.subversion}/bin/svn* $out/bin
126 126
127 for file in $out/bin/*; do #*/
127 for file in $out/bin/*; do
128 128 wrapProgram $file \
129 --prefix PYTHONPATH : $PYTHONPATH \
129 --set PATH $PATH \
130 --set PYTHONPATH $PYTHONPATH \
130 131 --set PYTHONHASHSEED random
131 132 done
132 133 '';
133 134
134 135 });
135 136 };
136 137
137 138 # Apply all overrides and fix the final package set
138 139 myPythonPackages =
139 140 (fix
140 141 (extends pythonExternalOverrides
141 142 (extends pythonLocalOverrides
142 143 (extends pythonOverrides
143 144 pythonGeneratedPackages))));
144 145
145 146 in myPythonPackages.rhodecode-vcsserver
General Comments 0
You need to be logged in to leave comments. Login now