Avoid infinite recursion in overlays

I’m trying to write an overlay in my configuration.nix for pidgin. The purpose of the overlay is to add plugins to it’s search paths. pidgin/default.nix starts (sort of) this way:

# ...
let unwrapped = stdenv.mkDerivation rec {
  # ...

And it ends this way:

    # ...
    platforms = platforms.linux;
    maintainers = [ maintainers.vcunat ];
  };
};

in if plugins == [] then unwrapped
    else import ./wrapper.nix {
      inherit makeWrapper symlinkJoin plugins;
      pidgin = unwrapped;
    }

And I wrote:

      # Add plugins to pidgin
      (
        self: super: {
          pidgin = super.pidgin.override {
            plugins = [
              super.pidgin-latex
              super.purple-matrix
              super.toxprpl
              super.telegram-purple
            ];
          };
        }
      )

And I tried using instead of just super. the following:

  • self.pidgin-bar
  • (self.pidgin-bar.override { pidgin = self.pidgin })
  • (super.pidgin-foo.override { pidgin = self.pidgin })

And all options failed with:

unpacking channels...
building Nix...
building the system configuration...
error: infinite recursion encountered, at undefined position
(use '--show-trace' to show detailed location information)

Is it me or is it impossible to overlay pidgin/default.nix with the way it’s currently designed / written?

It wouldn’t be a problem for me to Fix this but I’m just wondering if I’m missing something or perhaps that wasn’t the author’s intention… Pinging @vcunat.

Maybe use another attr name, e.g. pidgin-with-plugins.
But I agree that this is not a preferable way.

I guess that’d work but I’d like that modified pidgin to be used as a dependency for telepathy-haze which requires pidgin as a dependency. I’d like to avoid having to override telepathy-haze (e.g) as well - just because gets pidgin as a build input.

The problem is that the plugins themselves depend on pidgin, so if you override pidgin and populate it with plugins you create a plugin -> pidgin -> plugin loop.