Merge pull request #25274 from lheckemann/weechat-plugin-split

Weechat plugin split

authored by Frederik Rietdijk and committed by GitHub 4bd9b3b7 3ea077e6

+140 -62
+30
doc/package-notes.xml
··· 664 665 </section> 666 667 </chapter>
··· 664 665 </section> 666 667 + <section xml:id="sec-weechat"> 668 + <title>Weechat</title> 669 + <para> 670 + Weechat can currently be configured to include your choice of plugins. 671 + To make use of this functionality, install an expression that overrides its configuration such as 672 + <programlisting>weechat.override {configure = {availablePlugins, ...}: { 673 + plugins = with availablePlugins; [ python perl ]; 674 + } 675 + }</programlisting> 676 + </para> 677 + <para> 678 + The plugins currently available are <literal>python</literal>, 679 + <literal>perl</literal>, <literal>ruby</literal>, <literal>guile</literal>, 680 + <literal>tcl</literal> and <literal>lua</literal>. 681 + </para> 682 + <para> 683 + The python plugin allows the addition of extra libraries. For instance, 684 + the <literal>inotify.py</literal> script in weechat-scripts requires 685 + D-Bus or libnotify, and the <literal>fish.py</literal> script requires 686 + pycrypto. To use these scripts, use the <literal>python</literal> 687 + plugin's <literal>withPackages</literal> attribute: 688 + <programlisting>weechat.override {configure = {availablePlugins, ...}: { 689 + plugins = with availablePlugins; [ 690 + (python.withPackages (ps: with ps; [ pycrypto python-dbus ])) 691 + ]; 692 + } 693 + } 694 + </programlisting> 695 + </para> 696 + </section> 697 </chapter>
+110 -62
pkgs/applications/networking/irc/weechat/default.nix
··· 1 - { stdenv, fetchurl, ncurses, openssl, aspell, gnutls 2 - , zlib, curl , pkgconfig, libgcrypt 3 , cmake, makeWrapper, libobjc, libresolv, libiconv 4 , asciidoctor # manpages 5 , guileSupport ? true, guile 6 , luaSupport ? true, lua5 7 , perlSupport ? true, perl 8 - , pythonPackages 9 , rubySupport ? true, ruby 10 , tclSupport ? true, tcl 11 - , extraBuildInputs ? [] }: 12 - 13 - assert guileSupport -> guile != null; 14 - assert luaSupport -> lua5 != null; 15 - assert perlSupport -> perl != null; 16 - assert rubySupport -> ruby != null; 17 - assert tclSupport -> tcl != null; 18 19 let 20 inherit (pythonPackages) python pycrypto pync; 21 - in 22 23 - stdenv.mkDerivation rec { 24 - version = "1.9.1"; 25 - name = "weechat-${version}"; 26 27 - src = fetchurl { 28 - url = "http://weechat.org/files/src/weechat-${version}.tar.bz2"; 29 - sha256 = "1kgi079bq4n0wb7hc7mz8p7ay1b2m0a4wpvb92sfsxrnh10qr5m1"; 30 - }; 31 32 - outputs = [ "out" "man" ]; 33 34 - enableParallelBuilding = true; 35 - cmakeFlags = with stdenv.lib; [ 36 - "-DENABLE_MAN=ON" 37 - "-DENABLE_DOC=ON" 38 - ] 39 - ++ optionals stdenv.isDarwin ["-DICONV_LIBRARY=${libiconv}/lib/libiconv.dylib" "-DCMAKE_FIND_FRAMEWORK=LAST"] 40 - ++ optional (!guileSupport) "-DENABLE_GUILE=OFF" 41 - ++ optional (!luaSupport) "-DENABLE_LUA=OFF" 42 - ++ optional (!perlSupport) "-DENABLE_PERL=OFF" 43 - ++ optional (!rubySupport) "-DENABLE_RUBY=OFF" 44 - ++ optional (!tclSupport) "-DENABLE_TCL=OFF" 45 - ; 46 47 - buildInputs = with stdenv.lib; [ 48 - ncurses python openssl aspell gnutls zlib curl pkgconfig 49 - libgcrypt pycrypto makeWrapper 50 - cmake 51 - asciidoctor 52 ] 53 - ++ optionals stdenv.isDarwin [ pync libobjc libresolv ] 54 - ++ optional guileSupport guile 55 - ++ optional luaSupport lua5 56 - ++ optional perlSupport perl 57 - ++ optional rubySupport ruby 58 - ++ optional tclSupport tcl 59 - ++ extraBuildInputs; 60 61 - NIX_CFLAGS_COMPILE = "-I${python}/include/${python.libPrefix}" 62 - # Fix '_res_9_init: undefined symbol' error 63 - + (stdenv.lib.optionalString stdenv.isDarwin "-DBIND_8_COMPAT=1 -lresolv"); 64 65 - postInstall = with stdenv.lib; '' 66 - NIX_PYTHONPATH="$out/lib/${python.libPrefix}/site-packages" 67 - wrapProgram "$out/bin/weechat" \ 68 - ${optionalString perlSupport "--prefix PATH : ${perl}/bin"} \ 69 - --prefix PATH : ${pythonPackages.python}/bin \ 70 - --prefix PYTHONPATH : "$PYTHONPATH" \ 71 - --prefix PYTHONPATH : "$NIX_PYTHONPATH" 72 - ''; 73 74 - meta = { 75 - homepage = http://www.weechat.org/; 76 - description = "A fast, light and extensible chat client"; 77 - license = stdenv.lib.licenses.gpl3; 78 - maintainers = with stdenv.lib.maintainers; [ lovek323 garbas the-kenny ]; 79 - platforms = stdenv.lib.platforms.unix; 80 - }; 81 - }
··· 1 + { stdenv, fetchurl, fetchpatch, lib 2 + , ncurses, openssl, aspell, gnutls 3 + , zlib, curl, pkgconfig, libgcrypt 4 , cmake, makeWrapper, libobjc, libresolv, libiconv 5 + , writeScriptBin, symlinkJoin # for withPlugins 6 , asciidoctor # manpages 7 , guileSupport ? true, guile 8 , luaSupport ? true, lua5 9 , perlSupport ? true, perl 10 + , pythonSupport ? true, pythonPackages 11 , rubySupport ? true, ruby 12 , tclSupport ? true, tcl 13 + , extraBuildInputs ? [] 14 + , configure ? null 15 + , runCommand }: 16 17 let 18 inherit (pythonPackages) python pycrypto pync; 19 + plugins = [ 20 + { name = "perl"; enabled = perlSupport; cmakeFlag = "ENABLE_PERL"; buildInputs = [ perl ]; } 21 + { name = "tcl"; enabled = tclSupport; cmakeFlag = "ENABLE_TCL"; buildInputs = [ tcl ]; } 22 + { name = "ruby"; enabled = rubySupport; cmakeFlag = "ENABLE_RUBY"; buildInputs = [ ruby ]; } 23 + { name = "guile"; enabled = guileSupport; cmakeFlag = "ENABLE_GUILE"; buildInputs = [ guile ]; } 24 + { name = "lua"; enabled = luaSupport; cmakeFlag = "ENABLE_LUA"; buildInputs = [ lua5 ]; } 25 + { name = "python"; enabled = pythonSupport; cmakeFlag = "ENABLE_PYTHON"; buildInputs = [ python ]; } 26 + ]; 27 + enabledPlugins = builtins.filter (p: p.enabled) plugins; 28 29 + weechat = 30 + assert lib.all (p: p.enabled -> ! (builtins.elem null p.buildInputs)) plugins; 31 + stdenv.mkDerivation rec { 32 + version = "1.9.1"; 33 + name = "weechat-${version}"; 34 35 + src = fetchurl { 36 + url = "http://weechat.org/files/src/weechat-${version}.tar.bz2"; 37 + sha256 = "1kgi079bq4n0wb7hc7mz8p7ay1b2m0a4wpvb92sfsxrnh10qr5m1"; 38 + }; 39 40 + patches = [ 41 + # TODO: Remove this patch when weechat is updated to a release that 42 + # incorporates weechat/weechat#971 43 + (fetchpatch { 44 + url = https://github.com/lheckemann/weechat/commit/45a4f0565cc745b9c6e943f20199015185696df0.patch; 45 + sha256 = "0x7vv7g0k3b2hj444x2cinyv1mq5bkr6m18grfnyy6swbymzc9bj"; 46 + }) 47 + ]; 48 49 + outputs = [ "out" "man" ] ++ map (p: p.name) enabledPlugins; 50 51 + enableParallelBuilding = true; 52 + cmakeFlags = with stdenv.lib; [ 53 + "-DENABLE_MAN=ON" 54 + "-DENABLE_DOC=ON" 55 ] 56 + ++ optionals stdenv.isDarwin ["-DICONV_LIBRARY=${libiconv}/lib/libiconv.dylib" "-DCMAKE_FIND_FRAMEWORK=LAST"] 57 + ++ map (p: "-D${p.cmakeFlag}=" + (if p.enabled then "ON" else "OFF")) plugins 58 + ; 59 60 + buildInputs = with stdenv.lib; [ 61 + ncurses openssl aspell gnutls zlib curl pkgconfig 62 + libgcrypt makeWrapper cmake asciidoctor 63 + ] 64 + ++ optionals stdenv.isDarwin [ libobjc libresolv ] 65 + ++ concatMap (p: p.buildInputs) enabledPlugins 66 + ++ extraBuildInputs; 67 68 + NIX_CFLAGS_COMPILE = "-I${python}/include/${python.libPrefix}" 69 + # Fix '_res_9_init: undefined symbol' error 70 + + (stdenv.lib.optionalString stdenv.isDarwin "-DBIND_8_COMPAT=1 -lresolv"); 71 + 72 + postInstall = with stdenv.lib; '' 73 + for p in ${concatMapStringsSep " " (p: p.name) enabledPlugins}; do 74 + from=$out/lib/weechat/plugins/$p.so 75 + to=''${!p}/lib/weechat/plugins/$p.so 76 + mkdir -p $(dirname $to) 77 + mv $from $to 78 + done 79 + ''; 80 81 + meta = { 82 + homepage = http://www.weechat.org/; 83 + description = "A fast, light and extensible chat client"; 84 + license = stdenv.lib.licenses.gpl3; 85 + maintainers = with stdenv.lib.maintainers; [ lovek323 garbas the-kenny lheckemann ]; 86 + platforms = stdenv.lib.platforms.unix; 87 + }; 88 + }; 89 + in if configure == null then weechat else 90 + let 91 + perlInterpreter = perl; 92 + config = configure { 93 + availablePlugins = let 94 + simplePlugin = name: {pluginFile = "${weechat.${name}}/lib/weechat/plugins/${name}.so";}; 95 + in rec { 96 + python = { 97 + pluginFile = "${weechat.python}/lib/weechat/plugins/python.so"; 98 + withPackages = pkgsFun: (python // { 99 + extraEnv = '' 100 + export PYTHONHOME="${pythonPackages.python.withPackages pkgsFun}" 101 + ''; 102 + }); 103 + }; 104 + perl = (simplePlugin "perl") // { 105 + extraEnv = '' 106 + export PATH="${perlInterpreter}/bin:$PATH" 107 + ''; 108 + }; 109 + tcl = simplePlugin "tcl"; 110 + ruby = simplePlugin "ruby"; 111 + guile = simplePlugin "guile"; 112 + lua = simplePlugin "lua"; 113 + }; 114 + }; 115 + 116 + inherit (config) plugins; 117 + 118 + pluginsDir = runCommand "weechat-plugins" {} '' 119 + mkdir -p $out/plugins 120 + for plugin in ${lib.concatMapStringsSep " " (p: p.pluginFile) plugins} ; do 121 + ln -s $plugin $out/plugins 122 + done 123 + ''; 124 + in writeScriptBin "weechat" '' 125 + #!${stdenv.shell} 126 + export WEECHAT_EXTRA_LIBDIR=${pluginsDir} 127 + ${lib.concatMapStringsSep "\n" (p: lib.optionalString (p ? extraEnv) p.extraEnv) plugins} 128 + exec ${weechat}/bin/weechat "$@" 129 + ''