mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 06:53:01 +00:00
Merge pull request #199371 from figsoda/fetchCrate
fetchCrate: rewrite in terms of fetchzip
This commit is contained in:
commit
ff93685724
@ -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" ])
|
||||
|
Loading…
Reference in New Issue
Block a user