about summary refs log tree commit diff
path: root/pkgs/applications/networking/irc
diff options
context:
space:
mode:
authorNaïm Favier <n@monade.li>2022-10-09 16:26:53 +0200
committerNaïm Favier <n@monade.li>2022-10-09 21:55:38 +0200
commitcea0c62688fba15ecbe4b94541e30c0773320e9b (patch)
tree651fca03927bcdb3f39bc6320634d73671738101 /pkgs/applications/networking/irc
parent86b0bec1921f3a2a53018e90fb52423de91e37ac (diff)
weechat: add PHP support
Add PHP support, but do not include it in the wrapper by default, because
- it doesn't build on Darwin,
- it doubles the closure size,
- there are no official scripts written in PHP,
- it's probably broken: the [example PHP
  script](https://weechat.org/files/doc/stable/weechat_scripting.en.html#register_function)
  from the manual fails to load.

Enable build-time tests (except on Darwin as they don't build).

Remove `-DENABLE_JAVASCRIPT=OFF`, which was made the default upstream [a long time
ago](https://github.com/weechat/weechat/commit/340d6646a6371e2f224d392c9b1b44c8a20b5074).

Add myself as a maintainer.
Diffstat (limited to 'pkgs/applications/networking/irc')
-rw-r--r--pkgs/applications/networking/irc/weechat/default.nix21
-rw-r--r--pkgs/applications/networking/irc/weechat/wrapper.nix8
2 files changed, 21 insertions, 8 deletions
diff --git a/pkgs/applications/networking/irc/weechat/default.nix b/pkgs/applications/networking/irc/weechat/default.nix
index c84262d3db365..132504a20e164 100644
--- a/pkgs/applications/networking/irc/weechat/default.nix
+++ b/pkgs/applications/networking/irc/weechat/default.nix
@@ -1,20 +1,25 @@
 { stdenv, fetchurl, lib
 , ncurses, openssl, aspell, gnutls, gettext
 , zlib, curl, pkg-config, libgcrypt
-, cmake, makeWrapper, libobjc, libresolv, libiconv
+, cmake, libobjc, libresolv, libiconv
 , asciidoctor # manpages
+, enableTests ? !stdenv.isDarwin, cpputest
 , guileSupport ? true, guile
 , luaSupport ? true, lua5
 , perlSupport ? true, perl
 , pythonSupport ? true, python3Packages
 , rubySupport ? true, ruby
 , tclSupport ? true, tcl
+, phpSupport ? !stdenv.isDarwin, php, systemd, libxml2, pcre2, libargon2
 , extraBuildInputs ? []
-, fetchpatch
 }:
 
 let
   inherit (python3Packages) python;
+  php-embed = php.override {
+    embedSupport = true;
+    apxs2Support = false;
+  };
   plugins = [
     { name = "perl"; enabled = perlSupport; cmakeFlag = "ENABLE_PERL"; buildInputs = [ perl ]; }
     { name = "tcl"; enabled = tclSupport; cmakeFlag = "ENABLE_TCL"; buildInputs = [ tcl ]; }
@@ -22,6 +27,9 @@ let
     { name = "guile"; enabled = guileSupport; cmakeFlag = "ENABLE_GUILE"; buildInputs = [ guile ]; }
     { name = "lua"; enabled = luaSupport; cmakeFlag = "ENABLE_LUA"; buildInputs = [ lua5 ]; }
     { name = "python"; enabled = pythonSupport; cmakeFlag = "ENABLE_PYTHON3"; buildInputs = [ python ]; }
+    { name = "php"; enabled = phpSupport; cmakeFlag = "ENABLE_PHP"; buildInputs = [
+      php-embed.unwrapped.dev libxml2 pcre2 libargon2
+    ] ++ lib.optional stdenv.isLinux systemd; }
   ];
   enabledPlugins = builtins.filter (p: p.enabled) plugins;
 
@@ -42,15 +50,14 @@ let
 
       cmakeFlags = with lib; [
         "-DENABLE_MAN=ON"
-        "-DENABLE_DOC=OFF"         # TODO: Documentation fails to build, was deactivated to push through security update
-        "-DENABLE_JAVASCRIPT=OFF"  # Requires v8 <= 3.24.3, https://github.com/weechat/weechat/issues/360
-        "-DENABLE_PHP=OFF"
+        "-DENABLE_DOC=OFF"         # TODO(@ncfavier): Documentation fails to build, was deactivated to push through security update
+        "-DENABLE_TESTS=${if enableTests then "ON" else "OFF"}"
       ]
         ++ optionals stdenv.isDarwin ["-DICONV_LIBRARY=${libiconv}/lib/libiconv.dylib"]
         ++ map (p: "-D${p.cmakeFlag}=" + (if p.enabled then "ON" else "OFF")) plugins
         ;
 
-      nativeBuildInputs = [ cmake pkg-config makeWrapper asciidoctor ];
+      nativeBuildInputs = [ cmake pkg-config asciidoctor ] ++ lib.optional enableTests cpputest;
       buildInputs = with lib; [
           ncurses openssl aspell gnutls gettext zlib curl
           libgcrypt ]
@@ -85,7 +92,7 @@ let
           on https://nixos.org/nixpkgs/manual/#sec-weechat .
         '';
         license = lib.licenses.gpl3;
-        maintainers = with lib.maintainers; [ lovek323 ];
+        maintainers = with lib.maintainers; [ ncfavier ];
         platforms = lib.platforms.unix;
       };
     }
diff --git a/pkgs/applications/networking/irc/weechat/wrapper.nix b/pkgs/applications/networking/irc/weechat/wrapper.nix
index 5c06bb8517a29..353b7ffd6fda4 100644
--- a/pkgs/applications/networking/irc/weechat/wrapper.nix
+++ b/pkgs/applications/networking/irc/weechat/wrapper.nix
@@ -7,7 +7,11 @@ weechat:
 let
   wrapper = {
     installManPages ? true
-  , configure ? { availablePlugins, ... }: { plugins = builtins.attrValues availablePlugins; }
+  , configure ? { availablePlugins, ... }: {
+      # Do not include PHP by default, because it bloats the closure, doesn't
+      # build on Darwin, and there are no official PHP scripts.
+      plugins = builtins.attrValues (builtins.removeAttrs availablePlugins [ "php" ]);
+    }
   }:
 
   let
@@ -21,6 +25,7 @@ let
           '';
           withPackages = pkgsFun: (python // {
             extraEnv = ''
+              ${python.extraEnv}
               export PYTHONHOME="${python3Packages.python.withPackages pkgsFun}"
             '';
           });
@@ -40,6 +45,7 @@ let
         ruby = simplePlugin "ruby";
         guile = simplePlugin "guile";
         lua = simplePlugin "lua";
+        php = simplePlugin "php";
       };
 
     config = configure { inherit availablePlugins; };