about summary refs log tree commit diff
path: root/pkgs/applications/networking/irc
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2018-07-25 17:36:41 +0100
committerAlyssa Ross <hi@alyssa.is>2018-07-25 17:49:00 +0100
commit8887e1f697d9e13ad277ca7d7054bc42c2459548 (patch)
treedc9ce624209f1cbc17aa288e0c485631dcfa4918 /pkgs/applications/networking/irc
parenta0383ffec82244cef7f72d71759c674f5bb30d97 (diff)
downloadnixlib-8887e1f697d9e13ad277ca7d7054bc42c2459548.tar
nixlib-8887e1f697d9e13ad277ca7d7054bc42c2459548.tar.gz
nixlib-8887e1f697d9e13ad277ca7d7054bc42c2459548.tar.bz2
nixlib-8887e1f697d9e13ad277ca7d7054bc42c2459548.tar.lz
nixlib-8887e1f697d9e13ad277ca7d7054bc42c2459548.tar.xz
nixlib-8887e1f697d9e13ad277ca7d7054bc42c2459548.tar.zst
nixlib-8887e1f697d9e13ad277ca7d7054bc42c2459548.zip
weechat: seperate weechat-unwrapped from wrapper
If I have a patch I want to apply to weechat, I can't do that with
overrideAttrs like I can with almost every other package, because that
only applies to the wrapper derivation. For other wrapped packages, one
can usually call the wrapper with any version of the derivation, but the
weechat derivation didn't expose a wrapper creation function.

Taking inspiration from other packages, particularly Firefox, I
extracted the wrapper into its own function, made the default weechat
derivation use that, and added weechat-unwrapped.

Now I can add my custom patch like this:

    (wrapWeechat
      (weechat-unwrapped.overrideAttrs (oldAttrs: {
        patches = [
          (fetchpatch {
            url = "https://github.com/weechat/weechat/commit/55767f5f116db3cb56cf85f52aa80feff45b6abf.patch?full_index=1";
            sha256 = "1pkcdsby57diqds1y5hhl0fr4i8j0zax32jb0gqd36siki3lza3d";
          })
        ];
      }))
      { configure =
        { availablePlugins, ... }:
        {
          plugins = with availablePlugins; [
            (python.withPackages (packages: with packages; [ potr websocket_client ]))
          ];
        };
      })

There is a small backward incompatibility here: previously, it was
possible to get an unwrapped weechat like this:

    weechat.override { configure = null; }

This didn't seem too important to keep around since it was also possible
to get an unwrapped weechat in a much more obvious way:

    weechat.unwrapped

I could probably make it so that the first way still worked, if that
behavior turns out to really have been important.
Diffstat (limited to 'pkgs/applications/networking/irc')
-rw-r--r--pkgs/applications/networking/irc/weechat/default.nix54
-rw-r--r--pkgs/applications/networking/irc/weechat/wrapper.nix57
2 files changed, 60 insertions, 51 deletions
diff --git a/pkgs/applications/networking/irc/weechat/default.nix b/pkgs/applications/networking/irc/weechat/default.nix
index 16162435e09a..82f9e28a13cc 100644
--- a/pkgs/applications/networking/irc/weechat/default.nix
+++ b/pkgs/applications/networking/irc/weechat/default.nix
@@ -2,7 +2,6 @@
 , ncurses, openssl, aspell, gnutls
 , zlib, curl, pkgconfig, libgcrypt
 , cmake, makeWrapper, libobjc, libresolv, libiconv
-, writeScriptBin # for withPlugins
 , asciidoctor # manpages
 , guileSupport ? true, guile
 , luaSupport ? true, lua5
@@ -10,9 +9,7 @@
 , pythonSupport ? true, pythonPackages
 , rubySupport ? true, ruby
 , tclSupport ? true, tcl
-, extraBuildInputs ? []
-, configure ? { availablePlugins, ... }: { plugins = builtins.attrValues availablePlugins; }
-, runCommand }:
+, extraBuildInputs ? [] }:
 
 let
   inherit (pythonPackages) python;
@@ -26,7 +23,7 @@ let
   ];
   enabledPlugins = builtins.filter (p: p.enabled) plugins;
 
