summary refs log tree commit diff
path: root/doc
diff options
context:
space:
mode:
authorBenjamin Hipple <bhipple@protonmail.com>2020-01-12 11:21:23 -0500
committerBenjamin Hipple <bhipple@protonmail.com>2020-02-10 10:17:29 -0500
commit2115a2037cb8337ccb09798c175733f1fc747ee3 (patch)
treeae36678ae1dfb15b8c9cd74229cb369a60ae7fe8 /doc
parentd9eb897edd8dfb7c65d8069197e3db5eeb537d69 (diff)
downloadnixpkgs-2115a2037cb8337ccb09798c175733f1fc747ee3.tar
nixpkgs-2115a2037cb8337ccb09798c175733f1fc747ee3.tar.gz
nixpkgs-2115a2037cb8337ccb09798c175733f1fc747ee3.tar.bz2
nixpkgs-2115a2037cb8337ccb09798c175733f1fc747ee3.tar.lz
nixpkgs-2115a2037cb8337ccb09798c175733f1fc747ee3.tar.xz
nixpkgs-2115a2037cb8337ccb09798c175733f1fc747ee3.tar.zst
nixpkgs-2115a2037cb8337ccb09798c175733f1fc747ee3.zip
fetchcargo: use flat tar.gz file for vendored src instead of recursive hash dir
This has several advantages:

1. It takes up less space on disk in-between builds in the nix store.
2. It uses less space in the binary cache for vendor derivation packages.
3. It uses less network traffic downloading from the binary cache.
4. It plays nicely with hashed mirrors like tarballs.nixos.org, which only
   substitute --flat hashes on single files (not recursive directory hashes).
5. It's consistent with how simple `fetchurl` src derivations work.
6. It provides a stronger abstraction between input src-package and output
   package, e.g., it's harder to accidentally depend on the src derivation at
   runtime by referencing something like `${src}/etc/index.html`. Likewise, in
   the store it's harder to get confused with something that is just there as a
   build-time dependency vs. a runtime dependency, since the build-time
   src dependencies are tarred up.

Disadvantages are:
1. It takes slightly longer to untar at the start of a build.

As currently implemented, this attaches the compacted vendor.tar.gz feature as a
rider on `verifyCargoDeps`, since both of them are relatively newly implemented
behavior that change the `cargoSha256`.

If this PR is accepted, I will push forward the remaining rust packages with a
series of treewide PRs to update the `cargoSha256`s.
Diffstat (limited to 'doc')
-rw-r--r--doc/languages-frameworks/rust.section.md21
1 files changed, 14 insertions, 7 deletions
diff --git a/doc/languages-frameworks/rust.section.md b/doc/languages-frameworks/rust.section.md
index 3332dff1eb0..6f0ec7c0514 100644
--- a/doc/languages-frameworks/rust.section.md
+++ b/doc/languages-frameworks/rust.section.md
@@ -37,7 +37,7 @@ rustPlatform.buildRustPackage rec {
   };
 
   cargoSha256 = "17ldqr3asrdcsh4l29m3b5r37r5d0b3npq1lrgjmxb6vlx6a36qh";
-  verifyCargoDeps = true;
+  legacyCargoFetcher = false;
 
   meta = with stdenv.lib; {
     description = "A fast line-oriented regex search tool, similar to ag and ack";
@@ -59,12 +59,19 @@ When the `Cargo.lock`, provided by upstream, is not in sync with the
 added in `cargoPatches` will also be prepended to the patches in `patches` at
 build-time.
 
-When `verifyCargoDeps` is set to `true`, the build will also verify that the
-`cargoSha256` is not out of date by comparing the `Cargo.lock` file in both the
-`cargoDeps` and `src`. Note that this option changes the value of `cargoSha256`
-since it also copies the `Cargo.lock` in it. To avoid breaking
-backward-compatibility this option is not enabled by default but hopefully will
-be in the future.
+Setting `legacyCargoFetcher` to `false` enables the following behavior:
+
+1. The `Cargo.lock` file is copied into the cargo vendor directory.
+2. At buildtime, `buildRustPackage` will ensure that the `src` and `cargoSha256`
+   are consistent. This avoids errors where one but not the other is updated.
+3. The builder will compress the vendored cargo src directory into a tar.gz file
+   for storage after vendoring, and decompress it before the build. This saves
+   disk space and enables hashed mirrors for Rust dependencies.
+
+Note that this option changes the value of `cargoSha256`, so it is currently
+defaulted to `false`. When updating a Rust package, please set it to `true`;
+eventually we will default this to true and update the remaining Rust packages,
+then delete the option from all individual Rust package expressions.
 
 ### Building a crate for a different target