mirror of
https://github.com/ipetkov/crane.git
synced 2024-11-26 09:08:57 +03:00
26 lines
620 B
Nix
26 lines
620 B
Nix
|
{ registryFromDownloadUrl, lib }:
|
||
|
|
||
|
{ indexUrl
|
||
|
, configSha256
|
||
|
, fetchurlExtraArgs ? { }
|
||
|
}:
|
||
|
|
||
|
let
|
||
|
slashTerminatedIndexUrl = if lib.hasSuffix "/" indexUrl then indexUrl else "${indexUrl}/";
|
||
|
configContents = builtins.readFile "${builtins.fetchurl {
|
||
|
url = "${slashTerminatedIndexUrl}config.json";
|
||
|
sha256 = configSha256;
|
||
|
}}";
|
||
|
|
||
|
config = builtins.fromJSON configContents;
|
||
|
dl = config.dl or (throw ''
|
||
|
registry config does not have a "dl" endpoint:
|
||
|
${configContents}
|
||
|
'');
|
||
|
in
|
||
|
registryFromDownloadUrl {
|
||
|
inherit dl fetchurlExtraArgs;
|
||
|
registryPrefix = "sparse+";
|
||
|
indexUrl = slashTerminatedIndexUrl;
|
||
|
}
|