3
0
Fork 0
forked from mirrors/nixpkgs

fetchCrate: add unpack option to use fetchurl instead of fetchzip

This commit is contained in:
figsoda 2023-03-13 21:51:23 -04:00
parent cce677256a
commit 62327ff6a9

View file

@ -1,15 +1,17 @@
{ lib, fetchzip }:
{ lib, fetchzip, fetchurl }:
{ crateName ? args.pname
, pname ? null
, version
, unpack ? true
, ...
} @ args:
assert pname == null || pname == crateName;
fetchzip ({
(if unpack then fetchzip else fetchurl) ({
name = "${crateName}-${version}.tar.gz";
url = "https://crates.io/api/v1/crates/${crateName}/${version}/download";
} // lib.optionalAttrs unpack {
extension = "tar.gz";
} // removeAttrs args [ "crateName" "pname" "version" ])
} // removeAttrs args [ "crateName" "pname" "version" "unpack" ])