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;