mirror of
https://github.com/ipetkov/crane.git
synced 2024-11-24 00:42:39 +03:00
31 lines
537 B
Nix
31 lines
537 B
Nix
|
{ lib
|
||
|
, registryFromDownloadUrl
|
||
|
}:
|
||
|
|
||
|
{ url
|
||
|
, rev
|
||
|
}:
|
||
|
|
||
|
let
|
||
|
index = builtins.fetchGit {
|
||
|
inherit url rev;
|
||
|
};
|
||
|
|
||
|
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 = url;
|
||
|
}
|