Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib, pkgs }:
2
3let
4 inherit (lib) optionalString;
5
6 inherit (pkgs)
7 autoconf
8 automake
9 checkinstall
10 clang-analyzer
11 cov-build
12 enableGCOVInstrumentation
13 lcov
14 libtool
15 makeGCOVReport
16 runCommand
17 stdenv
18 vmTools
19 xz
20 ;
21in
22
23rec {
24
25 sourceTarball =
26 args:
27 import ./source-tarball.nix (
28 {
29 inherit
30 lib
31 stdenv
32 autoconf
33 automake
34 libtool
35 ;
36 }
37 // args
38 );
39
40 makeSourceTarball = sourceTarball; # compatibility
41
42 binaryTarball =
43 args:
44 import ./binary-tarball.nix (
45 {
46 inherit lib stdenv;
47 }
48 // args
49 );
50
51 mvnBuild =
52 args:
53 import ./maven-build.nix (
54 {
55 inherit lib stdenv;
56 }
57 // args
58 );
59
60 nixBuild =
61 args:
62 import ./nix-build.nix (
63 {
64 inherit lib stdenv;
65 }
66 // args
67 );
68
69 coverageAnalysis =
70 args:
71 nixBuild (
72 {
73 inherit lcov enableGCOVInstrumentation makeGCOVReport;
74 doCoverageAnalysis = true;
75 }
76 // args
77 );
78
79 clangAnalysis =
80 args:
81 nixBuild (
82 {
83 inherit clang-analyzer;
84 doClangAnalysis = true;
85 }
86 // args
87 );
88
89 coverityAnalysis =
90 args:
91 nixBuild (
92 {
93 inherit cov-build xz;
94 doCoverityAnalysis = true;
95 }
96 // args
97 );
98
99 rpmBuild =
100 args:
101 import ./rpm-build.nix (
102 {
103 inherit lib vmTools;
104 }
105 // args
106 );
107
108 debBuild =
109 args:
110 import ./debian-build.nix (
111 {
112 inherit
113 lib
114 stdenv
115 vmTools
116 checkinstall
117 ;
118 }
119 // args
120 );
121
122 aggregate =
123 {
124 name,
125 constituents,
126 meta ? { },
127 }:
128 pkgs.runCommand name
129 {
130 inherit constituents meta;
131 preferLocalBuild = true;
132 _hydraAggregate = true;
133 }
134 ''
135 mkdir -p $out/nix-support
136 touch $out/nix-support/hydra-build-products
137 echo $constituents > $out/nix-support/hydra-aggregate-constituents
138
139 # Propagate build failures.
140 for i in $constituents; do
141 if [ -e $i/nix-support/failed ]; then
142 touch $out/nix-support/failed
143 fi
144 done
145 '';
146
147 /*
148 Create a channel job which success depends on the success of all of
149 its contituents. Channel jobs are a special type of jobs that are
150 listed in the channel tab of Hydra and that can be subscribed.
151 A tarball of the src attribute is distributed via the channel.
152
153 - constituents: a list of derivations on which the channel success depends.
154 - name: the channel name that will be used in the hydra interface.
155 - src: should point to the root folder of the nix-expressions used by the
156 channel, typically a folder containing a `default.nix`.
157
158 channel {
159 constituents = [ foo bar baz ];
160 name = "my-channel";
161 src = ./.;
162 };
163 */
164 channel =
165 {
166 name,
167 src,
168 constituents ? [ ],
169 meta ? { },
170 isNixOS ? true,
171 ...
172 }@args:
173 stdenv.mkDerivation (
174 {
175 preferLocalBuild = true;
176 _hydraAggregate = true;
177
178 dontConfigure = true;
179 dontBuild = true;
180
181 patchPhase = optionalString isNixOS ''
182 touch .update-on-nixos-rebuild
183 '';
184
185 installPhase = ''
186 mkdir -p $out/{tarballs,nix-support}
187
188 tar cJf "$out/tarballs/nixexprs.tar.xz" \
189 --owner=0 --group=0 --mtime="1970-01-01 00:00:00 UTC" \
190 --transform='s!^\.!${name}!' .
191
192 echo "channel - $out/tarballs/nixexprs.tar.xz" > "$out/nix-support/hydra-build-products"
193 echo $constituents > "$out/nix-support/hydra-aggregate-constituents"
194
195 # Propagate build failures.
196 for i in $constituents; do
197 if [ -e "$i/nix-support/failed" ]; then
198 touch "$out/nix-support/failed"
199 fi
200 done
201 '';
202
203 meta = meta // {
204 isHydraChannel = true;
205 };
206 }
207 // removeAttrs args [ "meta" ]
208 );
209
210}