# 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 ];
- });
+final: prev:
+let
+ idempontenlyAddPatch =
+ pkg: patch:
+ if builtins.elem patch (pkg.drvAttrs.patches or [ ]) then
+ pkg
+ else
+ pkg.overrideAttrs (old: {
+ patches = (old.patches or [ ]) ++ [ patch ];
+ });
+in
+{
+ squashfsTools = idempontenlyAddPatch prev.squashfsTools ./squashfs-tools-label.patch;
+ util-linux = idempontenlyAddPatch prev.util-linux ./util-linux-squashfs-label.patch;
}