Is it possible to override cargoSha256 in buildRustPackage?

Ok I wasn’t sure because I saw overrideAttrs was mentioned in the implementation of makeOverridable, but looking closer, I think all it’s doing is wrapping overrideAttrs such that the results of calling it is made overridable again.

It would be nice if functions like buildRustPackage had their own version of overrideAttrs. I guess we’d want a different name though.

Another option here is to use something like

self: super:

{
  ffsend = super.callPackage <nixpkgs/pkgs/tools/misc/ffsend> {
    rustPlatform = super.rustPlatform // {
      buildRustPackage = args:
        super.rustPlatform.buildRustPackage (args // {
          src = newSrcValue;
          cargoSha256 = newSha;
        });
    };
  };
}

This re-invokes the original package (whose path you need to know of course) but overrides the call to rustPlatform.buildRustPackage such that it modifies the args before passing them along.

7 Likes