From: Scott Worley Date: Wed, 24 May 2023 23:07:17 +0000 (-0700) Subject: Don't set virtualisation.bootDevice in 23.05+ X-Git-Url: http://git.scottworley.com/nixos-qemu-vm-isolation/commitdiff_plain/a91e7da80da9d5987b609a20821a08ac15805065 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. --- 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; + }) +]