at 24.11-pre 2.1 kB view raw
1import ./make-test-python.nix ({ pkgs, ... }: { 2 name = "nixos-rebuild-install-bootloader"; 3 4 nodes = { 5 machine = { lib, pkgs, ... }: { 6 imports = [ 7 ../modules/profiles/installation-device.nix 8 ../modules/profiles/base.nix 9 ]; 10 11 nix.settings = { 12 substituters = lib.mkForce [ ]; 13 hashed-mirrors = null; 14 connect-timeout = 1; 15 }; 16 17 system.includeBuildDependencies = true; 18 19 virtualisation = { 20 cores = 2; 21 memorySize = 2048; 22 }; 23 24 virtualisation.useBootLoader = true; 25 }; 26 }; 27 28 testScript = 29 let 30 configFile = pkgs.writeText "configuration.nix" '' 31 { lib, pkgs, ... }: { 32 imports = [ 33 ./hardware-configuration.nix 34 <nixpkgs/nixos/modules/testing/test-instrumentation.nix> 35 ]; 36 37 boot.loader.grub = { 38 enable = true; 39 device = "/dev/vda"; 40 forceInstall = true; 41 }; 42 43 documentation.enable = false; 44 } 45 ''; 46 47 in 48 '' 49 machine.start() 50 machine.succeed("udevadm settle") 51 machine.wait_for_unit("multi-user.target") 52 53 machine.succeed("nixos-generate-config") 54 machine.copy_from_host( 55 "${configFile}", 56 "/etc/nixos/configuration.nix", 57 ) 58 machine.succeed("nixos-rebuild switch") 59 60 # Need to run `nixos-rebuild` twice because the first run will install 61 # GRUB anyway 62 with subtest("Switch system again and install bootloader"): 63 result = machine.succeed("nixos-rebuild switch --install-bootloader 2>&1") 64 # install-grub2.pl messages 65 assert "updating GRUB 2 menu..." in result 66 assert "installing the GRUB 2 boot loader on /dev/vda..." in result 67 # GRUB message 68 assert "Installation finished. No error reported." in result 69 # at this point we've tested regression #262724, but haven't tested the bootloader itself 70 # TODO: figure out how to how to tell the test driver to start the bootloader instead of 71 # booting into the kernel directly. 72 ''; 73})