at 18.09-beta 2.7 kB view raw
1{ system ? builtins.currentSystem }: 2 3with import ../lib/testing.nix { inherit system; }; 4with pkgs.lib; 5 6let 7 8 iso = 9 (import ../lib/eval-config.nix { 10 inherit system; 11 modules = 12 [ ../modules/installer/cd-dvd/installation-cd-minimal.nix 13 ../modules/testing/test-instrumentation.nix 14 ]; 15 }).config.system.build.isoImage; 16 17 makeBootTest = name: machineConfig: 18 makeTest { 19 inherit iso; 20 name = "boot-" + name; 21 nodes = { }; 22 testScript = 23 '' 24 my $machine = createMachine({ ${machineConfig}, qemuFlags => '-m 768' }); 25 $machine->start; 26 $machine->waitForUnit("multi-user.target"); 27 $machine->succeed("nix verify -r --no-trust /run/current-system"); 28 29 # Test whether the channel got installed correctly. 30 $machine->succeed("nix-instantiate --dry-run '<nixpkgs>' -A hello"); 31 $machine->succeed("nix-env --dry-run -iA nixos.procps"); 32 33 $machine->shutdown; 34 ''; 35 }; 36in { 37 38 biosCdrom = makeBootTest "bios-cdrom" '' 39 cdrom => glob("${iso}/iso/*.iso") 40 ''; 41 42 biosUsb = makeBootTest "bios-usb" '' 43 usb => glob("${iso}/iso/*.iso") 44 ''; 45 46 uefiCdrom = makeBootTest "uefi-cdrom" '' 47 cdrom => glob("${iso}/iso/*.iso"), 48 bios => '${pkgs.OVMF.fd}/FV/OVMF.fd' 49 ''; 50 51 uefiUsb = makeBootTest "uefi-usb" '' 52 usb => glob("${iso}/iso/*.iso"), 53 bios => '${pkgs.OVMF.fd}/FV/OVMF.fd' 54 ''; 55 56 netboot = let 57 config = (import ../lib/eval-config.nix { 58 inherit system; 59 modules = 60 [ ../modules/installer/netboot/netboot.nix 61 ../modules/testing/test-instrumentation.nix 62 { key = "serial"; } 63 ]; 64 }).config; 65 ipxeScriptDir = pkgs.writeTextFile { 66 name = "ipxeScriptDir"; 67 text = '' 68 #!ipxe 69 dhcp 70 kernel bzImage init=${config.system.build.toplevel}/init ${toString config.boot.kernelParams} console=ttyS0 71 initrd initrd 72 boot 73 ''; 74 destination = "/boot.ipxe"; 75 }; 76 ipxeBootDir = pkgs.symlinkJoin { 77 name = "ipxeBootDir"; 78 paths = [ 79 config.system.build.netbootRamdisk 80 config.system.build.kernel 81 ipxeScriptDir 82 ]; 83 }; 84 in 85 makeTest { 86 name = "boot-netboot"; 87 nodes = { }; 88 testScript = 89 '' 90 my $machine = createMachine({ qemuFlags => '-boot order=n -net nic,model=e1000 -net user,tftp=${ipxeBootDir}/,bootfile=boot.ipxe -m 2000M' }); 91 $machine->start; 92 $machine->waitForUnit("multi-user.target"); 93 $machine->shutdown; 94 ''; 95 }; 96}