2023-03-14 01:51:23 +00:00
|
|
|
{ lib, fetchzip, fetchurl }:
|
2017-12-12 10:54:01 +00:00
|
|
|
|
2020-08-26 12:56:19 +00:00
|
|
|
{ crateName ? args.pname
|
|
|
|
, pname ? null
|
2023-05-25 20:29:01 +00:00
|
|
|
# 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"
|
2017-12-12 10:54:01 +00:00
|
|
|
, version
|
2023-03-14 01:51:23 +00:00
|
|
|
, unpack ? true
|
2022-11-03 16:33:27 +00:00
|
|
|
, ...
|
|
|
|
} @ args:
|
2017-12-12 10:54:01 +00:00
|
|
|
|
2020-08-26 12:56:19 +00:00
|
|
|
assert pname == null || pname == crateName;
|
|
|
|
|
2023-03-14 01:51:23 +00:00
|
|
|
(if unpack then fetchzip else fetchurl) ({
|
2017-12-12 10:54:01 +00:00
|
|
|
name = "${crateName}-${version}.tar.gz";
|
2023-05-25 20:29:01 +00:00
|
|
|
url = "${registryDl}/${crateName}/${version}/download";
|
2023-03-14 01:51:23 +00:00
|
|
|
} // lib.optionalAttrs unpack {
|
2022-11-03 16:33:27 +00:00
|
|
|
extension = "tar.gz";
|
2023-05-28 17:20:03 +00:00
|
|
|
} // removeAttrs args [ "crateName" "pname" "registryDl" "version" "unpack" ])
|