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