]> git.scottworley.com Git - nixos-qemu-vm-isolation/blobdiff - modules/qemu-vm-isolation.nix
Don't set virtualisation.bootDevice in 23.05+
[nixos-qemu-vm-isolation] / modules / qemu-vm-isolation.nix
index a9bf0dfc8177d28376c004c3aafd964ec5e19de6..00dbac139f81fc63edc05b71da92900e6560a85d 100644 (file)
@@ -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;
+  })
+]