From ef8ea67eaa15dca252efe273e4255f34a5d6d7e5 Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Thu, 27 Aug 2026 22:31:31 -0400 Subject: [PATCH] {qemu,vz}-vm: load registration from lower store Otherwise, if gc later decides to remove registration derivation from its store, consequent reboots will point to a missing registration file. (As of this patch, this is not fatal because registration service failure doesn't fail builder boot; a later patch in the series makes registration service required, making sure we never boot with db that is not populated.) --- nixos/modules/virtualisation/qemu-vm.nix | 7 ++++++- nixos/modules/virtualisation/vz-vm.nix | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/nixos/modules/virtualisation/qemu-vm.nix b/nixos/modules/virtualisation/qemu-vm.nix index a99dd8f2ec5e..88b9f08aefcf 100644 --- a/nixos/modules/virtualisation/qemu-vm.nix +++ b/nixos/modules/virtualisation/qemu-vm.nix @@ -351,6 +351,11 @@ let ''; regInfo = hostPkgs.closureInfo { rootPaths = config.virtualisation.additionalPaths; }; + regInfoPath = + if cfg.useNixStoreImage || cfg.mountHostNixStore then + "/nix/.ro-store/${baseNameOf regInfo}/registration" + else + "${regInfo}/registration"; # Use well-defined and persistent filesystem labels to identify block devices. rootFilesystemLabel = "nixos"; @@ -1314,7 +1319,7 @@ in mkIf cfg.directBoot.enable [ "-kernel \${NIXPKGS_QEMU_KERNEL_${sanitizeShellIdent config.system.name}:-${config.system.build.toplevel}/kernel}" "-initrd ${cfg.directBoot.initrd}" - ''-append "$(cat ${config.system.build.toplevel}/kernel-params) init=${config.system.build.toplevel}/init regInfo=${regInfo}/registration ${consoles} $QEMU_KERNEL_PARAMS"'' + ''-append "$(cat ${config.system.build.toplevel}/kernel-params) init=${config.system.build.toplevel}/init regInfo=${regInfoPath} ${consoles} $QEMU_KERNEL_PARAMS"'' ] ) (mkIf cfg.useEFIBoot [ diff --git a/nixos/modules/virtualisation/vz-vm.nix b/nixos/modules/virtualisation/vz-vm.nix index 4011545e3df4..d05d016bf256 100644 --- a/nixos/modules/virtualisation/vz-vm.nix +++ b/nixos/modules/virtualisation/vz-vm.nix @@ -14,6 +14,7 @@ let hostPkgs = cfg.host.pkgs; regInfo = hostPkgs.closureInfo { rootPaths = cfg.additionalPaths; }; + regInfoPath = "/nix/.ro-store/${baseNameOf regInfo}/registration"; # Host-built erofs store image, named by closure hash so only a changed guest rebuilds it. # A derivation is not an option: it would need the Linux builder this VM provides. @@ -31,7 +32,7 @@ let # Virtualization.framework offers a virtio console "console=hvc0" "init=${toplevel}/init" - "regInfo=${regInfo}/registration" + "regInfo=${regInfoPath}" ] ++ config.boot.kernelParams;