mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-11 08:13:04 +00:00
18 lines
442 B
Nix
18 lines
442 B
Nix
{ lib, fetchzip, fetchurl }:
|
|
|
|
{ crateName ? args.pname
|
|
, pname ? null
|
|
, version
|
|
, unpack ? true
|
|
, ...
|
|
} @ args:
|
|
|
|
assert pname == null || pname == crateName;
|
|
|
|
(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" "unpack" ])
|