"error: attribute 'override' missing" in overlay in flake

Hi!

I am running into this behaviour that I am struggling to understand when trying to override a part of a package that is stiched into my configuration from a flake.

In my Nix flake, I am importing an external packaged called hugin which exposes a Go package.
In the upstream repo, it is built with pkgs.buildGoModule;, but it requires a specific go version. I am trying to override this external buildGoModule with buildGo123Module but am having a hard time doing so.

In my flake.nix, I am adding this package like this:

{
  nixpkgs = {
    overlays = [
  (_: prev: {
    go = prev.go_1_23;
    buildGoModules = prev.buildGo123Modules;
    hugin = hugin.packages."${prev.system}".hugin;
  })
];
  };
}

This works fine, and I now have a package available called hugin, however, when I try to do an override on this package:

{
  nixpkgs = {
    overlays = [
  (_: prev: {
    go = prev.go_1_23;
    buildGoModules = prev.buildGo123Modules;
    hugin = hugin.packages."${prev.system}".hugin.override {
      buildGoModule = prev.buildGo123Module;
    };
  })
];
  };
}

I am getting error: attribute 'override' missing which puzzles me, I dont understand exactly why this doesnt work. I’ve tried a variaty of formats and syntaxes, but not managed.

Any hint would be useful!

Thank you!

You didn’t use callPackage in the hugin flake, so there’s nothing to override. See Package parameters and overrides with callPackage — nix.dev documentation

And of course you will need to have an arg called buildGoModule in order to override it.

PS you should prefer final over prev whenever possible (unless it would cause infrec to use final, then you must use prev).

ah Thank you! that did it, it makes sense!

For others, in the upstream (imported) hugin repo, I changed from only calling buildGoModule to:

      hugin = pkgs.callPackage ({buildGoModule}:
          buildGoModule {
            pname = "hugin";
            version = huginVersion;
            src = pkgs.nix-gitignore.gitignoreSource [] ./.;

            buildInputs = [huginElm];

            patchPhase = ''
              cp -r ${huginElm} dist
            '';

            vendorHash = "sha256-rZ5CJW9iRi7Ozhg/cBCyByIqlKYLw1GtgGWiE3iTtDE=";
          }) {};