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 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_plasma6 = forMatchingSystems supportedSystems (system: makeIso {
181 module = ./modules/installer/cd-dvd/installation-cd-graphical-calamares-plasma6.nix;
182 type = "plasma6";
183 inherit system;
184 });
185
186 iso_gnome = forMatchingSystems supportedSystems (system: makeIso {
187 module = ./modules/installer/cd-dvd/installation-cd-graphical-calamares-gnome.nix;
188 type = "gnome";
189 inherit system;
190 });
191
192 # A variant with a more recent (but possibly less stable) kernel that might support more hardware.
193 # This variant keeps zfs support enabled, hoping it will build and work.
194 iso_minimal_new_kernel = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system: makeIso {
195 module = ./modules/installer/cd-dvd/installation-cd-minimal-new-kernel.nix;
196 type = "minimal-new-kernel";
197 inherit system;
198 });
199
200 # A variant with a more recent (but possibly less stable) kernel that might support more hardware.
201 # ZFS support disabled since it is unlikely to support the latest kernel.
202 iso_minimal_new_kernel_no_zfs = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system: makeIso {
203 module = ./modules/installer/cd-dvd/installation-cd-minimal-new-kernel-no-zfs.nix;
204 type = "minimal-new-kernel-no-zfs";
205 inherit system;
206 });
207
208 sd_image = forMatchingSystems [ "armv6l-linux" "armv7l-linux" "aarch64-linux" ] (system: makeSdImage {
209 module = {
210 armv6l-linux = ./modules/installer/sd-card/sd-image-raspberrypi-installer.nix;
211 armv7l-linux = ./modules/installer/sd-card/sd-image-armv7l-multiplatform-installer.nix;
212 aarch64-linux = ./modules/installer/sd-card/sd-image-aarch64-installer.nix;
213 }.${system};
214 inherit system;
215 });
216
217 sd_image_new_kernel = forMatchingSystems [ "aarch64-linux" ] (system: makeSdImage {
218 module = {
219 aarch64-linux = ./modules/installer/sd-card/sd-image-aarch64-new-kernel-installer.nix;
220 }.${system};
221 type = "minimal-new-kernel";
222 inherit system;
223 });
224
225 sd_image_new_kernel_no_zfs = forMatchingSystems [ "aarch64-linux" ] (system: makeSdImage {
226 module = {
227 aarch64-linux = ./modules/installer/sd-card/sd-image-aarch64-new-kernel-no-zfs-installer.nix;
228 }.${system};
229 type = "minimal-new-kernel-no-zfs";
230 inherit system;
231 });
232
233 # A bootable VirtualBox virtual appliance as an OVA file (i.e. packaged OVF).
234 ova = forMatchingSystems [ "x86_64-linux" ] (system:
235
236 with import ./.. { inherit system; };
237
238 hydraJob ((import lib/eval-config.nix {
239 inherit system;
240 modules =
241 [ versionModule
242 ./modules/installer/virtualbox-demo.nix
243 ];
244 }).config.system.build.virtualBoxOVA)
245
246 );
247
248 # KVM image for proxmox in VMA format
249 proxmoxImage = forMatchingSystems [ "x86_64-linux" ] (system:
250 with import ./.. { inherit system; };
251
252 hydraJob ((import lib/eval-config.nix {
253 inherit system;
254 modules = [
255 ./modules/virtualisation/proxmox-image.nix
256 ];
257 }).config.system.build.VMA)
258 );
259
260 # LXC tarball for proxmox
261 proxmoxLXC = forMatchingSystems [ "x86_64-linux" ] (system:
262 with import ./.. { inherit system; };
263
264 hydraJob ((import lib/eval-config.nix {
265 inherit system;
266 modules = [
267 ./modules/virtualisation/proxmox-lxc.nix
268 ];
269 }).config.system.build.tarball)
270 );
271
272 # A disk image that can be imported to Amazon EC2 and registered as an AMI
273 amazonImage = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system:
274
275 with import ./.. { inherit system; };
276
277 hydraJob ((import lib/eval-config.nix {
278 inherit system;
279 modules =
280 [ configuration
281 versionModule
282 ./maintainers/scripts/ec2/amazon-image.nix
283 ];
284 }).config.system.build.amazonImage)
285
286 );
287 amazonImageZfs = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system:
288
289 with import ./.. { inherit system; };
290
291 hydraJob ((import lib/eval-config.nix {
292 inherit system;
293 modules =
294 [ configuration
295 versionModule
296 ./maintainers/scripts/ec2/amazon-image-zfs.nix
297 ];
298 }).config.system.build.amazonImage)
299
300 );
301
302
303 # Test job for https://github.com/NixOS/nixpkgs/issues/121354 to test
304 # automatic sizing without blocking the channel.
305 amazonImageAutomaticSize = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system:
306
307 with import ./.. { inherit system; };
308
309 hydraJob ((import lib/eval-config.nix {
310 inherit system;
311 modules =
312 [ configuration
313 versionModule
314 ./maintainers/scripts/ec2/amazon-image.nix
315 ({ ... }: { amazonImage.sizeMB = "auto"; })
316 ];
317 }).config.system.build.amazonImage)
318
319 );
320
321 # An image that can be imported into lxd and used for container creation
322 lxdContainerImage = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system:
323
324 with import ./.. { inherit system; };
325
326 hydraJob ((import lib/eval-config.nix {
327 inherit system;
328 modules =
329 [ configuration
330 versionModule
331 ./maintainers/scripts/lxd/lxd-container-image.nix
332 ];
333 }).config.system.build.tarball)
334
335 );
336
337 lxdContainerImageSquashfs = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system:
338
339 with import ./.. { inherit system; };
340
341 hydraJob ((import lib/eval-config.nix {
342 inherit system;
343 modules =
344 [ configuration
345 versionModule
346 ./maintainers/scripts/lxd/lxd-container-image.nix
347 ];
348 }).config.system.build.squashfs)
349
350 );
351
352 # Metadata for the lxd image
353 lxdContainerMeta = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system:
354
355 with import ./.. { inherit system; };
356
357 hydraJob ((import lib/eval-config.nix {
358 inherit system;
359 modules =
360 [ configuration
361 versionModule
362 ./maintainers/scripts/lxd/lxd-container-image.nix
363 ];
364 }).config.system.build.metadata)
365
366 );
367
368 # An image that can be imported into lxd and used for container creation
369 lxdVirtualMachineImage = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system:
370
371 with import ./.. { inherit system; };
372
373 hydraJob ((import lib/eval-config.nix {
374 inherit system;
375 modules =
376 [ configuration
377 versionModule
378 ./maintainers/scripts/lxd/lxd-virtual-machine-image.nix
379 ];
380 }).config.system.build.qemuImage)
381
382 );
383
384 # Metadata for the lxd image
385 lxdVirtualMachineImageMeta = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system:
386
387 with import ./.. { inherit system; };
388
389 hydraJob ((import lib/eval-config.nix {
390 inherit system;
391 modules =
392 [ configuration
393 versionModule
394 ./maintainers/scripts/lxd/lxd-virtual-machine-image.nix
395 ];
396 }).config.system.build.metadata)
397
398 );
399
400 # Ensure that all packages used by the minimal NixOS config end up in the channel.
401 dummy = forAllSystems (system: pkgs.runCommand "dummy"
402 { toplevel = (import lib/eval-config.nix {
403 inherit system;
404 modules = singleton ({ ... }:
405 { fileSystems."/".device = mkDefault "/dev/sda1";
406 boot.loader.grub.device = mkDefault "/dev/sda";
407 system.stateVersion = mkDefault lib.trivial.release;
408 });
409 }).config.system.build.toplevel;
410 preferLocalBuild = true;
411 }
412 "mkdir $out; ln -s $toplevel $out/dummy");
413
414
415 # Provide container tarball for lxc, libvirt-lxc, docker-lxc, ...
416 containerTarball = forAllSystems (system: makeSystemTarball {
417 module = ./modules/virtualisation/lxc-container.nix;
418 inherit system;
419 });
420
421 tests = allTests;
422
423 /* Build a bunch of typical closures so that Hydra can keep track of
424 the evolution of closure sizes. */
425
426 closures = {
427
428 smallContainer = makeClosure ({ ... }:
429 { boot.isContainer = true;
430 services.openssh.enable = true;
431 });
432
433 tinyContainer = makeClosure ({ ... }:
434 { boot.isContainer = true;
435 imports = [ modules/profiles/minimal.nix ];
436 });
437
438 ec2 = makeClosure ({ ... }:
439 { imports = [ modules/virtualisation/amazon-image.nix ];
440 });
441
442 kde = makeClosure ({ ... }:
443 { services.xserver.enable = true;
444 services.displayManager.sddm.enable = true;
445 services.xserver.desktopManager.plasma5.enable = true;
446 });
447
448 xfce = makeClosure ({ ... }:
449 { services.xserver.enable = true;
450 services.xserver.desktopManager.xfce.enable = true;
451 });
452
453 gnome = makeClosure ({ ... }:
454 { services.xserver.enable = true;
455 services.xserver.displayManager.gdm.enable = true;
456 services.xserver.desktopManager.gnome.enable = true;
457 });
458
459 pantheon = makeClosure ({ ... }:
460 { services.xserver.enable = true;
461 services.xserver.desktopManager.pantheon.enable = true;
462 });
463
464 deepin = makeClosure ({ ... }:
465 { services.xserver.enable = true;
466 services.xserver.displayManager.lightdm.enable = true;
467 services.xserver.desktopManager.deepin.enable = true;
468 });
469
470 # Linux/Apache/PostgreSQL/PHP stack.
471 lapp = makeClosure ({ pkgs, ... }:
472 { services.httpd.enable = true;
473 services.httpd.adminAddr = "foo@example.org";
474 services.httpd.enablePHP = true;
475 services.postgresql.enable = true;
476 services.postgresql.package = pkgs.postgresql;
477 });
478 };
479}