about summary refs log tree commit diff
path: root/nixos/tests/systemd-boot.nix
diff options
context:
space:
mode:
authorDaniel Fullmer <danielrf12@gmail.com>2020-06-13 23:25:34 -0400
committerDaniel Fullmer <danielrf12@gmail.com>2020-07-06 12:07:50 -0700
commitb278a7d75ae96d1416791da99b778eb46018a9b2 (patch)
tree5f466608cd324554853558424391a0c8a422ea11 /nixos/tests/systemd-boot.nix
parent4d148268258732a216dc83327fe16073082d1063 (diff)
nixos/systemd-boot: test for EFI boot entry
Diffstat (limited to 'nixos/tests/systemd-boot.nix')
-rw-r--r--nixos/tests/systemd-boot.nix32
1 files changed, 32 insertions, 0 deletions
diff --git a/nixos/tests/systemd-boot.nix b/nixos/tests/systemd-boot.nix
index eba4729d6de84..7a663dd9b4284 100644
--- a/nixos/tests/systemd-boot.nix
+++ b/nixos/tests/systemd-boot.nix
@@ -11,6 +11,8 @@ let
     virtualisation.useBootLoader = true;
     virtualisation.useEFIBoot = true;
     boot.loader.systemd-boot.enable = true;
+    boot.loader.efi.canTouchEfiVariables = true;
+    environment.systemPackages = [ pkgs.efibootmgr ];
   };
 in
 {
@@ -31,6 +33,36 @@ in
       machine.succeed(
           "test -e /sys/firmware/efi/efivars/LoaderEntrySelected-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f"
       )
+
+      # "bootctl install" should have created an EFI entry
+      machine.succeed('efibootmgr | grep "Linux Boot Manager"')
+    '';
+  };
+
+  # Boot without having created an EFI entry--instead using default "/EFI/BOOT/BOOTX64.EFI"
+  fallback = makeTest {
+    name = "systemd-boot-fallback";
+    meta.maintainers = with pkgs.stdenv.lib.maintainers; [ danielfullmer ];
+
+    machine = { pkgs, lib, ... }: {
+      imports = [ common ];
+      boot.loader.efi.canTouchEfiVariables = mkForce false;
+    };
+
+    testScript = ''
+      machine.start()
+      machine.wait_for_unit("multi-user.target")
+
+      machine.succeed("test -e /boot/loader/entries/nixos-generation-1.conf")
+
+      # Ensure we actually booted using systemd-boot
+      # Magic number is the vendor UUID used by systemd-boot.
+      machine.succeed(
+          "test -e /sys/firmware/efi/efivars/LoaderEntrySelected-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f"
+      )
+
+      # "bootctl install" should _not_ have created an EFI entry
+      machine.fail('efibootmgr | grep "Linux Boot Manager"')
     '';
   };