-  weechat =
+  in
     assert lib.all (p: p.enabled -> ! (builtins.elem null p.buildInputs)) plugins;
     stdenv.mkDerivation rec {
       version = "2.1";
@@ -81,49 +78,4 @@ let
         maintainers = with stdenv.lib.maintainers; [ lovek323 garbas the-kenny lheckemann ];
         platforms = stdenv.lib.platforms.unix;
       };
-    };
-in if configure == null then weechat else
-  let
-    perlInterpreter = perl;
-    config = configure {
-      availablePlugins = let
-          simplePlugin = name: {pluginFile = "${weechat.${name}}/lib/weechat/plugins/${name}.so";};
-        in rec {
-          python = {
-            pluginFile = "${weechat.python}/lib/weechat/plugins/python.so";
-            withPackages = pkgsFun: (python // {
-              extraEnv = ''
-                export PYTHONHOME="${pythonPackages.python.withPackages pkgsFun}"
-              '';
-            });
-          };
-          perl = (simplePlugin "perl") // {
-            extraEnv = ''
-              export PATH="${perlInterpreter}/bin:$PATH"
-            '';
-          };
-          tcl = simplePlugin "tcl";
-          ruby = simplePlugin "ruby";
-          guile = simplePlugin "guile";
-          lua = simplePlugin "lua";
-        };
-      };
-
-    inherit (config) plugins;
-
-    pluginsDir = runCommand "weechat-plugins" {} ''
-      mkdir -p $out/plugins
-      for plugin in ${lib.concatMapStringsSep " " (p: p.pluginFile) plugins} ; do
-        ln -s $plugin $out/plugins
-      done
-    '';
-  in (writeScriptBin "weechat" ''
-    #!${stdenv.shell}
-    export WEECHAT_EXTRA_LIBDIR=${pluginsDir}
-    ${lib.concatMapStringsSep "\n" (p: lib.optionalString (p ? extraEnv) p.extraEnv) plugins}
-    exec ${weechat}/bin/weechat "$@"
-  '') // {
-    name = weechat.name;
-    unwrapped = weechat;
-    meta = weechat.meta;
-  }
+    }
diff --git a/pkgs/applications/networking/irc/weechat/wrapper.nix b/pkgs/applications/networking/irc/weechat/wrapper.nix
new file mode 100644
index 000000000000..5c557a8fd242
--- /dev/null
+++ b/pkgs/applications/networking/irc/weechat/wrapper.nix
@@ -0,0 +1,57 @@
+{ pythonPackages, perl, runCommand, lib, writeScriptBin, stdenv
+}:
+
+weechat:
+
+let
+  wrapper = {
+    configure ? { availablePlugins, ... }: { plugins = builtins.attrValues availablePlugins; }
+  }:
+
+  let
+    perlInterpreter = perl;
+    config = configure {
+      availablePlugins = let
+        simplePlugin = name: { pluginFile = "${weechat.${name}}/lib/weechat/plugins/${name}.so"; };
+        in rec {
+          python = {
+            pluginFile = "${weechat.python}/lib/weechat/plugins/python.so";
+            withPackages = pkgsFun: (python // {
+              extraEnv = ''
+                export PYTHONHOME="${pythonPackages.python.withPackages pkgsFun}"
+              '';
+            });
+          };
+          perl = (simplePlugin "perl") // {
+            extraEnv = ''
+              export PATH="${perlInterpreter}/bin:$PATH"
+            '';
+          };
+          tcl = simplePlugin "tcl";
+          ruby = simplePlugin "ruby";
+          guile = simplePlugin "guile";
+          lua = simplePlugin "lua";
+        };
+    };
+
+    inherit (config) plugins;
+
+    pluginsDir = runCommand "weechat-plugins" {} ''
+      mkdir -p $out/plugins
+      for plugin in ${lib.concatMapStringsSep " " (p: p.pluginFile) plugins} ; do
+        ln -s $plugin $out/plugins
+      done
+    '';
+
+  in (writeScriptBin "weechat" ''
+    #!${stdenv.shell}
+    export WEECHAT_EXTRA_LIBDIR=${pluginsDir}
+    ${lib.concatMapStringsSep "\n" (p: lib.optionalString (p ? extraEnv) p.extraEnv) plugins}
+    exec ${weechat}/bin/weechat "$@"
+  '') // {
+    name = weechat.name;
+    unwrapped = weechat;
+    meta = weechat.meta;
+  };
+
+in lib.makeOverridable wrapper