summary refs log tree commit diff
path: root/doc/languages-frameworks
diff options
context:
space:
mode:
authorDaniël de Kok <me@danieldk.eu>2021-02-15 07:06:31 +0100
committerDaniël de Kok <me@danieldk.eu>2021-02-15 07:06:31 +0100
commitd92396039df6cf4c609cf1be47d0802496560e17 (patch)
tree0c2355ce904a0e93d887c4cc6327888fb7dc8345 /doc/languages-frameworks
parent2b37fe7a77b618ed259f55c73280312435d42aca (diff)
downloadnixpkgs-d92396039df6cf4c609cf1be47d0802496560e17.tar
nixpkgs-d92396039df6cf4c609cf1be47d0802496560e17.tar.gz
nixpkgs-d92396039df6cf4c609cf1be47d0802496560e17.tar.bz2
nixpkgs-d92396039df6cf4c609cf1be47d0802496560e17.tar.lz
nixpkgs-d92396039df6cf4c609cf1be47d0802496560e17.tar.xz
nixpkgs-d92396039df6cf4c609cf1be47d0802496560e17.tar.zst
nixpkgs-d92396039df6cf4c609cf1be47d0802496560e17.zip
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`.
Diffstat (limited to 'doc/languages-frameworks')
-rw-r--r--doc/languages-frameworks/rust.section.md27
1 files changed, 27 insertions, 0 deletions
diff --git a/doc/languages-frameworks/rust.section.md b/doc/languages-frameworks/rust.section.md
index 8f6db28ab4d..18d3cd9c926 100644
--- a/doc/languages-frameworks/rust.section.md
+++ b/doc/languages-frameworks/rust.section.md
@@ -80,6 +80,33 @@ The fetcher will verify that the `Cargo.lock` file is in sync with the `src`
 attribute, and fail the build if not. It will also will compress the vendor
 directory into a tar.gz archive.
 
+The tarball with vendored dependencies contains a directory with the
+package's `name`, which is normally composed of `pname` and
+`version`. This means that the vendored dependencies hash
+(`cargoSha256`/`cargoHash`) is dependent on the package name and
+version. The `cargoDepsName` attribute can be used to use another name
+for the directory of vendored dependencies. For example, the hash can
+be made invariant to the version by setting `cargoDepsName` to
+`pname`:
+
+```nix
+rustPlatform.buildRustPackage rec {
+  pname = "broot";
+  version = "1.2.0";
+
+  src = fetchCrate {
+    inherit pname version;
+    sha256 = "1mqaynrqaas82f5957lx31x80v74zwmwmjxxlbywajb61vh00d38";
+  };
+
+  cargoHash = "sha256-JmBZcDVYJaK1cK05cxx5BrnGWp4t8ca6FLUbvIot67s=";
+  cargoDepsName = pname;
+
+  # ...
+}
+```
+
+
 ### Cross compilation
 
 By default, Rust packages are compiled for the host platform, just like any