From 62327ff6a9cc828309c135ef370cdc13ebf9913c Mon Sep 17 00:00:00 2001 From: figsoda Date: Mon, 13 Mar 2023 21:51:23 -0400 Subject: [PATCH] fetchCrate: add unpack option to use fetchurl instead of fetchzip --- pkgs/build-support/rust/fetchcrate.nix | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/build-support/rust/fetchcrate.nix b/pkgs/build-support/rust/fetchcrate.nix index 53219b2d0629..09f5e7805e16 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" ])