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