lol

nixos/tests: add nixos-rebuild-install-bootloader

+76
+1
nixos/release-combined.nix
··· 97 97 (onSystems ["x86_64-linux"] "nixos.tests.installer.simpleUefiSystemdBoot") 98 98 (onSystems ["x86_64-linux"] "nixos.tests.installer.simple") 99 99 (onSystems ["x86_64-linux"] "nixos.tests.installer.swraid") 100 + (onSystems ["x86_64-linux"] "nixos.tests.nixos-rebuild-install-bootloader") 100 101 (onFullSupported "nixos.tests.ipv6") 101 102 (onFullSupported "nixos.tests.keymap.azerty") 102 103 (onFullSupported "nixos.tests.keymap.colemak")
+1
nixos/tests/all-tests.nix
··· 569 569 nix-serve-ssh = handleTest ./nix-serve-ssh.nix {}; 570 570 nixops = handleTest ./nixops/default.nix {}; 571 571 nixos-generate-config = handleTest ./nixos-generate-config.nix {}; 572 + nixos-rebuild-install-bootloader = handleTest ./nixos-rebuild-install-bootloader.nix {}; 572 573 nixos-rebuild-specialisations = handleTest ./nixos-rebuild-specialisations.nix {}; 573 574 nixpkgs = pkgs.callPackage ../modules/misc/nixpkgs/test.nix { inherit evalMinimalConfig; }; 574 575 node-red = handleTest ./node-red.nix {};
+73
nixos/tests/nixos-rebuild-install-bootloader.nix
··· 1 + import ./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") 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 + })
+1
pkgs/os-specific/linux/nixos-rebuild/default.nix
··· 32 32 33 33 # run some a simple installer tests to make sure nixos-rebuild still works for them 34 34 passthru.tests = { 35 + install-bootloader = nixosTests.nixos-rebuild-install-bootloader; 35 36 simple-installer = nixosTests.installer.simple; 36 37 specialisations = nixosTests.nixos-rebuild-specialisations; 37 38 };