mirror of
https://github.com/ipetkov/crane.git
synced 2024-11-26 09:08:57 +03:00
29 lines
586 B
Nix
29 lines
586 B
Nix
|
{ lib
|
||
|
}:
|
||
|
|
||
|
# https://doc.rust-lang.org/cargo/reference/registries.html
|
||
|
{ dl
|
||
|
, indexUrl
|
||
|
}:
|
||
|
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";
|
||
|
|
||
|
registryPrefix = "registry+";
|
||
|
registryIndexUrl =
|
||
|
if lib.hasPrefix registryPrefix indexUrl
|
||
|
then indexUrl
|
||
|
else "${registryPrefix}${indexUrl}";
|
||
|
in
|
||
|
{
|
||
|
"${registryIndexUrl}" = fullDownloadUrl;
|
||
|
}
|