@@ -80,6 +80,33 @@ The fetcher will verify that the `Cargo.lock` file is in sync with the `src`
8080attribute, and fail the build if not. It will also will compress the vendor
8181directory into a tar.gz archive.
8282
83+The tarball with vendored dependencies contains a directory with the
84+package's `name`, which is normally composed of `pname` and
85+`version`. This means that the vendored dependencies hash
86+(`cargoSha256`/`cargoHash`) is dependent on the package name and
87+version. The `cargoDepsName` attribute can be used to use another name
88+for the directory of vendored dependencies. For example, the hash can
89+be made invariant to the version by setting `cargoDepsName` to
90+`pname`:
91+
92+```nix
93+rustPlatform.buildRustPackage rec {
94+ pname = "broot";
95+ version = "1.2.0";
96+
97+ src = fetchCrate {
98+ inherit pname version;
99+ sha256 = "1mqaynrqaas82f5957lx31x80v74zwmwmjxxlbywajb61vh00d38";
100+ };
101+
102+ cargoHash = "sha256-JmBZcDVYJaK1cK05cxx5BrnGWp4t8ca6FLUbvIot67s=";
103+ cargoDepsName = pname;
104+
105+ # ...
106+}
107+```
108+
109+
83110### Cross compilation
84111
85112By default, Rust packages are compiled for the host platform, just like any