buildRustPackage: add cargoDepsName attribute

The directory in the tarball of vendored dependencies contains `name`,
which is by default set to `${pname}-${version}`. This adds an
additional attribute to permit setting the name to something of the
user's choosing.

Since `cargoSha256`/`cargoHash` depend on the name of the directory of
vendored dependencies, `cargoDepsName` can be used to e.g. make the
hash invariant to the package version by setting `cargoDepsName =
pname`.
This commit is contained in:
Daniël de Kok
2021-02-15 07:06:31 +01:00
parent 2b37fe7a77
commit d92396039d
2 changed files with 32 additions and 1 deletions
+5 -1
View File
@@ -23,6 +23,9 @@
# Legacy hash
, cargoSha256 ? ""
# Name for the vendored dependencies tarball
, cargoDepsName ? name
, src ? null
, srcs ? null
, unpackPhase ? null
@@ -60,7 +63,8 @@ let
cargoDeps = if cargoVendorDir == null
then fetchCargoTarball ({
inherit name src srcs sourceRoot unpackPhase cargoUpdateHook;
inherit src srcs sourceRoot unpackPhase cargoUpdateHook;
name = cargoDepsName;
hash = cargoHash;
patches = cargoPatches;
sha256 = cargoSha256;