mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 16:33:15 +00:00
fetchCrate: allow overriding registryDl
This will allow `rustPlatform.importCargoLock` to use `fetchCrate` directly instead of including its own implementation.
This commit is contained in:
parent
954cc08721
commit
545206f936
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
{ crateName ? args.pname
|
{ crateName ? args.pname
|
||||||
, pname ? null
|
, pname ? null
|
||||||
|
# The `dl` field of the registry's index configuration
|
||||||
|
# https://doc.rust-lang.org/cargo/reference/registry-index.html#index-configuration
|
||||||
|
, registryDl ? "https://crates.io/api/v1/crates"
|
||||||
, version
|
, version
|
||||||
, unpack ? true
|
, unpack ? true
|
||||||
, ...
|
, ...
|
||||||
@ -11,7 +14,7 @@ assert pname == null || pname == crateName;
|
|||||||
|
|
||||||
(if unpack then fetchzip else fetchurl) ({
|
(if unpack then fetchzip else fetchurl) ({
|
||||||
name = "${crateName}-${version}.tar.gz";
|
name = "${crateName}-${version}.tar.gz";
|
||||||
url = "https://crates.io/api/v1/crates/${crateName}/${version}/download";
|
url = "${registryDl}/${crateName}/${version}/download";
|
||||||
} // lib.optionalAttrs unpack {
|
} // lib.optionalAttrs unpack {
|
||||||
extension = "tar.gz";
|
extension = "tar.gz";
|
||||||
} // removeAttrs args [ "crateName" "pname" "version" "unpack" ])
|
} // removeAttrs args [ "crateName" "pname" "version" "unpack" ])
|
||||||
|
Loading…
Reference in New Issue
Block a user