From 877f80ac7e91d684857e2c940cdb3c423efa1833 Mon Sep 17 00:00:00 2001 From: Winter Date: Sat, 10 Sep 2022 21:12:06 -0400 Subject: [PATCH] fix prefetching when using the hash key --- lib/prefetcher.nix | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/prefetcher.nix b/lib/prefetcher.nix index 4df7184..a32a60f 100644 --- a/lib/prefetcher.nix +++ b/lib/prefetcher.nix @@ -34,7 +34,11 @@ let hashSupport = !isBuiltinFetcher || fetcherFunctionArgs ? hash; - fetcherHashArg = optionalAttrs hashSupport (singleAttr hashAlgo hash); + fetcherHashArg = + let + key = if hashSupport then "hash" else hashAlgo; + in + singleAttr key hash; # https://stackoverflow.com/questions/28666357/git-how-to-get-default-branch/54204231#54204231 gitHEAD = pkgs.writeScript "git-head.sh" '' @@ -45,7 +49,7 @@ let fetcherRevArg = url: { rev = exec [ gitHEAD url ]; }; prefetcherArgs = - let args = removeAttrs fetcher.args hashAlgos // fetcherArgs // fetcherHashArg; + let args = removeAttrs fetcher.args (hashAlgos ++ [ "hash" ]) // fetcherArgs // fetcherHashArg; in args // optionalAttrs (fetcherFunctionArgs ? rev && args.rev or "" == "") ( if fetcher.name == "fetchFromGitHub" && args ? owner && args ? repo then fetcherRevArg (fetcher (prefetcherArgs // { fetchSubmodules = true; })).url