2022-01-30 03:12:22 +03:00
|
|
|
{ lib
|
|
|
|
}:
|
|
|
|
|
|
|
|
# https://doc.rust-lang.org/cargo/reference/registries.html
|
|
|
|
{ dl
|
|
|
|
, indexUrl
|
2023-06-13 05:03:18 +03:00
|
|
|
, registryPrefix ? "registry+"
|
2022-11-21 03:22:13 +03:00
|
|
|
, fetchurlExtraArgs ? { }
|
2022-01-30 03:12:22 +03:00
|
|
|
}:
|
|
|
|
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
|
|
|
|
{
|
2022-11-21 03:22:13 +03:00
|
|
|
"${registryIndexUrl}" = {
|
|
|
|
inherit fetchurlExtraArgs;
|
|
|
|
downloadUrl = fullDownloadUrl;
|
|
|
|
};
|
2022-01-30 03:12:22 +03:00
|
|
|
}
|