about summary refs log tree commit diff
path: root/doc
diff options
context:
space:
mode:
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>2021-09-22 12:02:01 +0000
committerGitHub <noreply@github.com>2021-09-22 12:02:01 +0000
commit2505488672158a0ff136df263bbc63abdfa347d3 (patch)
tree1d33192d665bf856246264377a1fd5f22e5104a5 /doc
parentf0955beaff44eeb94e4741b79cec1d158d648443 (diff)
parenta406978902baeea5140a4b5b21120da03d747278 (diff)
downloadnixlib-2505488672158a0ff136df263bbc63abdfa347d3.tar
nixlib-2505488672158a0ff136df263bbc63abdfa347d3.tar.gz
nixlib-2505488672158a0ff136df263bbc63abdfa347d3.tar.bz2
nixlib-2505488672158a0ff136df263bbc63abdfa347d3.tar.lz
nixlib-2505488672158a0ff136df263bbc63abdfa347d3.tar.xz
nixlib-2505488672158a0ff136df263bbc63abdfa347d3.tar.zst
nixlib-2505488672158a0ff136df263bbc63abdfa347d3.zip
Merge staging-next into staging
Diffstat (limited to 'doc')
-rw-r--r--doc/languages-frameworks/rust.section.md32
1 files changed, 27 insertions, 5 deletions
diff --git a/doc/languages-frameworks/rust.section.md b/doc/languages-frameworks/rust.section.md
index 71f197af53da..b2f045b11b32 100644
--- a/doc/languages-frameworks/rust.section.md
+++ b/doc/languages-frameworks/rust.section.md
@@ -116,22 +116,44 @@ is updated after every change to `Cargo.lock`. Therefore,
 a `Cargo.lock` file using the `cargoLock` argument. For example:
 
 ```nix
-rustPlatform.buildRustPackage rec {
+rustPlatform.buildRustPackage {
   pname = "myproject";
   version = "1.0.0";
 
   cargoLock = {
     lockFile = ./Cargo.lock;
-  }
+  };
 
   # ...
 }
 ```
 
 This will retrieve the dependencies using fixed-output derivations from
-the specified lockfile. Note that setting `cargoLock.lockFile` doesn't
-add a `Cargo.lock` to your `src`, and a `Cargo.lock` is still required
-to build a rust package. A simple fix is to use:
+the specified lockfile.
+
+One caveat is that `Cargo.lock` cannot be patched in the `patchPhase`
+because it runs after the dependencies have already been fetched. If
+you need to patch or generate the lockfile you can alternatively set
+`cargoLock.lockFileContents` to a string of its contents:
+
+```nix
+rustPlatform.buildRustPackage {
+  pname = "myproject";
+  version = "1.0.0";
+
+  cargoLock = let
+    fixupLockFile = path: f (builtins.readFile path);
+  in {
+    lockFileContents = fixupLockFile ./Cargo.lock;
+  };
+
+  # ...
+}
+```
+
+Note that setting `cargoLock.lockFile` or `cargoLock.lockFileContents`
+doesn't add a `Cargo.lock` to your `src`, and a `Cargo.lock` is still
+required to build a rust package. A simple fix is to use:
 
 ```nix
 postPatch = ''