]> git.scottworley.com Git - nixos-qemu-vm-isolation/blobdiff - modules/qemu-vm-isolation.nix
Quantify squashfs' efficiency
[nixos-qemu-vm-isolation] / modules / qemu-vm-isolation.nix
index 5467f29a366de753f2714a6001762d2ae821999b..77db2f5f2476b84e6949f8c1e369838e62c06964 100644 (file)
@@ -49,17 +49,15 @@ let
       }/nix-store.img";
     squashfs =
       "${hostPkgs.callPackage (modulesPath + "/../lib/make-squashfs.nix") {
-        squashfsTools = hostPkgs.squashfsTools.overrideAttrs (old: {
-          # We patch in support for squashfs labels because
-          # https://github.com/NixOS/nixpkgs/pull/236656 requires filesystems to have labels and
-          # https://github.com/plougher/squashfs-tools/issues/59 squashfs doesn't support labels
-          patches = (old.patches or []) ++ [ ./squashfs-tools-label.patch ];
-          buildInputs = (old.buildInputs or []) ++ [ hostPkgs.makeWrapper ];
-          postInstall = (old.postInstall or "") + ''
-            wrapProgram "$out/bin/mksquashfs" \
-              --append-flags "-label nix-store"
-          '';
-        });
+        squashfsTools =
+          (hostPkgs.extend (import ../overlays/squashfs-labels)).squashfsTools.overrideAttrs
+            (old: {
+              buildInputs = (old.buildInputs or [ ]) ++ [ hostPkgs.makeWrapper ];
+              postInstall = (old.postInstall or "") + ''
+                wrapProgram "$out/bin/mksquashfs" \
+                  --append-flags "-label nix-store"
+              '';
+            });
         storeContents = config.virtualisation.additionalPaths;
       }}";
   };
@@ -70,9 +68,12 @@ in {
       description = ''
         What filesystem to use for the guest's Nix store.
 
-        erofs is more compact than ext4, but less mature.
-
         squashfs is best, but requires patches to set the filesystem label.
+
+        ext4 images are ~4x larger than squashfs images.
+
+        erofs images are only ~2.5x larger than squashfs images, but erofs is less mature than either squashfs or ext4.
+
       '';
       type = lib.types.enum [ "ext4" "erofs" "squashfs" ];
       default = "ext4";
@@ -84,14 +85,7 @@ in {
         optional (cfg.nixStoreFilesystemType == "erofs") "erofs";
 
       nixpkgs.overlays = optional (cfg.nixStoreFilesystemType == "squashfs")
-        (final: prev: {
-          util-linux = prev.util-linux.overrideAttrs (old: {
-            # We patch in support for squashfs labels because
-            # https://github.com/NixOS/nixpkgs/pull/236656 requires filesystems to have labels and
-            # https://github.com/plougher/squashfs-tools/issues/59 squashfs doesn't support labels
-            patches = (old.patches or [ ]) ++ [ ./util-linux-squashfs-label.patch ];
-          });
-        });
+        (import ../overlays/squashfs-labels);
 
       fileSystems = mkVMOverride {
         "${storeMountPath}" = {