diff --git a/pkgs/build-support/fetchpatch/default.nix b/pkgs/build-support/fetchpatch/default.nix index a6ddf132cd5b..a9bfac320fb8 100644 --- a/pkgs/build-support/fetchpatch/default.nix +++ b/pkgs/build-support/fetchpatch/default.nix @@ -5,7 +5,7 @@ # stripLen acts as the -p parameter when applying a patch. { lib, fetchurl, patchutils }: -{ stripLen ? 0, addPrefixes ? false, ... }@args: +{ stripLen ? 0, addPrefixes ? false, excludes ? [], ... }@args: fetchurl ({ postFetch = '' @@ -21,7 +21,10 @@ fetchurl ({ --addnewprefix=b/ \ ''} \ --clean "$out" > "$tmpfile" - mv "$tmpfile" "$out" + ${patchutils}/bin/filterdiff \ + -p1 \ + ${builtins.toString (builtins.map (x: "-x ${x}") excludes)} \ + "$tmpfile" > "$out" ${args.postFetch or ""} ''; -} // builtins.removeAttrs args ["stripLen" "addPrefixes"]) +} // builtins.removeAttrs args ["stripLen" "addPrefixes" "excludes"])