From 328f87c12f4f1961a525d05ce435bfce4ab07e7c Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Thu, 4 Jun 2026 14:13:51 -0700 Subject: [PATCH] Use bcarnes' squashfs label patches instead of the dubious kludge --- .../libblkid-squashfs-nix-store-kludge.patch | 19 ------------------ modules/qemu-vm-isolation.nix | 20 +++++++++++++++---- 2 files changed, 16 insertions(+), 23 deletions(-) delete mode 100644 modules/libblkid-squashfs-nix-store-kludge.patch diff --git a/modules/libblkid-squashfs-nix-store-kludge.patch b/modules/libblkid-squashfs-nix-store-kludge.patch deleted file mode 100644 index de971f7..0000000 --- a/modules/libblkid-squashfs-nix-store-kludge.patch +++ /dev/null @@ -1,19 +0,0 @@ -# This dubious kludge results from -# https://github.com/NixOS/nixpkgs/pull/236656 requiring filesystems to have labels and -# https://github.com/plougher/squashfs-tools/issues/59 squashfs not supporting labels. -diff --git a/libblkid/src/superblocks/squashfs.c b/libblkid/src/superblocks/squashfs.c -index 4db842493..ed7465882 100644 ---- a/libblkid/src/superblocks/squashfs.c -+++ b/libblkid/src/superblocks/squashfs.c -@@ -45,6 +45,11 @@ static int probe_squashfs(blkid_probe pr, const struct blkid_idmag *mag) - - blkid_probe_sprintf_version(pr, "%u.%u", vermaj, vermin); - -+ { -+ char label_kludge[] = "nix-store"; -+ blkid_probe_set_label(pr, label_kludge, sizeof(label_kludge)); -+ } -+ - return 0; - } - diff --git a/modules/qemu-vm-isolation.nix b/modules/qemu-vm-isolation.nix index 69bacde..5467f29 100644 --- a/modules/qemu-vm-isolation.nix +++ b/modules/qemu-vm-isolation.nix @@ -49,6 +49,17 @@ 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" + ''; + }); storeContents = config.virtualisation.additionalPaths; }}"; }; @@ -61,8 +72,7 @@ in { erofs is more compact than ext4, but less mature. - squashfs support currently requires a dubious kludge that results in these - VMs not being able to mount any other squashfs volumes besides the nix store. + squashfs is best, but requires patches to set the filesystem label. ''; type = lib.types.enum [ "ext4" "erofs" "squashfs" ]; default = "ext4"; @@ -76,8 +86,10 @@ in { nixpkgs.overlays = optional (cfg.nixStoreFilesystemType == "squashfs") (final: prev: { util-linux = prev.util-linux.overrideAttrs (old: { - patches = (old.patches or [ ]) - ++ [ ./libblkid-squashfs-nix-store-kludge.patch ]; + # 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 ]; }); }); -- 2.51.2