1with import ../lib;
2
3{ nixpkgs ? { outPath = cleanSource ./..; revCount = 130979; shortRev = "gfedcba"; }
4, stableBranch ? false
5, supportedSystems ? [ "x86_64-linux" "aarch64-linux" ]
6, configuration ? {}
7}:
8
9with import ../pkgs/top-level/release-lib.nix { inherit supportedSystems; };
10
11let
12
13 version = fileContents ../.version;
14 versionSuffix =
15 (if stableBranch then "." else "pre") + "${toString nixpkgs.revCount}.${nixpkgs.shortRev}";
16
17 # Run the tests for each platform. You can run a test by doing
18 # e.g. ‘nix-build -A tests.login.x86_64-linux’, or equivalently,
19 # ‘nix-build tests/login.nix -A result’.
20 allTestsForSystem = system:
21 import ./tests/all-tests.nix {
22 inherit system;
23 pkgs = import ./.. { inherit system; };
24 callTest = t: {
25 ${system} = hydraJob t.test;
26 };
27 };
28 allTests =
29 foldAttrs recursiveUpdate {} (map allTestsForSystem supportedSystems);
30
31 pkgs = import ./.. { system = "x86_64-linux"; };
32
33
34 versionModule =
35 { system.nixos.versionSuffix = versionSuffix;
36 system.nixos.revision = nixpkgs.rev or nixpkgs.shortRev;
37 };
38
39 makeModules = module: rest: [ configuration versionModule module rest ];
40
41 makeIso =
42 { module, type, system, ... }:
43
44 with import ./.. { inherit system; };
45
46 hydraJob ((import lib/eval-config.nix {
47 inherit system;
48 modules = makeModules module {
49 isoImage.isoBaseName = "nixos-${type}";
50 };
51 }).config.system.build.isoImage);
52
53
54 makeSdImage =
55 { module, system, ... }:
56
57 with import ./.. { inherit system; };
58
59 hydraJob ((import lib/eval-config.nix {
60 inherit system;
61 modules = makeModules module {};
62 }).config.system.build.sdImage);
63
64
65 makeSystemTarball =
66 { module, maintainers ? ["viric"], system }:
67
68 with import ./.. { inherit system; };
69
70 let
71
72 config = (import lib/eval-config.nix {
73 inherit system;
74 modules = makeModules module {};
75 }).config;
76
77 tarball = config.system.build.tarball;
78
79 in
80 tarball //
81 { meta = {
82 description = "NixOS system tarball for ${system} - ${stdenv.hostPlatform.linux-kernel.name}";
83 maintainers = map (x: lib.maintainers.${x}) maintainers;
84 };
85 inherit config;
86 };
87
88
89 makeClosure = module: buildFromConfig module (config: config.system.build.toplevel);
90
91
92 buildFromConfig = module: sel: forAllSystems (system: hydraJob (sel (import ./lib/eval-config.nix {
93 inherit system;
94 modules = makeModules module
95 ({ ... }:
96 { fileSystems."/".device = mkDefault "/dev/sda1";
97 boot.loader.grub.device = mkDefault "/dev/sda";
98 });
99 }).config));
100
101 makeNetboot = { module, system, ... }:
102 let
103 configEvaled = import lib/eval-config.nix {
104 inherit system;
105 modules = makeModules module {};
106 };
107 build = configEvaled.config.system.build;
108 kernelTarget = configEvaled.pkgs.stdenv.hostPlatform.linux-kernel.target;
109 in
110 pkgs.symlinkJoin {
111 name = "netboot";
112 paths = [
113 build.netbootRamdisk
114 build.kernel
115 build.netbootIpxeScript
116 ];
117 postBuild = ''
118 mkdir -p $out/nix-support
119 echo "file ${kernelTarget} ${build.kernel}/${kernelTarget}" >> $out/nix-support/hydra-build-products
120 echo "file initrd ${build.netbootRamdisk}/initrd" >> $out/nix-support/hydra-build-products
121 echo "file ipxe ${build.netbootIpxeScript}/netboot.ipxe" >> $out/nix-support/hydra-build-products
122 '';
123 preferLocalBuild = true;
124 };
125
126in rec {
127
128 channel = import lib/make-channel.nix { inherit pkgs nixpkgs version versionSuffix; };
129
130 manualHTML = buildFromConfig ({ ... }: { }) (config: config.system.build.manual.manualHTML);
131 manual = manualHTML; # TODO(@oxij): remove eventually
132 manualEpub = (buildFromConfig ({ ... }: { }) (config: config.system.build.manual.manualEpub));
133 manpages = buildFromConfig ({ ... }: { }) (config: config.system.build.manual.manpages);
134 manualGeneratedSources = buildFromConfig ({ ... }: { }) (config: config.system.build.manual.generatedSources);
135 options = (buildFromConfig ({ ... }: { }) (config: config.system.build.manual.optionsJSON)).x86_64-linux;
136
137
138 # Build the initial ramdisk so Hydra can keep track of its size over time.
139 initialRamdisk = buildFromConfig ({ ... }: { }) (config: config.system.build.initialRamdisk);
140
141 netboot = forMatchingSystems supportedSystems (system: makeNetboot {
142 module = ./modules/installer/netboot/netboot-minimal.nix;
143 inherit system;
144 });
145
146 iso_minimal = forAllSystems (system: makeIso {
147 module = ./modules/installer/cd-dvd/installation-cd-minimal.nix;
148 type = "minimal";
149 inherit system;
150 });
151
152 iso_plasma5 = forMatchingSystems [ "x86_64-linux" ] (system: makeIso {
153 module = ./modules/installer/cd-dvd/installation-cd-graphical-plasma5.nix;
154 type = "plasma5";
155 inherit system;
156 });
157
158 iso_gnome = forMatchingSystems [ "x86_64-linux" ] (system: makeIso {
159 module = ./modules/installer/cd-dvd/installation-cd-graphical-gnome.nix;
160 type = "gnome";
161 inherit system;
162 });
163
164 # A variant with a more recent (but possibly less stable) kernel
165 # that might support more hardware.
166 iso_minimal_new_kernel = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system: makeIso {
167 module = ./modules/installer/cd-dvd/installation-cd-minimal-new-kernel.nix;
168 type = "minimal-new-kernel";
169 inherit system;
170 });
171
172 sd_image = forMatchingSystems [ "armv6l-linux" "armv7l-linux" "aarch64-linux" ] (system: makeSdImage {
173 module = {
174 armv6l-linux = ./modules/installer/sd-card/sd-image-raspberrypi-installer.nix;
175 armv7l-linux = ./modules/installer/sd-card/sd-image-armv7l-multiplatform-installer.nix;
176 aarch64-linux = ./modules/installer/sd-card/sd-image-aarch64-installer.nix;
177 }.${system};
178 inherit system;
179 });
180
181 sd_image_new_kernel = forMatchingSystems [ "aarch64-linux" ] (system: makeSdImage {
182 module = {
183 aarch64-linux = ./modules/installer/sd-card/sd-image-aarch64-new-kernel-installer.nix;
184 }.${system};
185 type = "minimal-new-kernel";
186 inherit system;
187 });
188
189 # A bootable VirtualBox virtual appliance as an OVA file (i.e. packaged OVF).
190 ova = forMatchingSystems [ "x86_64-linux" ] (system:
191
192 with import ./.. { inherit system; };
193
194 hydraJob ((import lib/eval-config.nix {
195 inherit system;
196 modules =
197 [ versionModule
198 ./modules/installer/virtualbox-demo.nix
199 ];
200 }).config.system.build.virtualBoxOVA)
201
202 );
203
204
205 # A disk image that can be imported to Amazon EC2 and registered as an AMI
206 amazonImage = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system:
207
208 with import ./.. { inherit system; };
209
210 hydraJob ((import lib/eval-config.nix {
211 inherit system;
212 modules =
213 [ configuration
214 versionModule
215 ./maintainers/scripts/ec2/amazon-image.nix
216 ];
217 }).config.system.build.amazonImage)
218
219 );
220 amazonImageZfs = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system:
221
222 with import ./.. { inherit system; };
223
224 hydraJob ((import lib/eval-config.nix {
225 inherit system;
226 modules =
227 [ configuration
228 versionModule
229 ./maintainers/scripts/ec2/amazon-image-zfs.nix
230 ];
231 }).config.system.build.amazonImage)
232
233 );
234
235
236 # Test job for https://github.com/NixOS/nixpkgs/issues/121354 to test
237 # automatic sizing without blocking the channel.
238 amazonImageAutomaticSize = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system:
239
240 with import ./.. { inherit system; };
241
242 hydraJob ((import lib/eval-config.nix {
243 inherit system;
244 modules =
245 [ configuration
246 versionModule
247 ./maintainers/scripts/ec2/amazon-image.nix
248 ({ ... }: { amazonImage.sizeMB = "auto"; })
249 ];
250 }).config.system.build.amazonImage)
251
252 );
253
254 # An image that can be imported into lxd and used for container creation
255 lxdImage = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system:
256
257 with import ./.. { inherit system; };
258
259 hydraJob ((import lib/eval-config.nix {
260 inherit system;
261 modules =
262 [ configuration
263 versionModule
264 ./maintainers/scripts/lxd/lxd-image.nix
265 ];
266 }).config.system.build.tarball)
267
268 );
269
270 # Metadata for the lxd image
271 lxdMeta = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system:
272
273 with import ./.. { inherit system; };
274
275 hydraJob ((import lib/eval-config.nix {
276 inherit system;
277 modules =
278 [ configuration
279 versionModule
280 ./maintainers/scripts/lxd/lxd-image.nix
281 ];
282 }).config.system.build.metadata)
283
284 );
285
286 # Ensure that all packages used by the minimal NixOS config end up in the channel.
287 dummy = forAllSystems (system: pkgs.runCommand "dummy"
288 { toplevel = (import lib/eval-config.nix {
289 inherit system;
290 modules = singleton ({ ... }:
291 { fileSystems."/".device = mkDefault "/dev/sda1";
292 boot.loader.grub.device = mkDefault "/dev/sda";
293 system.stateVersion = mkDefault "18.03";
294 });
295 }).config.system.build.toplevel;
296 preferLocalBuild = true;
297 }
298 "mkdir $out; ln -s $toplevel $out/dummy");
299
300
301 # Provide a tarball that can be unpacked into an SD card, and easily
302 # boot that system from uboot (like for the sheevaplug).
303 # The pc variant helps preparing the expression for the system tarball
304 # in a machine faster than the sheevpalug
305 /*
306 system_tarball_pc = forAllSystems (system: makeSystemTarball {
307 module = ./modules/installer/cd-dvd/system-tarball-pc.nix;
308 inherit system;
309 });
310 */
311
312 # Provide container tarball for lxc, libvirt-lxc, docker-lxc, ...
313 containerTarball = forAllSystems (system: makeSystemTarball {
314 module = ./modules/virtualisation/lxc-container.nix;
315 inherit system;
316 });
317
318 /*
319 system_tarball_fuloong2f =
320 assert builtins.currentSystem == "mips64-linux";
321 makeSystemTarball {
322 module = ./modules/installer/cd-dvd/system-tarball-fuloong2f.nix;
323 system = "mips64-linux";
324 };
325
326 system_tarball_sheevaplug =
327 assert builtins.currentSystem == "armv5tel-linux";
328 makeSystemTarball {
329 module = ./modules/installer/cd-dvd/system-tarball-sheevaplug.nix;
330 system = "armv5tel-linux";
331 };
332 */
333
334 tests = allTests;
335
336 /* Build a bunch of typical closures so that Hydra can keep track of
337 the evolution of closure sizes. */
338
339 closures = {
340
341 smallContainer = makeClosure ({ ... }:
342 { boot.isContainer = true;
343 services.openssh.enable = true;
344 });
345
346 tinyContainer = makeClosure ({ ... }:
347 { boot.isContainer = true;
348 imports = [ modules/profiles/minimal.nix ];
349 });
350
351 ec2 = makeClosure ({ ... }:
352 { imports = [ modules/virtualisation/amazon-image.nix ];
353 });
354
355 kde = makeClosure ({ ... }:
356 { services.xserver.enable = true;
357 services.xserver.displayManager.sddm.enable = true;
358 services.xserver.desktopManager.plasma5.enable = true;
359 });
360
361 xfce = makeClosure ({ ... }:
362 { services.xserver.enable = true;
363 services.xserver.desktopManager.xfce.enable = true;
364 });
365
366 gnome = makeClosure ({ ... }:
367 { services.xserver.enable = true;
368 services.xserver.displayManager.gdm.enable = true;
369 services.xserver.desktopManager.gnome.enable = true;
370 });
371
372 pantheon = makeClosure ({ ... }:
373 { services.xserver.enable = true;
374 services.xserver.desktopManager.pantheon.enable = true;
375 });
376
377 # Linux/Apache/PostgreSQL/PHP stack.
378 lapp = makeClosure ({ pkgs, ... }:
379 { services.httpd.enable = true;
380 services.httpd.adminAddr = "foo@example.org";
381 services.httpd.enablePHP = true;
382 services.postgresql.enable = true;
383 services.postgresql.package = pkgs.postgresql;
384 });
385 };
386}