nixos/qemu-vm: split up the "keep EFI variables from system image" logic

This commit is contained in:
K900 2024-04-05 08:56:21 +03:00
parent 7b602cff5c
commit 15d95c7b74
2 changed files with 9 additions and 1 deletions

View file

@ -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 = {

View file

@ -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";