summary refs log tree commit diff
diff options
context:
space:
mode:
authorfigsoda <figsoda@pm.me>2023-03-13 21:51:23 -0400
committerfigsoda <figsoda@pm.me>2023-03-13 22:15:02 -0400
commit62327ff6a9cc828309c135ef370cdc13ebf9913c (patch)
treea248f7d3703accd080e3635ec2e215346c03de60
parentcce677256a7010580b16c95e0c5b11824fe0af53 (diff)
downloadnixpkgs-62327ff6a9cc828309c135ef370cdc13ebf9913c.tar
nixpkgs-62327ff6a9cc828309c135ef370cdc13ebf9913c.tar.gz
nixpkgs-62327ff6a9cc828309c135ef370cdc13ebf9913c.tar.bz2
nixpkgs-62327ff6a9cc828309c135ef370cdc13ebf9913c.tar.lz
nixpkgs-62327ff6a9cc828309c135ef370cdc13ebf9913c.tar.xz
nixpkgs-62327ff6a9cc828309c135ef370cdc13ebf9913c.tar.zst
nixpkgs-62327ff6a9cc828309c135ef370cdc13ebf9913c.zip
fetchCrate: add unpack option to use fetchurl instead of fetchzip
-rw-r--r--pkgs/build-support/rust/fetchcrate.nix8
1 files changed, 5 insertions, 3 deletions
diff --git a/pkgs/build-support/rust/fetchcrate.nix b/pkgs/build-support/rust/fetchcrate.nix
index 53219b2d062..09f5e7805e1 100644
--- a/pkgs/build-support/rust/fetchcrate.nix
+++ b/pkgs/build-support/rust/fetchcrate.nix
@@ -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" ])