mirror of
https://github.com/ipetkov/crane.git
synced 2024-11-26 09:08:57 +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>
33 lines
667 B
Nix
33 lines
667 B
Nix
{ lib
|
|
}:
|
|
|
|
# https://doc.rust-lang.org/cargo/reference/registries.html
|
|
{ dl
|
|
, indexUrl
|
|
, registryPrefix ? "registry+"
|
|
, fetchurlExtraArgs ? { }
|
|
}:
|
|
let
|
|
matches = m: builtins.match ".*${lib.escapeRegex m}.*" dl;
|
|
hasMarker = lib.any (m: null != matches m) [
|
|
"{crate}"
|
|
"{version}"
|
|
"{prefix}"
|
|
"{lowerprefix}"
|
|
"{sha256-checksum}"
|
|
];
|
|
|
|
fullDownloadUrl = if hasMarker then dl else "${dl}/{crate}/{version}/download";
|
|
|
|
registryIndexUrl =
|
|
if lib.hasPrefix registryPrefix indexUrl
|
|
then indexUrl
|
|
else "${registryPrefix}${indexUrl}";
|
|
in
|
|
{
|
|
"${registryIndexUrl}" = {
|
|
inherit fetchurlExtraArgs;
|
|
downloadUrl = fullDownloadUrl;
|
|
};
|
|
}
|