mirror of
https://github.com/ipetkov/crane.git
synced 2024-11-22 14:10:16 +03:00
75f7d715f8
With Cargo 1.68.0, sparse registries were made stable. With sparse registries, index metadata is stored in an HTTP api rather than in a git repository. As relevant to Crane, the relevant changes are mostly that registries do not always start with `registry+` and mostly start with `registry+` or `sparse+` depending on whether the registry is sparse or not. This PR adjusts the core of Crane to differentiate between `registry` and `sparse`, and adds a new sparse registry factory to make things easy. --------- Co-authored-by: Ivan Petkov <ivanppetkov@gmail.com>
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;
|
|
}
|