1 { stdenv, fetchurl, lib
2 , ncurses, openssl, aspell, cjson, gnutls, gettext
3 , zlib, curl, pkg-config, libgcrypt
4 , cmake, libobjc, libresolv, libiconv
5 , asciidoctor # manpages
6 , enableTests ? !stdenv.hostPlatform.isDarwin, cpputest
7 , guileSupport ? true, guile
8 , luaSupport ? true, lua5
9 , perlSupport ? true, perl
10 , pythonSupport ? true, python3Packages
11 , rubySupport ? true, ruby
12 , tclSupport ? true, tcl
13 , phpSupport ? !stdenv.hostPlatform.isDarwin, php, systemd, libxml2, pcre2, libargon2
14 , extraBuildInputs ? []
18 inherit (python3Packages) python;
19 php-embed = php.override {
24 { name = "perl"; enabled = perlSupport; cmakeFlag = "ENABLE_PERL"; buildInputs = [ perl ]; }
25 { name = "tcl"; enabled = tclSupport; cmakeFlag = "ENABLE_TCL"; buildInputs = [ tcl ]; }
26 { name = "ruby"; enabled = rubySupport; cmakeFlag = "ENABLE_RUBY"; buildInputs = [ ruby ]; }
27 { name = "guile"; enabled = guileSupport; cmakeFlag = "ENABLE_GUILE"; buildInputs = [ guile ]; }
28 { name = "lua"; enabled = luaSupport; cmakeFlag = "ENABLE_LUA"; buildInputs = [ lua5 ]; }
29 { name = "python"; enabled = pythonSupport; cmakeFlag = "ENABLE_PYTHON3"; buildInputs = [ python ]; }
30 { name = "php"; enabled = phpSupport; cmakeFlag = "ENABLE_PHP"; buildInputs = [
31 php-embed.unwrapped.dev libxml2 pcre2 libargon2
32 ] ++ lib.optional stdenv.hostPlatform.isLinux systemd; }
34 enabledPlugins = builtins.filter (p: p.enabled) plugins;
37 assert lib.all (p: p.enabled -> ! (builtins.elem null p.buildInputs)) plugins;
38 stdenv.mkDerivation rec {
42 hardeningEnable = [ "pie" ];
45 url = "https://weechat.org/files/src/weechat-${version}.tar.xz";
46 hash = "sha256-KVYS+NwkryjJGCV9MBTrUzQqXQd9Xj2aPq3zA72P6/o=";
49 # Why is this needed? https://github.com/weechat/weechat/issues/2031
50 patches = lib.optional gettext.gettextNeedsLdflags ./gettext-intl.patch;
52 outputs = [ "out" "man" ] ++ map (p: p.name) enabledPlugins;
57 "-DENABLE_DOC_INCOMPLETE=ON"
58 "-DENABLE_TESTS=${if enableTests then "ON" else "OFF"}"
60 ++ lib.optionals stdenv.hostPlatform.isDarwin ["-DICONV_LIBRARY=${libiconv}/lib/libiconv.dylib"]
61 ++ map (p: "-D${p.cmakeFlag}=" + (if p.enabled then "ON" else "OFF")) plugins
64 nativeBuildInputs = [ cmake pkg-config asciidoctor ] ++ lib.optional enableTests cpputest;
65 buildInputs = [ ncurses openssl aspell cjson gnutls gettext zlib curl libgcrypt ]
66 ++ lib.optionals stdenv.hostPlatform.isDarwin [ libobjc libresolv ]
67 ++ lib.concatMap (p: p.buildInputs) enabledPlugins
70 env.NIX_CFLAGS_COMPILE = "-I${python}/include/${python.libPrefix}"
71 # Fix '_res_9_init: undefined symbol' error
72 + (lib.optionalString stdenv.hostPlatform.isDarwin "-DBIND_8_COMPAT=1 -lresolv");
75 for p in ${lib.concatMapStringsSep " " (p: p.name) enabledPlugins}; do
76 from=$out/lib/weechat/plugins/$p.so
77 to=''${!p}/lib/weechat/plugins/$p.so
78 mkdir -p $(dirname $to)
83 doInstallCheck = true;
84 installCheckPhase = ''
85 $out/bin/weechat --version
89 homepage = "https://weechat.org/";
90 changelog = "https://weechat.org/files/doc/weechat/ChangeLog-${version}.html";
91 description = "Fast, light and extensible chat client";
93 You can find more documentation as to how to customize this package
94 (e.g. adding python modules for scripts that would require them, etc.)
95 on https://nixos.org/nixpkgs/manual/#sec-weechat .
97 license = lib.licenses.gpl3;
98 maintainers = with lib.maintainers; [ ncfavier ];
99 mainProgram = "weechat";
100 platforms = lib.platforms.unix;