From a91e7da80da9d5987b609a20821a08ac15805065 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 24 May 2023 16:07:17 -0700 Subject: [PATCH] Don't set virtualisation.bootDevice in 23.05+ This missing default has been fixed in 23.05, so setting it here is no longer necessary. --- modules/qemu-vm-isolation.nix | 66 +++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/modules/qemu-vm-isolation.nix b/modules/qemu-vm-isolation.nix index a9bf0df..00dbac1 100644 --- a/modules/qemu-vm-isolation.nix +++ b/modules/qemu-vm-isolation.nix @@ -1,6 +1,6 @@ { config, lib, modulesPath, pkgs, ... }: let - inherit (lib) findSingle mkForce mkVMOverride; + inherit (lib) findSingle mkForce mkIf mkMerge mkVMOverride; lookupDriveDeviceName = driveName: driveList: (findSingle (drive: drive.name == driveName) @@ -12,41 +12,45 @@ let else "/nix/store"; -in { +in mkMerge [ + { - boot.initrd.availableKernelModules = [ "squashfs" ]; + boot.initrd.availableKernelModules = [ "squashfs" ]; - fileSystems = mkVMOverride { - "${storeMountPath}" = { - device = - lookupDriveDeviceName "nixstore" config.virtualisation.qemu.drives; - fsType = "squashfs"; - options = [ "ro" ]; - neededForBoot = true; - }; - }; - - system.build.squashfsStore = - pkgs.callPackage (modulesPath + "/../lib/make-squashfs.nix") { - storeContents = config.virtualisation.additionalPaths; + fileSystems = mkVMOverride { + "${storeMountPath}" = { + device = + lookupDriveDeviceName "nixstore" config.virtualisation.qemu.drives; + fsType = "squashfs"; + options = [ "ro" ]; + neededForBoot = true; + }; }; - virtualisation = { + system.build.squashfsStore = + pkgs.callPackage (modulesPath + "/../lib/make-squashfs.nix") { + storeContents = config.virtualisation.additionalPaths; + }; - # This should be the default. - bootDevice = lookupDriveDeviceName "root" config.virtualisation.qemu.drives; + virtualisation = { - sharedDirectories = mkForce { }; + sharedDirectories = mkForce { }; - qemu.drives = [{ - name = "nixstore"; - file = "${config.system.build.squashfsStore}"; - driveExtraOpts = { - format = "raw"; - read-only = "on"; - werror = "report"; - }; - }]; + qemu.drives = [{ + name = "nixstore"; + file = "${config.system.build.squashfsStore}"; + driveExtraOpts = { + format = "raw"; + read-only = "on"; + werror = "report"; + }; + }]; - }; -} + }; + } + (mkIf (lib.version < "23.05") { + # This should always have been the default. + virtualisation.bootDevice = + lookupDriveDeviceName "root" config.virtualisation.qemu.drives; + }) +] -- 2.44.1