Merge pull request #25274 from lheckemann/weechat-plugin-split
Weechat plugin split
This commit is contained in:
commit
4bd9b3b7cf
@ -664,4 +664,34 @@ cp ${myEmacsConfig} $out/share/emacs/site-lisp/default.el
|
|||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<section xml:id="sec-weechat">
|
||||||
|
<title>Weechat</title>
|
||||||
|
<para>
|
||||||
|
Weechat can currently be configured to include your choice of plugins.
|
||||||
|
To make use of this functionality, install an expression that overrides its configuration such as
|
||||||
|
<programlisting>weechat.override {configure = {availablePlugins, ...}: {
|
||||||
|
plugins = with availablePlugins; [ python perl ];
|
||||||
|
}
|
||||||
|
}</programlisting>
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
The plugins currently available are <literal>python</literal>,
|
||||||
|
<literal>perl</literal>, <literal>ruby</literal>, <literal>guile</literal>,
|
||||||
|
<literal>tcl</literal> and <literal>lua</literal>.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
The python plugin allows the addition of extra libraries. For instance,
|
||||||
|
the <literal>inotify.py</literal> script in weechat-scripts requires
|
||||||
|
D-Bus or libnotify, and the <literal>fish.py</literal> script requires
|
||||||
|
pycrypto. To use these scripts, use the <literal>python</literal>
|
||||||
|
plugin's <literal>withPackages</literal> attribute:
|
||||||
|
<programlisting>weechat.override {configure = {availablePlugins, ...}: {
|
||||||
|
plugins = with availablePlugins; [
|
||||||
|
(python.withPackages (ps: with ps; [ pycrypto python-dbus ]))
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</programlisting>
|
||||||
|
</para>
|
||||||
|
</section>
|
||||||
</chapter>
|
</chapter>
|
||||||
|
@ -1,81 +1,129 @@
|
|||||||
{ stdenv, fetchurl, ncurses, openssl, aspell, gnutls
|
{ stdenv, fetchurl, fetchpatch, lib
|
||||||
, zlib, curl , pkgconfig, libgcrypt
|
, ncurses, openssl, aspell, gnutls
|
||||||
|
, zlib, curl, pkgconfig, libgcrypt
|
||||||
, cmake, makeWrapper, libobjc, libresolv, libiconv
|
, cmake, makeWrapper, libobjc, libresolv, libiconv
|
||||||
|
, writeScriptBin, symlinkJoin # for withPlugins
|
||||||
, asciidoctor # manpages
|
, asciidoctor # manpages
|
||||||
, guileSupport ? true, guile
|
, guileSupport ? true, guile
|
||||||
, luaSupport ? true, lua5
|
, luaSupport ? true, lua5
|
||||||
, perlSupport ? true, perl
|
, perlSupport ? true, perl
|
||||||
, pythonPackages
|
, pythonSupport ? true, pythonPackages
|
||||||
, rubySupport ? true, ruby
|
, rubySupport ? true, ruby
|
||||||
, tclSupport ? true, tcl
|
, tclSupport ? true, tcl
|
||||||
, extraBuildInputs ? [] }:
|
, extraBuildInputs ? []
|
||||||
|
, configure ? null
|
||||||
assert guileSupport -> guile != null;
|
, runCommand }:
|
||||||
assert luaSupport -> lua5 != null;
|
|
||||||
assert perlSupport -> perl != null;
|
|
||||||
assert rubySupport -> ruby != null;
|
|
||||||
assert tclSupport -> tcl != null;
|
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (pythonPackages) python pycrypto pync;
|
inherit (pythonPackages) python pycrypto pync;
|
||||||
in
|
plugins = [
|
||||||
|
{ name = "perl"; enabled = perlSupport; cmakeFlag = "ENABLE_PERL"; buildInputs = [ perl ]; }
|
||||||
|
{ name = "tcl"; enabled = tclSupport; cmakeFlag = "ENABLE_TCL"; buildInputs = [ tcl ]; }
|
||||||
|
{ name = "ruby"; enabled = rubySupport; cmakeFlag = "ENABLE_RUBY"; buildInputs = [ ruby ]; }
|
||||||
|
{ name = "guile"; enabled = guileSupport; cmakeFlag = "ENABLE_GUILE"; buildInputs = [ guile ]; }
|
||||||
|
{ name = "lua"; enabled = luaSupport; cmakeFlag = "ENABLE_LUA"; buildInputs = [ lua5 ]; }
|
||||||
|
{ name = "python"; enabled = pythonSupport; cmakeFlag = "ENABLE_PYTHON"; buildInputs = [ python ]; }
|
||||||
|
];
|
||||||
|
enabledPlugins = builtins.filter (p: p.enabled) plugins;
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
weechat =
|
||||||
version = "1.9.1";
|
assert lib.all (p: p.enabled -> ! (builtins.elem null p.buildInputs)) plugins;
|
||||||
name = "weechat-${version}";
|
stdenv.mkDerivation rec {
|
||||||
|
version = "1.9.1";
|
||||||
|
name = "weechat-${version}";
|
||||||
|
|
||||||
src = fetchurl {
|
src = fetchurl {
|
||||||
url = "http://weechat.org/files/src/weechat-${version}.tar.bz2";
|
url = "http://weechat.org/files/src/weechat-${version}.tar.bz2";
|
||||||
sha256 = "1kgi079bq4n0wb7hc7mz8p7ay1b2m0a4wpvb92sfsxrnh10qr5m1";
|
sha256 = "1kgi079bq4n0wb7hc7mz8p7ay1b2m0a4wpvb92sfsxrnh10qr5m1";
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = [ "out" "man" ];
|
patches = [
|
||||||
|
# TODO: Remove this patch when weechat is updated to a release that
|
||||||
|
# incorporates weechat/weechat#971
|
||||||
|
(fetchpatch {
|
||||||
|
url = https://github.com/lheckemann/weechat/commit/45a4f0565cc745b9c6e943f20199015185696df0.patch;
|
||||||
|
sha256 = "0x7vv7g0k3b2hj444x2cinyv1mq5bkr6m18grfnyy6swbymzc9bj";
|
||||||
|
})
|
||||||
|
];
|
||||||
|
|
||||||
enableParallelBuilding = true;
|
outputs = [ "out" "man" ] ++ map (p: p.name) enabledPlugins;
|
||||||
cmakeFlags = with stdenv.lib; [
|
|
||||||
"-DENABLE_MAN=ON"
|
|
||||||
"-DENABLE_DOC=ON"
|
|
||||||
]
|
|
||||||
++ optionals stdenv.isDarwin ["-DICONV_LIBRARY=${libiconv}/lib/libiconv.dylib" "-DCMAKE_FIND_FRAMEWORK=LAST"]
|
|
||||||
++ optional (!guileSupport) "-DENABLE_GUILE=OFF"
|
|
||||||
++ optional (!luaSupport) "-DENABLE_LUA=OFF"
|
|
||||||
++ optional (!perlSupport) "-DENABLE_PERL=OFF"
|
|
||||||
++ optional (!rubySupport) "-DENABLE_RUBY=OFF"
|
|
||||||
++ optional (!tclSupport) "-DENABLE_TCL=OFF"
|
|
||||||
;
|
|
||||||
|
|
||||||
buildInputs = with stdenv.lib; [
|
enableParallelBuilding = true;
|
||||||
ncurses python openssl aspell gnutls zlib curl pkgconfig
|
cmakeFlags = with stdenv.lib; [
|
||||||
libgcrypt pycrypto makeWrapper
|
"-DENABLE_MAN=ON"
|
||||||
cmake
|
"-DENABLE_DOC=ON"
|
||||||
asciidoctor
|
|
||||||
]
|
]
|
||||||
++ optionals stdenv.isDarwin [ pync libobjc libresolv ]
|
++ optionals stdenv.isDarwin ["-DICONV_LIBRARY=${libiconv}/lib/libiconv.dylib" "-DCMAKE_FIND_FRAMEWORK=LAST"]
|
||||||
++ optional guileSupport guile
|
++ map (p: "-D${p.cmakeFlag}=" + (if p.enabled then "ON" else "OFF")) plugins
|
||||||
++ optional luaSupport lua5
|
;
|
||||||
++ optional perlSupport perl
|
|
||||||
++ optional rubySupport ruby
|
|
||||||
++ optional tclSupport tcl
|
|
||||||
++ extraBuildInputs;
|
|
||||||
|
|
||||||
NIX_CFLAGS_COMPILE = "-I${python}/include/${python.libPrefix}"
|
buildInputs = with stdenv.lib; [
|
||||||
# Fix '_res_9_init: undefined symbol' error
|
ncurses openssl aspell gnutls zlib curl pkgconfig
|
||||||
+ (stdenv.lib.optionalString stdenv.isDarwin "-DBIND_8_COMPAT=1 -lresolv");
|
libgcrypt makeWrapper cmake asciidoctor
|
||||||
|
]
|
||||||
|
++ optionals stdenv.isDarwin [ libobjc libresolv ]
|
||||||
|
++ concatMap (p: p.buildInputs) enabledPlugins
|
||||||
|
++ extraBuildInputs;
|
||||||
|
|
||||||
postInstall = with stdenv.lib; ''
|
NIX_CFLAGS_COMPILE = "-I${python}/include/${python.libPrefix}"
|
||||||
NIX_PYTHONPATH="$out/lib/${python.libPrefix}/site-packages"
|
# Fix '_res_9_init: undefined symbol' error
|
||||||
wrapProgram "$out/bin/weechat" \
|
+ (stdenv.lib.optionalString stdenv.isDarwin "-DBIND_8_COMPAT=1 -lresolv");
|
||||||
${optionalString perlSupport "--prefix PATH : ${perl}/bin"} \
|
|
||||||
--prefix PATH : ${pythonPackages.python}/bin \
|
|
||||||
--prefix PYTHONPATH : "$PYTHONPATH" \
|
|
||||||
--prefix PYTHONPATH : "$NIX_PYTHONPATH"
|
|
||||||
'';
|
|
||||||
|
|
||||||
meta = {
|
postInstall = with stdenv.lib; ''
|
||||||
homepage = http://www.weechat.org/;
|
for p in ${concatMapStringsSep " " (p: p.name) enabledPlugins}; do
|
||||||
description = "A fast, light and extensible chat client";
|
from=$out/lib/weechat/plugins/$p.so
|
||||||
license = stdenv.lib.licenses.gpl3;
|
to=''${!p}/lib/weechat/plugins/$p.so
|
||||||
maintainers = with stdenv.lib.maintainers; [ lovek323 garbas the-kenny ];
|
mkdir -p $(dirname $to)
|
||||||
platforms = stdenv.lib.platforms.unix;
|
mv $from $to
|
||||||
};
|
done
|
||||||
}
|
'';
|
||||||
|
|
||||||
|
meta = {
|
||||||
|
homepage = http://www.weechat.org/;
|
||||||
|
description = "A fast, light and extensible chat client";
|
||||||
|
license = stdenv.lib.licenses.gpl3;
|
||||||
|
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 "$@"
|
||||||
|
''
|
||||||
|
Loading…
Reference in New Issue
Block a user