summary refs log tree commit diff
path: root/doc/languages-frameworks
diff options
context:
space:
mode:
authorRobin Stumm <serverkorken@gmail.com>2021-09-21 13:48:25 +0200
committerRaphael Megzari <raphael@megzari.com>2021-09-22 20:32:19 +0900
commit4ecb3e87958eb65ce8c5dc07ed3c5c1d79af98f0 (patch)
treec91025690b534b0eddf9695d443b5401b48ac12b /doc/languages-frameworks
parent9dafa439bca3a9959428169f63a621e8ced6c977 (diff)
downloadnixpkgs-4ecb3e87958eb65ce8c5dc07ed3c5c1d79af98f0.tar
nixpkgs-4ecb3e87958eb65ce8c5dc07ed3c5c1d79af98f0.tar.gz
nixpkgs-4ecb3e87958eb65ce8c5dc07ed3c5c1d79af98f0.tar.bz2
nixpkgs-4ecb3e87958eb65ce8c5dc07ed3c5c1d79af98f0.tar.lz
nixpkgs-4ecb3e87958eb65ce8c5dc07ed3c5c1d79af98f0.tar.xz
nixpkgs-4ecb3e87958eb65ce8c5dc07ed3c5c1d79af98f0.tar.zst
nixpkgs-4ecb3e87958eb65ce8c5dc07ed3c5c1d79af98f0.zip
doc: rust: document cargoLock.lockFileContents
Diffstat (limited to 'doc/languages-frameworks')
-rw-r--r--doc/languages-frameworks/rust.section.md30
1 files changed, 26 insertions, 4 deletions
diff --git a/doc/languages-frameworks/rust.section.md b/doc/languages-frameworks/rust.section.md
index 71f197af53d..09de57ff2be 100644
--- a/doc/languages-frameworks/rust.section.md
+++ b/doc/languages-frameworks/rust.section.md
@@ -122,16 +122,38 @@ rustPlatform.buildRustPackage rec {
 
   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.
+
+Alternatively, `cargoLock.lockFileContents` can be set to a string of
+the contents of a `Cargo.lock` file, for example if you need to
+preprocess or generate the file as part of your build:
+
+
+```nix
+rustPlatform.buildRustPackage rec {
+  pname = "myproject";
+  version = "1.0.0";
+
+  cargoLock = let
+    fixupLockFile = 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 = ''