2023-03-24 00:07:29 +00:00
|
|
|
{ lib, fetchzip, fetchurl }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-09-25 04:45:31 +00:00
|
|
|
{ crateName ? args.pname
|
|
|
|
, pname ? null
|
2020-04-24 23:36:52 +00:00
|
|
|
, version
|
2023-03-24 00:07:29 +00:00
|
|
|
, unpack ? true
|
2022-12-17 10:02:37 +00:00
|
|
|
, ...
|
|
|
|
} @ args:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-09-25 04:45:31 +00:00
|
|
|
assert pname == null || pname == crateName;
|
|
|
|
|
2023-03-24 00:07:29 +00:00
|
|
|
(if unpack then fetchzip else fetchurl) ({
|
2020-04-24 23:36:52 +00:00
|
|
|
name = "${crateName}-${version}.tar.gz";
|
|
|
|
url = "https://crates.io/api/v1/crates/${crateName}/${version}/download";
|
2023-03-24 00:07:29 +00:00
|
|
|
} // lib.optionalAttrs unpack {
|
2022-12-17 10:02:37 +00:00
|
|
|
extension = "tar.gz";
|
2023-03-24 00:07:29 +00:00
|
|
|
} // removeAttrs args [ "crateName" "pname" "version" "unpack" ])
|