8ac5e011d6
GitOrigin-RevId: 2c3273caa153ee8eb5786bc8141b85b859e7efd7
35 lines
847 B
Nix
35 lines
847 B
Nix
{ lib, fetchurl, unzip }:
|
|
|
|
{ crateName
|
|
, version
|
|
, sha256
|
|
, ... } @ args:
|
|
|
|
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"
|
|
'';
|
|
} // removeAttrs args [ "crateName" "version" ]))
|
|
# Hackety-hack: we actually need unzip hooks, too
|
|
(x: {nativeBuildInputs = x.nativeBuildInputs++ [unzip];})
|