From 4ecb3e87958eb65ce8c5dc07ed3c5c1d79af98f0 Mon Sep 17 00:00:00 2001 From: Robin Stumm Date: Tue, 21 Sep 2021 13:48:25 +0200 Subject: doc: rust: document cargoLock.lockFileContents --- doc/languages-frameworks/rust.section.md | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'doc') diff --git a/doc/languages-frameworks/rust.section.md b/doc/languages-frameworks/rust.section.md index 71f197af53dad..09de57ff2bed7 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 = '' -- cgit 1.4.1