summaryrefslogtreecommitdiffstats
path: root/nixos/tests/grub/efi.nix
blob: 953548bb24bb2afc6d94788b36d26a527647d146 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
{ lib, ... }:
{
  name = "grub-efi";

  meta = with lib.maintainers; {
    maintainers = [
      tomfitzhenry
      rnhmjoj
    ];
  };

  nodes.machine =
    { ... }:
    {
      virtualisation.useBootLoader = true;
      virtualisation.useEFIBoot = true;

      boot.loader.grub = {
        enable = true;
        efiSupport = true;
        device = "nodev";

        # Read GRUB from the serial console so its output can be matched
        # deterministically with wait_for_console_text, rather than via OCR.
        extraConfig = "serial; terminal_output serial";
      };
      boot.loader.efi.canTouchEfiVariables = true;
    };

  testScript = ''
    machine.start()

    with subtest("Enters GRUB"):
        machine.wait_for_console_text("GNU GRUB")

    with subtest("Loads kernel"):
        machine.wait_for_console_text("Linux version")

    with subtest("Reaches multi-user target"):
        machine.wait_for_unit("multi-user.target")

    with subtest("Boots via UEFI"):
        machine.succeed("test -d /sys/firmware/efi")
  '';
}