I just tried to do this ~1h ago, and I had to use 3 layers of nested overrideAttrs, and temporarily set outputHashAlgo in order to get the right outputHash from the error message.
I have not tested this, but I suspect using the cargoHash from finalAttrs would be able to fix this.
--- a/pkgs/build-support/rust/build-rust-package/default.nix
+++ b/pkgs/build-support/rust/build-rust-package/default.nix
@@ -127,7 +127,7 @@ lib.extendMkDerivation {
;
name = cargoDepsName;
patches = cargoPatches;
- hash = args.cargoHash;
+ hash = finalAttrs.cargoHash;
}
// depsExtraArgs
);
It would also allow things like cargoPatches to be overrideAttrsed, where in the original change I had to specify patches twice.