diff options
author | Jörg Thalheim <Mic92@users.noreply.github.com> | 2020-06-05 11:45:35 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-05 11:45:35 +0100 |
commit | 685f06c193c1d6dc90edd44cda9fdbbe4e5dd04d (patch) | |
tree | 4f45384272564e6b08e7b6600f70e1a87a6ee79d | |
parent | a4ed97daf0a7d594b01fe5f19a95dc13d427c75d (diff) | |
parent | f0396574ab32b2d0b02469e7c2b1446623344f09 (diff) | |
download | nixlib-685f06c193c1d6dc90edd44cda9fdbbe4e5dd04d.tar nixlib-685f06c193c1d6dc90edd44cda9fdbbe4e5dd04d.tar.gz nixlib-685f06c193c1d6dc90edd44cda9fdbbe4e5dd04d.tar.bz2 nixlib-685f06c193c1d6dc90edd44cda9fdbbe4e5dd04d.tar.lz nixlib-685f06c193c1d6dc90edd44cda9fdbbe4e5dd04d.tar.xz nixlib-685f06c193c1d6dc90edd44cda9fdbbe4e5dd04d.tar.zst nixlib-685f06c193c1d6dc90edd44cda9fdbbe4e5dd04d.zip |
Merge pull request #89523 from Mic92/rust-docs
buildRustPackage: add documentation on how to create cargo.lock patches
-rw-r--r-- | doc/languages-frameworks/rust.section.md | 18 | ||||
-rw-r--r-- | pkgs/build-support/rust/default.nix | 1 |
2 files changed, 19 insertions, 0 deletions
diff --git a/doc/languages-frameworks/rust.section.md b/doc/languages-frameworks/rust.section.md index cec3373cbee6..f56bc5285b93 100644 --- a/doc/languages-frameworks/rust.section.md +++ b/doc/languages-frameworks/rust.section.md @@ -75,6 +75,24 @@ pkgs.rustPlatform.buildRustPackage { } ``` +### Building a crate with an absent or out-of-date Cargo.lock file + +`buildRustPackage` needs a `Cargo.lock` file to get all dependencies in the +source code in a reproducible way. If it is missing or out-of-date one can use +the `cargoPatches` attribute to update or add it. + +``` +{ lib, rustPlatform, fetchFromGitHub }: + +rustPlatform.buildRustPackage rec { + (...) + cargoPatches = [ + # a patch file to add/update Cargo.lock in the source code + ./add-Cargo.lock.patch + ]; +} +``` + ## Compiling Rust crates using Nix instead of Cargo ### Simple operation diff --git a/pkgs/build-support/rust/default.nix b/pkgs/build-support/rust/default.nix index a6b47930c274..795ce841ffb6 100644 --- a/pkgs/build-support/rust/default.nix +++ b/pkgs/build-support/rust/default.nix @@ -130,6 +130,7 @@ stdenv.mkDerivation (args // { # give a friendlier error msg. if ! [ -e $srcLockfile ]; then echo "ERROR: Missing Cargo.lock from src. Expected to find it at: $srcLockfile" + echo "Hint: You can use the cargoPatches attribute to add a Cargo.lock manually to the build." exit 1 fi |