aboutsummaryrefslogtreecommitdiff
path: root/nixpkgs/pkgs/build-support/rust/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/build-support/rust/default.nix')
-rw-r--r--nixpkgs/pkgs/build-support/rust/default.nix19
1 files changed, 19 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/build-support/rust/default.nix b/nixpkgs/pkgs/build-support/rust/default.nix
index 4634d32f6ac..27601e481c6 100644
--- a/nixpkgs/pkgs/build-support/rust/default.nix
+++ b/nixpkgs/pkgs/build-support/rust/default.nix
@@ -13,6 +13,9 @@
, cargoUpdateHook ? ""
, cargoDepsHook ? ""
, cargoBuildFlags ? []
+, # Set to true to verify if the cargo dependencies are up to date.
+ # This will change the value of cargoSha256.
+ verifyCargoDeps ? false
, buildType ? "release"
, meta ? {}
@@ -26,6 +29,7 @@ let
cargoDeps = if cargoVendorDir == null
then fetchcargo {
inherit name src srcs sourceRoot cargoUpdateHook;
+ copyLockfile = verifyCargoDeps;
patches = cargoPatches;
sha256 = cargoSha256;
}
@@ -95,6 +99,21 @@ stdenv.mkDerivation (args // {
unset cargoDepsCopy
export RUST_LOG=${logLevel}
+ '' + stdenv.lib.optionalString verifyCargoDeps ''
+ if ! diff source/Cargo.lock $cargoDeps/Cargo.lock ; then
+ echo
+ echo "ERROR: cargoSha256 is out of date."
+ echo
+ echo "Cargo.lock is not the same in $cargoDeps."
+ echo
+ echo "To fix the issue:"
+ echo '1. Use "1111111111111111111111111111111111111111111111111111" as the cargoSha256 value'
+ echo "2. Build the derivation and wait it to fail with a hash mismatch"
+ echo "3. Copy the 'got: sha256:' value back into the cargoSha256 field"
+ echo
+
+ exit 1
+ fi
'' + (args.postUnpack or "");
configurePhase = args.configurePhase or ''