summaryrefslogtreecommitdiff
path: root/pkgs/build-support/fetchpatch
diff options
context:
space:
mode:
authorIvan Trubach <mr.trubach@icloud.com>2024-07-01 17:01:44 +0300
committerIvan Trubach <mr.trubach@icloud.com>2024-07-01 18:09:00 +0300
commit6ed79156cef042b7dcfa206bafaa824d0a9ef638 (patch)
tree500af4488ccb2883164fff2ed4cdc613bd866d31 /pkgs/build-support/fetchpatch
parentfetchpatch2: fix hash in tests (diff)
downloadnixpkgs-6ed79156cef042b7dcfa206bafaa824d0a9ef638.tar.gz
fetchpatch: add patchutils to nativeBuildInputs
This change allows using programs from patchutils in postFetch.
Diffstat (limited to 'pkgs/build-support/fetchpatch')
-rw-r--r--pkgs/build-support/fetchpatch/default.nix12
1 files changed, 7 insertions, 5 deletions
diff --git a/pkgs/build-support/fetchpatch/default.nix b/pkgs/build-support/fetchpatch/default.nix
index a3ca6685147d..97b3661bb2d4 100644
--- a/pkgs/build-support/fetchpatch/default.nix
+++ b/pkgs/build-support/fetchpatch/default.nix
@@ -14,6 +14,7 @@
, includes ? []
, revert ? false
, postFetch ? ""
+, nativeBuildInputs ? []
, ...
}@args:
let
@@ -29,6 +30,7 @@ in
lib.throwIfNot (excludes == [] || includes == [])
"fetchpatch: cannot use excludes and includes simultaneously"
fetchurl ({
+ nativeBuildInputs = [ patchutils ] ++ nativeBuildInputs;
postFetch = ''
tmpfile="$TMPDIR/patch"
@@ -48,12 +50,12 @@ fetchurl ({
set -e
mv "$tmpfile" "$out"
- "${patchutils}/bin/lsdiff" \
+ lsdiff \
${lib.optionalString (relative != null) "-p1 -i ${lib.escapeShellArg relative}/'*'"} \
"$out" \
| sort -u | sed -e 's/[*?]/\\&/g' \
| xargs -I{} \
- "${patchutils}/bin/filterdiff" \
+ filterdiff \
--include={} \
--strip=${toString stripLen} \
${lib.optionalString (extraPrefix != null) ''
@@ -70,7 +72,7 @@ fetchurl ({
exit 1
fi
- ${patchutils}/bin/filterdiff \
+ filterdiff \
-p1 \
${builtins.toString (builtins.map (x: "-x ${lib.escapeShellArg x}") excludes)} \
${builtins.toString (builtins.map (x: "-i ${lib.escapeShellArg x}") includes)} \
@@ -84,10 +86,10 @@ fetchurl ({
exit 1
fi
'' + lib.optionalString revert ''
- ${patchutils}/bin/interdiff "$out" /dev/null > "$tmpfile"
+ interdiff "$out" /dev/null > "$tmpfile"
mv "$tmpfile" "$out"
'' + postFetch;
} // builtins.removeAttrs args [
"relative" "stripLen" "decode" "extraPrefix" "excludes" "includes" "revert"
- "postFetch"
+ "postFetch" "nativeBuildInputs"
])