Is it possible to override cargoSha256 in buildRustPackage?

To clarify, https://github.com/NixOS/nixpkgs/pull/234651 alone doesn’t solve the “arguments not overridable via the <pkg>.overrideAttrs” issue.

To make cargoHash overridable in buildRustPackage-constructed packages, we need to utilize the fixed-point arguments support of the base build helper and refer to cargoHash as finalAttrs.cargoHash or finalAttrs.passthru.cargoHash to use the overridden version.

For rustPlatform.buildRustPackage, the base build helper is stdenv.mkDerivation, which already supports fixed-point arguments. While for build helpers that are not directly based on stdenv.mkDerivation, it would be helpful to refactor the base build helper with lib.extendMkDerivation.

We underwent a similar transition to make vendorHash overridable for buildGoModule-constructed packages:

A more complex transition for Python packages to use overrideAttrs instead of overridePythonAttrs is underway. Reviews and feedbacks are welcome:

4 Likes