fetchCrate: rewrite in terms of fetchzip
This commit is contained in:
parent
e5691c322f
commit
9508a4ac68
1 changed files with 6 additions and 29 deletions
|
@ -1,38 +1,15 @@
|
||||||
{ lib, fetchurl, unzip }:
|
{ lib, fetchzip }:
|
||||||
|
|
||||||
{ crateName ? args.pname
|
{ crateName ? args.pname
|
||||||
, pname ? null
|
, pname ? null
|
||||||
, version
|
, version
|
||||||
, sha256
|
, ...
|
||||||
, ... } @ args:
|
} @ args:
|
||||||
|
|
||||||
assert pname == null || pname == crateName;
|
assert pname == null || pname == crateName;
|
||||||
|
|
||||||
lib.overrideDerivation (fetchurl ({
|
fetchzip ({
|
||||||
|
|
||||||
name = "${crateName}-${version}.tar.gz";
|
name = "${crateName}-${version}.tar.gz";
|
||||||
url = "https://crates.io/api/v1/crates/${crateName}/${version}/download";
|
url = "https://crates.io/api/v1/crates/${crateName}/${version}/download";
|
||||||
recursiveHash = true;
|
extension = "tar.gz";
|
||||||
|
} // removeAttrs args [ "crateName" "pname" "version" ])
|
||||||
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];})
|
|
||||||
|
|
Loading…
Reference in a new issue