fetchCrate: accept pname besides crateName

This enables short argument attrsets similar to fetchPypi:

src = fetchCrate {
  inherit pname version;
  sha256 = "02h8pikmk19ziqw9jgxxf7kjhnb3792vz9is446p1xfvlh4mzmyx";
};
This commit is contained in:
Daniël de Kok 2020-08-26 14:56:19 +02:00 committed by Peter Simons
parent bd8cc7086c
commit ba71fb305d

View File

@ -1,10 +1,13 @@
{ lib, fetchurl, unzip }:
{ crateName
{ crateName ? args.pname
, pname ? null
, version
, sha256
, ... } @ args:
assert pname == null || pname == crateName;
lib.overrideDerivation (fetchurl ({
name = "${crateName}-${version}.tar.gz";
@ -30,6 +33,6 @@ lib.overrideDerivation (fetchurl ({
fi
mv "$unpackDir/$fn" "$out"
'';
} // removeAttrs args [ "crateName" "version" ]))
} // removeAttrs args [ "crateName" "pname" "version" ]))
# Hackety-hack: we actually need unzip hooks, too
(x: {nativeBuildInputs = x.nativeBuildInputs++ [unzip];})