From: Scott Worley Date: Fri, 5 Jun 2026 18:29:27 +0000 (-0700) Subject: Put squashfs-label patch overlays in a separate file X-Git-Url: http://git.scottworley.com/nixos-qemu-vm-isolation/commitdiff_plain/1b39c55ce550354b408a3e017f2fec88b6f20a1b?ds=sidebyside;hp=328f87c12f4f1961a525d05ce435bfce4ab07e7c Put squashfs-label patch overlays in a separate file The util-linux patch in particular causes a lot of rebuilds / cache misses (linux kernel, llvm and hence clang, rustc, & ghc, etc.) in the guest. If the host is also building large stuff like the kernel locally for other reasons, this can result in two sets of large, local builds. :( Users sensitive to this may wish to harmonize the host and guest config to get back down to one set of large local builds. So we make the squashfs-label patches easy to also apply to the host, for those that wish to do so. --- diff --git a/modules/qemu-vm-isolation.nix b/modules/qemu-vm-isolation.nix index 5467f29..ed6800e 100644 --- a/modules/qemu-vm-isolation.nix +++ b/modules/qemu-vm-isolation.nix @@ -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; }}"; }; @@ -84,14 +82,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}" = { diff --git a/overlays/squashfs-labels/default.nix b/overlays/squashfs-labels/default.nix new file mode 100644 index 0000000..8a482d3 --- /dev/null +++ b/overlays/squashfs-labels/default.nix @@ -0,0 +1,12 @@ +# 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 +final: prev: { + squashfsTools = prev.squashfsTools.overrideAttrs (old: { + patches = (old.patches or [ ]) ++ [ ./squashfs-tools-label.patch ]; + }); + + util-linux = prev.util-linux.overrideAttrs (old: { + patches = (old.patches or [ ]) ++ [ ./util-linux-squashfs-label.patch ]; + }); +} diff --git a/modules/squashfs-tools-label.patch b/overlays/squashfs-labels/squashfs-tools-label.patch similarity index 100% rename from modules/squashfs-tools-label.patch rename to overlays/squashfs-labels/squashfs-tools-label.patch diff --git a/modules/util-linux-squashfs-label.patch b/overlays/squashfs-labels/util-linux-squashfs-label.patch similarity index 100% rename from modules/util-linux-squashfs-label.patch rename to overlays/squashfs-labels/util-linux-squashfs-label.patch