| 
									
										
										
										
											2018-11-11 17:41:11 +09:00
										 |  |  | { system ? builtins.currentSystem, | 
					
						
							|  |  |  |   config ? {}, | 
					
						
							|  |  |  |   pkgs ? import ../.. { inherit system config; } | 
					
						
							|  |  |  | }: | 
					
						
							| 
									
										
										
										
											2014-11-19 23:18:44 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-11 17:41:11 +09:00
										 |  |  | with import ../lib/testing.nix { inherit system pkgs; }; | 
					
						
							| 
									
										
										
										
											2014-11-19 23:18:44 +01:00
										 |  |  | with pkgs.lib; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | let | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   iso = | 
					
						
							|  |  |  |     (import ../lib/eval-config.nix { | 
					
						
							|  |  |  |       inherit system; | 
					
						
							|  |  |  |       modules = | 
					
						
							|  |  |  |         [ ../modules/installer/cd-dvd/installation-cd-minimal.nix | 
					
						
							|  |  |  |           ../modules/testing/test-instrumentation.nix | 
					
						
							|  |  |  |         ]; | 
					
						
							|  |  |  |     }).config.system.build.isoImage; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-22 13:21:33 +03:00
										 |  |  |   perlAttrs = params: "{ ${concatStringsSep ", " (mapAttrsToList (name: param: "${name} => ${builtins.toJSON param}") params)} }"; | 
					
						
							| 
									
										
										
										
											2018-02-27 19:58:23 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-15 18:56:53 +03:00
										 |  |  |   makeBootTest = name: extraConfig: | 
					
						
							|  |  |  |     let | 
					
						
							|  |  |  |       machineConfig = perlAttrs ({ qemuFlags = "-m 768"; } // extraConfig); | 
					
						
							|  |  |  |     in | 
					
						
							|  |  |  |       makeTest { | 
					
						
							|  |  |  |         inherit iso; | 
					
						
							|  |  |  |         name = "boot-" + name; | 
					
						
							|  |  |  |         nodes = { }; | 
					
						
							|  |  |  |         testScript = | 
					
						
							|  |  |  |           ''
 | 
					
						
							|  |  |  |             my $machine = createMachine(${machineConfig}); | 
					
						
							|  |  |  |             $machine->start; | 
					
						
							|  |  |  |             $machine->waitForUnit("multi-user.target"); | 
					
						
							|  |  |  |             $machine->succeed("nix verify -r --no-trust /run/current-system"); | 
					
						
							| 
									
										
										
										
											2016-05-25 10:21:14 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-15 18:56:53 +03:00
										 |  |  |             # Test whether the channel got installed correctly. | 
					
						
							|  |  |  |             $machine->succeed("nix-instantiate --dry-run '<nixpkgs>' -A hello"); | 
					
						
							|  |  |  |             $machine->succeed("nix-env --dry-run -iA nixos.procps"); | 
					
						
							| 
									
										
										
										
											2016-05-25 10:21:14 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-15 18:56:53 +03:00
										 |  |  |             $machine->shutdown; | 
					
						
							|  |  |  |           '';
 | 
					
						
							|  |  |  |       }; | 
					
						
							| 
									
										
										
										
											2016-05-25 10:21:14 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-15 18:56:53 +03:00
										 |  |  |   makeNetbootTest = name: extraConfig: | 
					
						
							|  |  |  |     let | 
					
						
							| 
									
										
										
										
											2016-04-08 13:53:27 +00:00
										 |  |  |       config = (import ../lib/eval-config.nix { | 
					
						
							|  |  |  |           inherit system; | 
					
						
							|  |  |  |           modules = | 
					
						
							|  |  |  |             [ ../modules/installer/netboot/netboot.nix | 
					
						
							|  |  |  |               ../modules/testing/test-instrumentation.nix | 
					
						
							|  |  |  |               { key = "serial"; } | 
					
						
							|  |  |  |             ]; | 
					
						
							|  |  |  |         }).config; | 
					
						
							| 
									
										
										
										
											2016-05-03 22:05:11 +02:00
										 |  |  |       ipxeBootDir = pkgs.symlinkJoin { | 
					
						
							|  |  |  |         name = "ipxeBootDir"; | 
					
						
							|  |  |  |         paths = [ | 
					
						
							|  |  |  |           config.system.build.netbootRamdisk | 
					
						
							|  |  |  |           config.system.build.kernel | 
					
						
							| 
									
										
										
										
											2019-07-15 18:56:53 +03:00
										 |  |  |           config.system.build.netbootIpxeScript | 
					
						
							| 
									
										
										
										
											2016-05-03 22:05:11 +02:00
										 |  |  |         ]; | 
					
						
							|  |  |  |       }; | 
					
						
							| 
									
										
										
										
											2019-07-15 18:56:53 +03:00
										 |  |  |       machineConfig = perlAttrs ({ | 
					
						
							| 
									
										
										
										
											2019-07-21 14:07:37 +09:00
										 |  |  |         qemuFlags = "-boot order=n -m 2000"; | 
					
						
							|  |  |  |         netBackendArgs = "tftp=${ipxeBootDir},bootfile=netboot.ipxe"; | 
					
						
							| 
									
										
										
										
											2019-07-15 18:56:53 +03:00
										 |  |  |       } // extraConfig); | 
					
						
							| 
									
										
										
										
											2016-04-08 13:53:27 +00:00
										 |  |  |     in | 
					
						
							|  |  |  |       makeTest { | 
					
						
							| 
									
										
										
										
											2019-07-15 18:56:53 +03:00
										 |  |  |         name = "boot-netboot-" + name; | 
					
						
							| 
									
										
										
										
											2016-04-08 13:53:27 +00:00
										 |  |  |         nodes = { }; | 
					
						
							|  |  |  |         testScript = | 
					
						
							|  |  |  |           ''
 | 
					
						
							| 
									
										
										
										
											2019-07-15 18:56:53 +03:00
										 |  |  |             my $machine = createMachine(${machineConfig}); | 
					
						
							| 
									
										
										
										
											2016-04-08 13:53:27 +00:00
										 |  |  |             $machine->start; | 
					
						
							|  |  |  |             $machine->waitForUnit("multi-user.target"); | 
					
						
							|  |  |  |             $machine->shutdown; | 
					
						
							|  |  |  |           '';
 | 
					
						
							|  |  |  |       }; | 
					
						
							| 
									
										
										
										
											2019-07-15 18:56:53 +03:00
										 |  |  | in { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     biosCdrom = makeBootTest "bios-cdrom" { | 
					
						
							| 
									
										
										
										
											2019-07-22 13:21:33 +03:00
										 |  |  |       cdrom = "${iso}/iso/${iso.isoName}"; | 
					
						
							| 
									
										
										
										
											2019-07-15 18:56:53 +03:00
										 |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     biosUsb = makeBootTest "bios-usb" { | 
					
						
							| 
									
										
										
										
											2019-07-22 13:21:33 +03:00
										 |  |  |       usb = "${iso}/iso/${iso.isoName}"; | 
					
						
							| 
									
										
										
										
											2019-07-15 18:56:53 +03:00
										 |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     uefiCdrom = makeBootTest "uefi-cdrom" { | 
					
						
							| 
									
										
										
										
											2019-07-22 13:21:33 +03:00
										 |  |  |       cdrom = "${iso}/iso/${iso.isoName}"; | 
					
						
							|  |  |  |       bios = "${pkgs.OVMF.fd}/FV/OVMF.fd"; | 
					
						
							| 
									
										
										
										
											2019-07-15 18:56:53 +03:00
										 |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     uefiUsb = makeBootTest "uefi-usb" { | 
					
						
							| 
									
										
										
										
											2019-07-22 13:21:33 +03:00
										 |  |  |       usb = "${iso}/iso/${iso.isoName}"; | 
					
						
							|  |  |  |       bios = "${pkgs.OVMF.fd}/FV/OVMF.fd"; | 
					
						
							| 
									
										
										
										
											2019-07-15 18:56:53 +03:00
										 |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     biosNetboot = makeNetbootTest "bios" {}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     uefiNetboot = makeNetbootTest "uefi" { | 
					
						
							| 
									
										
										
										
											2019-07-22 13:21:33 +03:00
										 |  |  |       bios = "${pkgs.OVMF.fd}/FV/OVMF.fd"; | 
					
						
							| 
									
										
										
										
											2019-07-15 18:56:53 +03:00
										 |  |  |       # Custom ROM is needed for EFI PXE boot. I failed to understand exactly why, because QEMU should still use iPXE for EFI. | 
					
						
							| 
									
										
										
										
											2019-07-22 13:21:33 +03:00
										 |  |  |       netFrontendArgs = "romfile=${pkgs.ipxe}/ipxe.efirom"; | 
					
						
							| 
									
										
										
										
											2019-07-15 18:56:53 +03:00
										 |  |  |     }; | 
					
						
							| 
									
										
										
										
											2016-05-03 22:05:11 +02:00
										 |  |  | } |