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