Merge pull request #89523 from Mic92/rust-docs
buildRustPackage: add documentation on how to create cargo.lock patches
This commit is contained in:
commit
685f06c193
|
@ -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
|
## Compiling Rust crates using Nix instead of Cargo
|
||||||
|
|
||||||
### Simple operation
|
### Simple operation
|
||||||
|
|
|
@ -130,6 +130,7 @@ stdenv.mkDerivation (args // {
|
||||||
# give a friendlier error msg.
|
# give a friendlier error msg.
|
||||||
if ! [ -e $srcLockfile ]; then
|
if ! [ -e $srcLockfile ]; then
|
||||||
echo "ERROR: Missing Cargo.lock from src. Expected to find it at: $srcLockfile"
|
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
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue