{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.)
This commit is contained in:
Ihar Hrachyshka
2026-08-27 22:31:31 -04:00
parent 2abbaae08a
commit ef8ea67eaa
2 changed files with 8 additions and 2 deletions

View File

@@ -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 [

View File

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