Merge pull request #12 from hercules-ci/pure

Make tarball fetchers pure
This commit is contained in:
Eelco Dolstra 2021-07-29 13:15:37 +02:00 committed by GitHub
commit c6f3b63532
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -16,7 +16,11 @@ let
fetchTree = fetchTree =
info: info:
if info.type == "github" then if info.type == "github" then
{ outPath = fetchTarball "https://api.${info.host or "github.com"}/repos/${info.owner}/${info.repo}/tarball/${info.rev}"; { outPath =
fetchTarball
({ url = "https://api.${info.host or "github.com"}/repos/${info.owner}/${info.repo}/tarball/${info.rev}"; }
// (if info ? narHash then { sha256 = info.narHash; } else {})
);
rev = info.rev; rev = info.rev;
shortRev = builtins.substring 0 7 info.rev; shortRev = builtins.substring 0 7 info.rev;
lastModified = info.lastModified; lastModified = info.lastModified;
@ -43,12 +47,19 @@ let
narHash = info.narHash; narHash = info.narHash;
} }
else if info.type == "tarball" then else if info.type == "tarball" then
{ outPath = fetchTarball info.url; { outPath =
narHash = info.narHash; fetchTarball
({ inherit (info) url; }
// (if info ? narHash then { sha256 = info.narHash; } else {})
);
} }
else if info.type == "gitlab" then else if info.type == "gitlab" then
{ inherit (info) rev narHash lastModified; { inherit (info) rev narHash lastModified;
outPath = fetchTarball "https://${info.host or "gitlab.com"}/api/v4/projects/${info.owner}%2F${info.repo}/repository/archive.tar.gz?sha=${info.rev}"; outPath =
fetchTarball
({ url = "https://${info.host or "gitlab.com"}/api/v4/projects/${info.owner}%2F${info.repo}/repository/archive.tar.gz?sha=${info.rev}"; }
// (if info ? narHash then { sha256 = info.narHash; } else {})
);
shortRev = builtins.substring 0 7 info.rev; shortRev = builtins.substring 0 7 info.rev;
} }
else else