NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.29k stars 13.54k forks source link

`pidgin` does not like `plugins` override via overlays #162061

Open trofi opened 2 years ago

trofi commented 2 years ago

Describe the bug

I would prefer pidgin to always contain window_merge plugin. Here is my attempt:

$ nix build --impure --expr 'with import ./. { overlays = [(final: prev: { pidgin = prev.pidgin.override ({ plugins = [prev.pidgin-window-merge]; }); })]; }; pidgin'
error: infinite recursion encountered

       at //builtin/derivation.nix:19:19:
(use '--show-trace' to show detailed location information)

Before that I used pidgin-with-plugins attribute for the similar purpose.

I think recursion is a manifestation of confusion of pidgin being an SDK for plugins (and binary itself) and pidgin being a wrapper around SDK, pidgin binary and plugins. Should plugins use some other attribute?

Notify maintainers

@vcunat

One of the options would be to always use wrapper that embeds unwrapped pidgin:

--- a/pkgs/applications/networking/instant-messengers/pidgin-plugins/window-merge/default.nix
+++ b/pkgs/applications/networking/instant-messengers/pidgin-plugins/window-merge/default.nix
@@ -12 +12 @@ stdenv.mkDerivation rec {
-  buildInputs = [ pidgin ];
+  buildInputs = [ pidgin.unwrapped ];
diff --git a/pkgs/applications/networking/instant-messengers/pidgin/default.nix b/pkgs/applications/networking/instant-messengers/pidgin/default.nix
index bd6febeaf9d..0e6c56bde29 100644
--- a/pkgs/applications/networking/instant-messengers/pidgin/default.nix
+++ b/pkgs/applications/networking/instant-messengers/pidgin/default.nix
@@ -95,5 +95,4 @@ let unwrapped = stdenv.mkDerivation rec {
-in if plugins == [] then unwrapped
-    else callPackage ./wrapper.nix {
-      inherit plugins;
-      pidgin = unwrapped;
-    }
+in callPackage ./wrapper.nix {
+  inherit plugins;
+  pidgin = unwrapped;
+}
diff --git a/pkgs/applications/networking/instant-messengers/pidgin/wrapper.nix b/pkgs/applications/networking/instant-messengers/pidgin/wrapper.nix
index d5641c24fb0..12c532c90df 100644
--- a/pkgs/applications/networking/instant-messengers/pidgin/wrapper.nix
+++ b/pkgs/applications/networking/instant-messengers/pidgin/wrapper.nix
@@ -10,0 +11,3 @@ in symlinkJoin {
+  passthru = {
+    unwrapped = pidgin;
+  };

Or alternatively expose 2 attributes:

Shados commented 2 years ago

I also ran ran face-first into this problem with the pidgin-with-plugins deprecation. Having a separate -unwrapped attribute makes sense, and fits with other wrapped packages (e.g. firefox).

edanaher commented 2 years ago

Incidentally, I also ran into this using the old-style packageOverrides. For anyone else who runs into this before an fix is merged, a simple workaround is to name your overridden package pidgin-with-plugins while still overriding the pidgin package. in the original example in this issue:

$ nix build --impure --expr 'with import ./. { overlays = [(final: prev: { pidgin-with-plugins = prev.pidgin.override ({ plugins = [prev.pidgin-window-merge]; }); })]; }; pidgin-with-plugins'

Or what I actually have in my .nixpkgs/config.nix:

{
  ...
  packageOverrides = pkgs: rec {
    pidgin-with-plugins = pkgs.pidgin.override {
      plugins = [ pkgs.pidgin-otr pkgs.pidgin-osd pkgs.purple-hangouts pkgs.purple-googlechat ];
    };
}