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