diff options
author | figsoda <figsoda@pm.me> | 2022-11-03 12:33:27 -0400 |
---|---|---|
committer | figsoda <figsoda@pm.me> | 2022-11-03 12:33:27 -0400 |
commit | 9508a4ac68b3818631ae644e9c0beea597fc9dcf (patch) | |
tree | 0aad97d0417deb85ba57b9434e43155d18089311 | |
parent | e5691c322f1682cf5c7cafb60e4bb3b0f96939d3 (diff) | |
download | nixpkgs-9508a4ac68b3818631ae644e9c0beea597fc9dcf.tar nixpkgs-9508a4ac68b3818631ae644e9c0beea597fc9dcf.tar.gz nixpkgs-9508a4ac68b3818631ae644e9c0beea597fc9dcf.tar.bz2 nixpkgs-9508a4ac68b3818631ae644e9c0beea597fc9dcf.tar.lz nixpkgs-9508a4ac68b3818631ae644e9c0beea597fc9dcf.tar.xz nixpkgs-9508a4ac68b3818631ae644e9c0beea597fc9dcf.tar.zst nixpkgs-9508a4ac68b3818631ae644e9c0beea597fc9dcf.zip |
fetchCrate: rewrite in terms of fetchzip
-rw-r--r-- | pkgs/build-support/rust/fetchcrate.nix | 35 |
1 files changed, 6 insertions, 29 deletions
diff --git a/pkgs/build-support/rust/fetchcrate.nix b/pkgs/build-support/rust/fetchcrate.nix index 4e6c38b032c..53219b2d062 100644 --- a/pkgs/build-support/rust/fetchcrate.nix +++ b/pkgs/build-support/rust/fetchcrate.nix @@ -1,38 +1,15 @@ -{ lib, fetchurl, unzip }: +{ lib, fetchzip }: { crateName ? args.pname , pname ? null , version -, sha256 -, ... } @ args: +, ... +} @ args: assert pname == null || pname == crateName; -lib.overrideDerivation (fetchurl ({ - +fetchzip ({ name = "${crateName}-${version}.tar.gz"; url = "https://crates.io/api/v1/crates/${crateName}/${version}/download"; - recursiveHash = true; - - downloadToTemp = true; - - postFetch = - '' - export PATH=${unzip}/bin:$PATH - - unpackDir="$TMPDIR/unpack" - mkdir "$unpackDir" - cd "$unpackDir" - - renamed="$TMPDIR/${crateName}-${version}.tar.gz" - mv "$downloadedFile" "$renamed" - unpackFile "$renamed" - fn=$(cd "$unpackDir" && echo *) - if [ -f "$unpackDir/$fn" ]; then - mkdir $out - fi - mv "$unpackDir/$fn" "$out" - ''; -} // removeAttrs args [ "crateName" "pname" "version" ])) -# Hackety-hack: we actually need unzip hooks, too -(x: {nativeBuildInputs = x.nativeBuildInputs++ [unzip];}) + extension = "tar.gz"; +} // removeAttrs args [ "crateName" "pname" "version" ]) |