From 15d95c7b7451d3bfa2fec0389c02f3e8a9c35f60 Mon Sep 17 00:00:00 2001 From: K900 Date: Fri, 5 Apr 2024 08:56:21 +0300 Subject: [PATCH] nixos/qemu-vm: split up the "keep EFI variables from system image" logic --- nixos/modules/virtualisation/qemu-vm.nix | 9 ++++++++- nixos/tests/installer.nix | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/nixos/modules/virtualisation/qemu-vm.nix b/nixos/modules/virtualisation/qemu-vm.nix index 6f45c9b657c8..a8e5db4f8a5b 100644 --- a/nixos/modules/virtualisation/qemu-vm.nix +++ b/nixos/modules/virtualisation/qemu-vm.nix @@ -186,7 +186,7 @@ let NIX_EFI_VARS=$(readlink -f "''${NIX_EFI_VARS:-${config.system.name}-efi-vars.fd}") # VM needs writable EFI vars if ! test -e "$NIX_EFI_VARS"; then - ${if cfg.useBootLoader && cfg.useDefaultFilesystems then + ${if cfg.efi.keepVariables then # We still need the EFI var from the make-disk-image derivation # because our "switch-to-configuration" process might # write into it and we want to keep this data. @@ -905,6 +905,13 @@ in Defaults to OVMF. ''; }; + + keepVariables = mkOption { + type = types.bool; + default = cfg.useBootLoader; + defaultText = literalExpression "cfg.useBootLoader"; + description = "Whether to keep EFI variable values from the generated system image"; + }; }; virtualisation.tpm = { diff --git a/nixos/tests/installer.nix b/nixos/tests/installer.nix index 965e8a1ef5b8..7e835041eb39 100644 --- a/nixos/tests/installer.nix +++ b/nixos/tests/installer.nix @@ -513,6 +513,7 @@ let virtualisation.useBootLoader = true; virtualisation.useEFIBoot = isEfi; virtualisation.useDefaultFilesystems = false; + virtualisation.efi.keepVariables = false; virtualisation.fileSystems."/" = { device = "/dev/disk/by-label/this-is-not-real-and-will-never-be-used";