Overriding version on Rust based package

I’ve read and understood overrideAttrs and buildRustPackage - #2 by NobbZ

I’m in a need of overriding version in nixpkgs/pkgs/by-name/ya/yazi-unwrapped/package.nix at 314e12ba369ccdb9b352a4db26ff419f7c49fa84 · NixOS/nixpkgs · GitHub

But I see no simple way to use ordinary overrideAttrs on the encompassing/resulting stdenv derivation. What is the correct approach here? Redoing the buildRustPackage with wanted src instead of overriding its result seems like a way. But how to do so? Reading the nixpkgs source file(s) as text, patching it and then IFD and callPackage?

(pkgs.FOO.overrideAttrs (finalAttrs: prevAttrs:
        {
          cargoHash = ""; # build and replace this
          src = pkgs.fetchBAR { ... }; # change fetcher
          version = "..."; # change this
          cargoDeps = pkgs.rustPlatform.fetchCargoTarball {
            inherit (finalAttrs) pname src version;
            hash = finalAttrs.cargoHash;
          };
        }
      ))

replace FOO, BAR, and version, cargoHash should stay empty until you build and get the hash.

1 Like