How to override when derivation uses buildGoModule?

Hi, as the title mentions it, I’m having some troubles to make a simple change for updating to a latest version of git-town.

The derivation definition is here:

And I can’t make it work with overrideAttrs. I was able to do it with the following (in home-manager):

    nixpkgs.overlays = [
      (self: super: {
        git-town = super.git-town.overrideDerivation (oldAttrs: {
          src = super.fetchFromGitHub {
            owner = "git-town";
            repo = "git-town";
            rev = "v16.0.0";
            hash =
              "sha256-aSnUJLoHq5byILuiNRrguawfBzL5as7u7ekAbuAmUgM="; 
          };
        });
      })
    ];

The problem is that I see a warning in using overrideDerivation. I’m suspecting that the problem with overrideAttrs is because of the buildGoModule but I can’t figure out. Any easy way to just change version and sha under:

buildGoModule rec {
  version = "15.1.0";

  src = fetchFromGitHub {
    hash = "sha256-e4lOyYQHsVOmOYKQ+3B2EdneWL8NEzboTlRKtO8Wdjg=";
  };
}

You probably have to add version as well since it’s used in the derivation. This works for me:

  nixpkgs.overlays = [
    (final: prev: {
      git-town = prev.git-town.overrideAttrs (
        finalAttrs: oldAttrs: {
          version = "16.0.0";
          src = final.fetchFromGitHub {
            owner = "git-town";
            repo = "git-town";
            rev = "v${finalAttrs.version}";
            hash = "sha256-aSnUJLoHq5byILuiNRrguawfBzL5as7u7ekAbuAmUgM=";
          };
        }
      );
    })
  ];

Ohh, wow, thanks, this indeeds works. So there isn’t a way to just update version and src.hash?
I was trying to check if there was any way to merge the oldAttrs.src like:

      (final: prev: {
        git-town = prev.git-town.overrideAttrs (oldAttrs: {
          version = "16.0.0";
          src = oldAttrs.src // {
            sha256 = "sha256-aSnUJLoHq5byILuiNRrguawfBzL5as7u7ekAbuAmUgM=";
          };
        });
      })

But I was getting the same previous version :thinking:

This seems to be working:

  nixpkgs.overlays = [
    (final: prev: {
      git-town = prev.git-town.overrideAttrs (oldAttrs: {
        version = "16.0.0";
        src = oldAttrs.src // {
          outputHash = "sha256-aSnUJLoHq5byILuiNRrguawfBzL5as7u7ekAbuAmUgM=";
        };
      });
    })
  ];

But I personally don’t know what the consequences are of just overriding the hash.

Actually, that “doesn’t mark an error”, but the final version is the previous 15.1.0:

$git-town --version
Git Town 15.1.0

My guess is that maybe oldAttrs.src.rev is using oldAttrs.version instead of finalAttrs like in the previous one you shared.

Thanks!

1 Like