##// END OF EJS Templates
nix: added custom checkPhase to remove sugar output during package building.
marcink -
r135:49a07a00 default
parent child
Show More
@@ -1,152 +1,153
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 # bump GIT version
17 # bump GIT version
18 git = pkgs.lib.overrideDerivation pkgs_.git (oldAttrs: {
18 git = pkgs.lib.overrideDerivation pkgs_.git (oldAttrs: {
19 name = "git-2.9.3";
19 name = "git-2.9.3";
20 src = pkgs.fetchurl {
20 src = pkgs.fetchurl {
21 url = "https://www.kernel.org/pub/software/scm/git/git-2.9.3.tar.xz";
21 url = "https://www.kernel.org/pub/software/scm/git/git-2.9.3.tar.xz";
22 sha256 = "0qzs681a64k3shh5p0rg41l1z16fbk5sj0xga45k34hp1hsp654z";
22 sha256 = "0qzs681a64k3shh5p0rg41l1z16fbk5sj0xga45k34hp1hsp654z";
23 };
23 };
24
24
25 });
25 });
26
26
27 # Override subversion derivation to
27 # Override subversion derivation to
28 # - activate python bindings
28 # - activate python bindings
29 subversion = let
29 subversion = let
30 subversionWithPython = super.subversion.override {
30 subversionWithPython = super.subversion.override {
31 httpSupport = true;
31 httpSupport = true;
32 pythonBindings = true;
32 pythonBindings = true;
33 python = self.python27Packages.python;
33 python = self.python27Packages.python;
34 };
34 };
35
35
36 in
36 in
37
37
38 pkgs.lib.overrideDerivation subversionWithPython (oldAttrs: {
38 pkgs.lib.overrideDerivation subversionWithPython (oldAttrs: {
39 patches = (oldAttrs.patches or []) ++
39 patches = (oldAttrs.patches or []) ++
40 pkgs.lib.optionals pkgs.stdenv.isDarwin [
40 pkgs.lib.optionals pkgs.stdenv.isDarwin [
41 # johbo: "import svn.client" fails on darwin currently.
41 # johbo: "import svn.client" fails on darwin currently.
42 ./pkgs/subversion-1.9.4-darwin.patch
42 ./pkgs/subversion-1.9.4-darwin.patch
43 ];
43 ];
44 });
44 });
45
45
46 });
46 });
47
47
48 inherit (pkgs.lib) fix extends;
48 inherit (pkgs.lib) fix extends;
49
50 basePythonPackages = with builtins; if isAttrs pythonPackages
49 basePythonPackages = with builtins; if isAttrs pythonPackages
51 then pythonPackages
50 then pythonPackages
52 else getAttr pythonPackages pkgs;
51 else getAttr pythonPackages pkgs;
53
52
54 elem = builtins.elem;
53 elem = builtins.elem;
55 basename = path: with pkgs.lib; last (splitString "/" path);
54 basename = path: with pkgs.lib; last (splitString "/" path);
56 startsWith = prefix: full: let
55 startsWith = prefix: full: let
57 actualPrefix = builtins.substring 0 (builtins.stringLength prefix) full;
56 actualPrefix = builtins.substring 0 (builtins.stringLength prefix) full;
58 in actualPrefix == prefix;
57 in actualPrefix == prefix;
59
58
60 src-filter = path: type: with pkgs.lib;
59 src-filter = path: type: with pkgs.lib;
61 let
60 let
62 ext = last (splitString "." path);
61 ext = last (splitString "." path);
63 in
62 in
64 !elem (basename path) [
63 !elem (basename path) [".hg" ".git" "__pycache__" ".eggs"
65 ".git" ".hg" "__pycache__" ".eggs" "node_modules"
64 "node_modules" "build" "data" "tmp"] &&
66 "build" "data" "tmp"] &&
67 !elem ext ["egg-info" "pyc"] &&
65 !elem ext ["egg-info" "pyc"] &&
68 !startsWith "result" path;
66 !startsWith "result" path;
69
67
70 rhodecode-vcsserver-src = builtins.filterSource src-filter ./.;
68 rhodecode-vcsserver-src = builtins.filterSource src-filter ./.;
71
69
72 pythonGeneratedPackages = self: basePythonPackages.override (a: {
70 pythonGeneratedPackages = self: basePythonPackages.override (a: {
73 inherit self;
71 inherit self;
74 })
72 }) // (scopedImport {
75 // (scopedImport {
76 self = self;
73 self = self;
77 super = basePythonPackages;
74 super = basePythonPackages;
78 inherit pkgs;
75 inherit pkgs;
79 inherit (pkgs) fetchurl fetchgit;
76 inherit (pkgs) fetchurl fetchgit;
80 } ./pkgs/python-packages.nix);
77 } ./pkgs/python-packages.nix);
81
78
82 pythonOverrides = import ./pkgs/python-packages-overrides.nix {
79 pythonOverrides = import ./pkgs/python-packages-overrides.nix {
83 inherit
80 inherit basePythonPackages pkgs;
84 basePythonPackages
85 pkgs;
86 };
81 };
87
82
88 version = builtins.readFile ./vcsserver/VERSION;
83 version = builtins.readFile ./vcsserver/VERSION;
89
84
90 pythonLocalOverrides = self: super: {
85 pythonLocalOverrides = self: super: {
91 rhodecode-vcsserver = super.rhodecode-vcsserver.override (attrs: {
86 rhodecode-vcsserver = super.rhodecode-vcsserver.override (attrs: {
92 inherit
87 inherit doCheck version;
93 doCheck
88
94 version;
95 name = "rhodecode-vcsserver-${version}";
89 name = "rhodecode-vcsserver-${version}";
96 releaseName = "RhodeCodeVCSServer-${version}";
90 releaseName = "RhodeCodeVCSServer-${version}";
97 src = rhodecode-vcsserver-src;
91 src = rhodecode-vcsserver-src;
98
92
99 propagatedBuildInputs = attrs.propagatedBuildInputs ++ ([
93 propagatedBuildInputs = attrs.propagatedBuildInputs ++ ([
100 pkgs.git
94 pkgs.git
101 pkgs.subversion
95 pkgs.subversion
102 ]);
96 ]);
103
97
104 # TODO: johbo: Make a nicer way to expose the parts. Maybe
98 # TODO: johbo: Make a nicer way to expose the parts. Maybe
105 # pkgs/default.nix?
99 # pkgs/default.nix?
106 passthru = {
100 passthru = {
107 pythonPackages = self;
101 pythonPackages = self;
108 };
102 };
109
103
110 # 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'.
111 preCheck = ''
105 preCheck = ''
112 export PATH="$out/bin:$PATH"
106 export PATH="$out/bin:$PATH"
113 '';
107 '';
114
108
109 # put custom attrs here
110 checkPhase = ''
111 runHook preCheck
112 PYTHONHASHSEED=random py.test -p no:sugar -vv --cov-config=.coveragerc --cov=vcsserver --cov-report=term-missing vcsserver
113 runHook postCheck
114 '';
115
115 postInstall = ''
116 postInstall = ''
116 echo "Writing meta information for rccontrol to nix-support/rccontrol"
117 echo "Writing meta information for rccontrol to nix-support/rccontrol"
117 mkdir -p $out/nix-support/rccontrol
118 mkdir -p $out/nix-support/rccontrol
118 cp -v vcsserver/VERSION $out/nix-support/rccontrol/version
119 cp -v vcsserver/VERSION $out/nix-support/rccontrol/version
119 echo "DONE: Meta information for rccontrol written"
120 echo "DONE: Meta information for rccontrol written"
120
121
121 ln -s ${self.pyramid}/bin/* $out/bin/
122 ln -s ${self.pyramid}/bin/* $out/bin/
122 ln -s ${self.gunicorn}/bin/gunicorn $out/bin/
123 ln -s ${self.gunicorn}/bin/gunicorn $out/bin/
123
124
124 # Symlink version control utilities
125 # Symlink version control utilities
125 #
126 #
126 # 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.
127 # 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
128 # correct version.
129 # correct version.
129 ln -s ${pkgs.git}/bin/git $out/bin
130 ln -s ${pkgs.git}/bin/git $out/bin
130 ln -s ${self.mercurial}/bin/hg $out/bin
131 ln -s ${self.mercurial}/bin/hg $out/bin
131 ln -s ${pkgs.subversion}/bin/svn* $out/bin
132 ln -s ${pkgs.subversion}/bin/svn* $out/bin
132
133
133 for file in $out/bin/*; do
134 for file in $out/bin/*; do
134 wrapProgram $file \
135 wrapProgram $file \
135 --set PATH $PATH \
136 --set PATH $PATH \
136 --set PYTHONPATH $PYTHONPATH \
137 --set PYTHONPATH $PYTHONPATH \
137 --set PYTHONHASHSEED random
138 --set PYTHONHASHSEED random
138 done
139 done
139 '';
140 '';
140
141
141 });
142 });
142 };
143 };
143
144
144 # Apply all overrides and fix the final package set
145 # Apply all overrides and fix the final package set
145 myPythonPackages =
146 myPythonPackages =
146 (fix
147 (fix
147 (extends pythonExternalOverrides
148 (extends pythonExternalOverrides
148 (extends pythonLocalOverrides
149 (extends pythonLocalOverrides
149 (extends pythonOverrides
150 (extends pythonOverrides
150 pythonGeneratedPackages))));
151 pythonGeneratedPackages))));
151
152
152 in myPythonPackages.rhodecode-vcsserver
153 in myPythonPackages.rhodecode-vcsserver
General Comments 0
You need to be logged in to leave comments. Login now