crane/lib/registryFromGitIndex.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

32 lines
607 B
Nix
Raw Normal View History

2022-10-24 02:20:22 +03:00
{ registryFromDownloadUrl
}:
{ indexUrl
, rev
, fetchurlExtraArgs ? { }
}:
let
index = builtins.fetchGit {
inherit rev;
url = indexUrl;
shallow = true;
};
configPath = "${index}/config.json";
configContents =
if builtins.pathExists configPath then
builtins.readFile configPath
else
throw "registry index is missing a config.json file";
config = builtins.fromJSON configContents;
dl = config.dl or (throw ''
registry config does not have a "dl" endpoint:
${configContents}
'');
in
registryFromDownloadUrl {
inherit dl indexUrl fetchurlExtraArgs;
}