Skip to content

Commit

Permalink
fetchpatch: Allow using SRI hash instead of sha256
Browse files Browse the repository at this point in the history
  • Loading branch information
jtojnar committed Feb 14, 2020
1 parent 0acb6a5 commit d1d0961
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkgs/build-support/fetchpatch/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,17 @@ let
in
{ stripLen ? 0, extraPrefix ? null, excludes ? [], includes ? [], revert ? false, ... }@args:

let
tmpname =
if args ? hash then
# Make base-64 encoded SRI hash filename-safe using RFC 4648 §5
lib.replaceStrings [ "+" "/" "=" ] [ "-" "_" "" ] args.hash
else
args.sha256;
in
fetchurl ({
postFetch = ''
tmpfile="$TMPDIR/${args.sha256}"
tmpfile="$TMPDIR/${tmpname}"
if [ ! -s "$out" ]; then
echo "error: Fetched patch file '$out' is empty!" 1>&2
exit 1
Expand Down

0 comments on commit d1d0961

Please sign in to comment.