2017-12-12 10:54:01 +00:00
|
|
|
{ lib, fetchurl, unzip }:
|
|
|
|
|
2020-08-26 12:56:19 +00:00
|
|
|
{ crateName ? args.pname
|
|
|
|
, pname ? null
|
2017-12-12 10:54:01 +00:00
|
|
|
, version
|
|
|
|
, sha256
|
|
|
|
, ... } @ args:
|
|
|
|
|
2020-08-26 12:56:19 +00:00
|
|
|
assert pname == null || pname == crateName;
|
|
|
|
|
2017-12-12 10:54:01 +00:00
|
|
|
lib.overrideDerivation (fetchurl ({
|
|
|
|
|
|
|
|
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"
|
|
|
|
'';
|
2020-08-26 12:56:19 +00:00
|
|
|
} // removeAttrs args [ "crateName" "pname" "version" ]))
|
2017-12-12 10:54:01 +00:00
|
|
|
# Hackety-hack: we actually need unzip hooks, too
|
|
|
|
(x: {nativeBuildInputs = x.nativeBuildInputs++ [unzip];})
|