Skip to content

Commit

Permalink
fix prefetching when using the hash key
Browse files Browse the repository at this point in the history
  • Loading branch information
winterqt committed Sep 11, 2022
1 parent a4773bf commit 877f80a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/prefetcher.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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" ''
Expand All @@ -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
Expand Down

0 comments on commit 877f80a

Please sign in to comment.