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 "beta") + "${toString nixpkgs.revCount - 551362}.${nixpkgs.shortRev}";
16
17 # Run the tests for each platform. You can run a test by doing
18 # e.g. ‘nix-build release.nix -A tests.login.x86_64-linux’,
19 # or equivalently, ‘nix-build tests/login.nix’.
20 # See also nixosTests in pkgs/top-level/all-packages.nix
21 allTestsForSystem = system:
22 import ./tests/all-tests.nix {
23 inherit system;
24 pkgs = import ./.. { inherit system; };
25 callTest = config: {
26 ${system} = hydraJob config.test;
27 };
28 } // {
29 # for typechecking of the scripts and evaluation of
30 # the nodes, without running VMs.
31 allDrivers =
32 import ./tests/all-tests.nix {
33 inherit system;
34 pkgs = import ./.. { inherit system; };
35 callTest = config: {
36 ${system} = hydraJob config.driver;
37 };
38 };
39 };
40
41 allTests =
42 foldAttrs recursiveUpdate {} (map allTestsForSystem supportedSystems);
43
44 pkgs = import ./.. { system = "x86_64-linux"; };
45
46
47 versionModule = { config, ... }: {
48 system.nixos.versionSuffix = versionSuffix;
49 system.nixos.revision = nixpkgs.rev or nixpkgs.shortRev;
50
51 # At creation time we do not have state yet, so just default to latest.
52 system.stateVersion = config.system.nixos.version;
53 };
54
55 makeModules = module: rest: [ configuration versionModule module rest ];
56
57 makeIso =
58 { module, type, system, ... }:
59
60 with import ./.. { inherit system; };
61
62 hydraJob ((import lib/eval-config.nix {
63 inherit system;
64 modules = makeModules module {
65 isoImage.isoBaseName = "nixos-${type}";
66 };
67 }).config.system.build.isoImage);
68
69
70 makeSdImage =
71 { module, system, ... }:
72
73 with import ./.. { inherit system; };
74
75 hydraJob ((import lib/eval-config.nix {
76 inherit system;
77 modules = makeModules module {};
78 }).config.system.build.sdImage);
79
80
81 makeSystemTarball =
82 { module, maintainers ? ["viric"], system }:
83
84 with import ./.. { inherit system; };
85
86 let
87
88 config = (import lib/eval-config.nix {
89 inherit system;
90 modules = makeModules module {};
91 }).config;
92
93 tarball = config.system.build.tarball;
94
95 in
96 tarball //
97 { meta = {
98 description = "NixOS system tarball for ${system} - ${stdenv.hostPlatform.linux-kernel.name}";
99 maintainers = map (x: lib.maintainers.${x}) maintainers;
100 };
101 inherit config;
102 };
103
104
105 makeClosure = module: buildFromConfig module (config: config.system.build.toplevel);
106
107
108 buildFromConfig = module: sel: forAllSystems (system: hydraJob (sel (import ./lib/eval-config.nix {
109 inherit system;
110 modules = makeModules module
111 ({ ... }:
112 { fileSystems."/".device = mkDefault "/dev/sda1";
113 boot.loader.grub.device = mkDefault "/dev/sda";
114 });
115 }).config));
116
117 makeNetboot = { module, system, ... }:
118 let
119 configEvaled = import lib/eval-config.nix {
120 inherit system;
121 modules = makeModules module {};
122 };
123 build = configEvaled.config.system.build;
124 kernelTarget = configEvaled.pkgs.stdenv.hostPlatform.linux-kernel.target;
125 in
126 configEvaled.pkgs.symlinkJoin {
127 name = "netboot";
128 paths = [
129 build.netbootRamdisk
130 build.kernel
131 build.netbootIpxeScript
132 ];
133 postBuild = ''
134 mkdir -p $out/nix-support
135 echo "file ${kernelTarget} ${build.kernel}/${kernelTarget}" >> $out/nix-support/hydra-build-products
136 echo "file initrd ${build.netbootRamdisk}/initrd" >> $out/nix-support/hydra-build-products
137 echo "file ipxe ${build.netbootIpxeScript}/netboot.ipxe" >> $out/nix-support/hydra-build-products
138 '';
139 preferLocalBuild = true;
140 };
141
142in rec {
143
144 channel = import lib/make-channel.nix { inherit pkgs nixpkgs version versionSuffix; };
145
146 manualHTML = buildFromConfig ({ ... }: { }) (config: config.system.build.manual.manualHTML);
147 manual = manualHTML; # TODO(@oxij): remove eventually
148 manualEpub = (buildFromConfig ({ ... }: { }) (config: config.system.build.manual.manualEpub));
149 nixos-configuration-reference-manpage = buildFromConfig ({ ... }: { }) (config: config.system.build.manual.nixos-configuration-reference-manpage);
150 options = (buildFromConfig ({ ... }: { }) (config: config.system.build.manual.optionsJSON)).x86_64-linux;
151
152
153 # Build the initial ramdisk so Hydra can keep track of its size over time.
154 initialRamdisk = buildFromConfig ({ ... }: { }) (config: config.system.build.initialRamdisk);
155
156 kexec = forMatchingSystems supportedSystems (system: (import lib/eval-config.nix {
157 inherit system;
158 modules = [
159 ./modules/installer/netboot/netboot-minimal.nix
160 ];
161 }).config.system.build.kexecTree);
162
163 netboot = forMatchingSystems supportedSystems (system: makeNetboot {
164 module = ./modules/installer/netboot/netboot-minimal.nix;
165 inherit system;
166 });
167
168 iso_minimal = forAllSystems (system: makeIso {
169 module = ./modules/installer/cd-dvd/installation-cd-minimal.nix;
170 type = "minimal";
171 inherit system;
172 });
173
174 iso_plasma5 = forMatchingSystems supportedSystems (system: makeIso {
175 module = ./modules/installer/cd-dvd/installation-cd-graphical-calamares-plasma5.nix;
176 type = "plasma5";
177 inherit system;
178 });
179
180 iso_gnome = forMatchingSystems supportedSystems (system: makeIso {
181 module = ./modules/installer/cd-dvd/installation-cd-graphical-calamares-gnome.nix;
182 type = "gnome";
183 inherit system;
184 });
185
186 # A variant with a more recent (but possibly less stable) kernel that might support more hardware.
187 # This variant keeps zfs support enabled, hoping it will build and work.
188 iso_minimal_new_kernel = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system: makeIso {
189 module = ./modules/installer/cd-dvd/installation-cd-minimal-new-kernel.nix;
190 type = "minimal-new-kernel";
191 inherit system;
192 });
193
194 # A variant with a more recent (but possibly less stable) kernel that might support more hardware.
195 # ZFS support disabled since it is unlikely to support the latest kernel.
196 iso_minimal_new_kernel_no_zfs = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system: makeIso {
197 module = ./modules/installer/cd-dvd/installation-cd-minimal-new-kernel-no-zfs.nix;
198 type = "minimal-new-kernel-no-zfs";
199 inherit system;
200 });
201
202 sd_image = forMatchingSystems [ "armv6l-linux" "armv7l-linux" "aarch64-linux" ] (system: makeSdImage {
203 module = {
204 armv6l-linux = ./modules/installer/sd-card/sd-image-raspberrypi-installer.nix;
205 armv7l-linux = ./modules/installer/sd-card/sd-image-armv7l-multiplatform-installer.nix;
206 aarch64-linux = ./modules/installer/sd-card/sd-image-aarch64-installer.nix;
207 }.${system};
208 inherit system;
209 });
210
211 sd_image_new_kernel = forMatchingSystems [ "aarch64-linux" ] (system: makeSdImage {
212 module = {
213 aarch64-linux = ./modules/installer/sd-card/sd-image-aarch64-new-kernel-installer.nix;
214 }.${system};
215 type = "minimal-new-kernel";
216 inherit system;
217 });
218
219 sd_image_new_kernel_no_zfs = forMatchingSystems [ "aarch64-linux" ] (system: makeSdImage {
220 module = {
221 aarch64-linux = ./modules/installer/sd-card/sd-image-aarch64-new-kernel-no-zfs-installer.nix;
222 }.${system};
223 type = "minimal-new-kernel-no-zfs";
224 inherit system;
225 });
226
227 # A bootable VirtualBox virtual appliance as an OVA file (i.e. packaged OVF).
228 ova = forMatchingSystems [ "x86_64-linux" ] (system:
229
230 with import ./.. { inherit system; };
231
232 hydraJob ((import lib/eval-config.nix {
233 inherit system;
234 modules =
235 [ versionModule
236 ./modules/installer/virtualbox-demo.nix
237 ];
238 }).config.system.build.virtualBoxOVA)
239
240 );
241
242 # KVM image for proxmox in VMA format
243 proxmoxImage = forMatchingSystems [ "x86_64-linux" ] (system:
244 with import ./.. { inherit system; };
245
246 hydraJob ((import lib/eval-config.nix {
247 inherit system;
248 modules = [
249 ./modules/virtualisation/proxmox-image.nix
250 ];
251 }).config.system.build.VMA)
252 );
253
254 # LXC tarball for proxmox
255 proxmoxLXC = forMatchingSystems [ "x86_64-linux" ] (system:
256 with import ./.. { inherit system; };
257
258 hydraJob ((import lib/eval-config.nix {
259 inherit system;
260 modules = [
261 ./modules/virtualisation/proxmox-lxc.nix
262 ];
263 }).config.system.build.tarball)
264 );
265
266 # A disk image that can be imported to Amazon EC2 and registered as an AMI
267 amazonImage = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system:
268
269 with import ./.. { inherit system; };
270
271 hydraJob ((import lib/eval-config.nix {
272 inherit system;
273 modules =
274 [ configuration
275 versionModule
276 ./maintainers/scripts/ec2/amazon-image.nix
277 ];
278 }).config.system.build.amazonImage)
279
280 );
281 amazonImageZfs = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system:
282
283 with import ./.. { inherit system; };
284
285 hydraJob ((import lib/eval-config.nix {
286 inherit system;
287 modules =
288 [ configuration
289 versionModule
290 ./maintainers/scripts/ec2/amazon-image-zfs.nix
291 ];
292 }).config.system.build.amazonImage)
293
294 );
295
296
297 # Test job for https://github.com/NixOS/nixpkgs/issues/121354 to test
298 # automatic sizing without blocking the channel.
299 amazonImageAutomaticSize = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system:
300
301 with import ./.. { inherit system; };
302
303 hydraJob ((import lib/eval-config.nix {
304 inherit system;
305 modules =
306 [ configuration
307 versionModule
308 ./maintainers/scripts/ec2/amazon-image.nix
309 ({ ... }: { amazonImage.sizeMB = "auto"; })
310 ];
311 }).config.system.build.amazonImage)
312
313 );
314
315 # An image that can be imported into lxd and used for container creation
316 lxdContainerImage = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system:
317
318 with import ./.. { inherit system; };
319
320 hydraJob ((import lib/eval-config.nix {
321 inherit system;
322 modules =
323 [ configuration
324 versionModule
325 ./maintainers/scripts/lxd/lxd-container-image.nix
326 ];
327 }).config.system.build.tarball)
328
329 );
330
331 lxdContainerImageSquashfs = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system:
332
333 with import ./.. { inherit system; };
334
335 hydraJob ((import lib/eval-config.nix {
336 inherit system;
337 modules =
338 [ configuration
339 versionModule
340 ./maintainers/scripts/lxd/lxd-container-image.nix
341 ];
342 }).config.system.build.squashfs)
343
344 );
345
346 # Metadata for the lxd image
347 lxdContainerMeta = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system:
348
349 with import ./.. { inherit system; };
350
351 hydraJob ((import lib/eval-config.nix {
352 inherit system;
353 modules =
354 [ configuration
355 versionModule
356 ./maintainers/scripts/lxd/lxd-container-image.nix
357 ];
358 }).config.system.build.metadata)
359
360 );
361
362 # An image that can be imported into lxd and used for container creation
363 lxdVirtualMachineImage = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system:
364
365 with import ./.. { inherit system; };
366
367 hydraJob ((import lib/eval-config.nix {
368 inherit system;
369 modules =
370 [ configuration
371 versionModule
372 ./maintainers/scripts/lxd/lxd-virtual-machine-image.nix
373 ];
374 }).config.system.build.qemuImage)
375
376 );
377
378 # Metadata for the lxd image
379 lxdVirtualMachineImageMeta = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system:
380
381 with import ./.. { inherit system; };
382
383 hydraJob ((import lib/eval-config.nix {
384 inherit system;
385 modules =
386 [ configuration
387 versionModule
388 ./maintainers/scripts/lxd/lxd-virtual-machine-image.nix
389 ];
390 }).config.system.build.metadata)
391
392 );
393
394 # Ensure that all packages used by the minimal NixOS config end up in the channel.
395 dummy = forAllSystems (system: pkgs.runCommand "dummy"
396 { toplevel = (import lib/eval-config.nix {
397 inherit system;
398 modules = singleton ({ ... }:
399 { fileSystems."/".device = mkDefault "/dev/sda1";
400 boot.loader.grub.device = mkDefault "/dev/sda";
401 system.stateVersion = mkDefault lib.trivial.release;
402 });
403 }).config.system.build.toplevel;
404 preferLocalBuild = true;
405 }
406 "mkdir $out; ln -s $toplevel $out/dummy");
407
408
409 # Provide container tarball for lxc, libvirt-lxc, docker-lxc, ...
410 containerTarball = forAllSystems (system: makeSystemTarball {
411 module = ./modules/virtualisation/lxc-container.nix;
412 inherit system;
413 });
414
415 tests = allTests;
416
417 /* Build a bunch of typical closures so that Hydra can keep track of
418 the evolution of closure sizes. */
419
420 closures = {
421
422 smallContainer = makeClosure ({ ... }:
423 { boot.isContainer = true;
424 services.openssh.enable = true;
425 });
426
427 tinyContainer = makeClosure ({ ... }:
428 { boot.isContainer = true;
429 imports = [ modules/profiles/minimal.nix ];
430 });
431
432 ec2 = makeClosure ({ ... }:
433 { imports = [ modules/virtualisation/amazon-image.nix ];
434 });
435
436 kde = makeClosure ({ ... }:
437 { services.xserver.enable = true;
438 services.xserver.displayManager.sddm.enable = true;
439 services.xserver.desktopManager.plasma5.enable = true;
440 });
441
442 xfce = makeClosure ({ ... }:
443 { services.xserver.enable = true;
444 services.xserver.desktopManager.xfce.enable = true;
445 });
446
447 gnome = makeClosure ({ ... }:
448 { services.xserver.enable = true;
449 services.xserver.displayManager.gdm.enable = true;
450 services.xserver.desktopManager.gnome.enable = true;
451 });
452
453 pantheon = makeClosure ({ ... }:
454 { services.xserver.enable = true;
455 services.xserver.desktopManager.pantheon.enable = true;
456 });
457
458 deepin = makeClosure ({ ... }:
459 { services.xserver.enable = true;
460 services.xserver.displayManager.lightdm.enable = true;
461 services.xserver.desktopManager.deepin.enable = true;
462 });
463
464 # Linux/Apache/PostgreSQL/PHP stack.
465 lapp = makeClosure ({ pkgs, ... }:
466 { services.httpd.enable = true;
467 services.httpd.adminAddr = "foo@example.org";
468 services.httpd.enablePHP = true;
469 services.postgresql.enable = true;
470 services.postgresql.package = pkgs.postgresql;
471 });
472 };
473}