2017-11-03 11:25:22 +01:00
|
|
|
{ stdenv, fetchurl, fetchpatch, lib
|
|
|
|
, ncurses, openssl, aspell, gnutls
|
|
|
|
, zlib, curl, pkgconfig, libgcrypt
|
2016-10-20 14:28:27 +02:00
|
|
|
, cmake, makeWrapper, libobjc, libresolv, libiconv
|
2017-11-03 11:25:22 +01:00
|
|
|
, writeScriptBin, symlinkJoin # for withPlugins
|
2016-10-14 23:30:38 +02:00
|
|
|
, asciidoctor # manpages
|
2016-02-18 07:07:23 +01:00
|
|
|
, guileSupport ? true, guile
|
|
|
|
, luaSupport ? true, lua5
|
|
|
|
, perlSupport ? true, perl
|
2017-11-03 11:25:22 +01:00
|
|
|
, pythonSupport ? true, pythonPackages
|
2016-02-18 07:07:23 +01:00
|
|
|
, rubySupport ? true, ruby
|
|
|
|
, tclSupport ? true, tcl
|
2017-11-03 11:25:22 +01:00
|
|
|
, extraBuildInputs ? []
|
2017-11-29 16:25:28 +01:00
|
|
|
, configure ? { availablePlugins, ... }: { plugins = builtins.attrValues availablePlugins; }
|
2017-11-03 11:25:22 +01:00
|
|
|
, runCommand }:
|
2016-02-18 07:07:23 +01:00
|
|
|
|
|
|
|
let
|
|
|
|
inherit (pythonPackages) python pycrypto pync;
|
2017-11-03 11:25:22 +01:00
|
|
|
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;
|
2016-02-18 07:07:23 +01:00
|
|
|
|
2017-11-03 11:25:22 +01:00
|
|
|
weechat =
|
|
|
|
assert lib.all (p: p.enabled -> ! (builtins.elem null p.buildInputs)) plugins;
|
|
|
|
stdenv.mkDerivation rec {
|
2018-04-28 22:35:19 +02:00
|
|
|
version = "2.1";
|
2017-11-03 11:25:22 +01:00
|
|
|
name = "weechat-${version}";
|
2010-08-05 17:47:15 +02:00
|
|
|
|
2017-11-03 11:25:22 +01:00
|
|
|
src = fetchurl {
|
|
|
|
url = "http://weechat.org/files/src/weechat-${version}.tar.bz2";
|
2018-04-28 22:35:19 +02:00
|
|
|
sha256 = "0fq68wgynv2c3319gmzi0lz4ln4yrrk755y5mbrlr7fc1sx7ffd8";
|
2017-11-03 11:25:22 +01:00
|
|
|
};
|
2010-08-05 17:47:15 +02:00
|
|
|
|
2017-11-03 11:25:22 +01:00
|
|
|
outputs = [ "out" "man" ] ++ map (p: p.name) enabledPlugins;
|
2015-08-21 23:02:39 +02:00
|
|
|
|
2017-11-03 11:25:22 +01:00
|
|
|
enableParallelBuilding = true;
|
|
|
|
cmakeFlags = with stdenv.lib; [
|
|
|
|
"-DENABLE_MAN=ON"
|
|
|
|
"-DENABLE_DOC=ON"
|
2016-10-14 23:30:38 +02:00
|
|
|
]
|
2017-11-03 11:25:22 +01:00
|
|
|
++ optionals stdenv.isDarwin ["-DICONV_LIBRARY=${libiconv}/lib/libiconv.dylib" "-DCMAKE_FIND_FRAMEWORK=LAST"]
|
|
|
|
++ map (p: "-D${p.cmakeFlag}=" + (if p.enabled then "ON" else "OFF")) plugins
|
|
|
|
;
|
|
|
|
|
|
|
|
buildInputs = with stdenv.lib; [
|
|
|
|
ncurses openssl aspell gnutls zlib curl pkgconfig
|
|
|
|
libgcrypt makeWrapper cmake asciidoctor
|
|
|
|
]
|
|
|
|
++ optionals stdenv.isDarwin [ libobjc libresolv ]
|
|
|
|
++ concatMap (p: p.buildInputs) enabledPlugins
|
|
|
|
++ extraBuildInputs;
|
|
|
|
|
|
|
|
NIX_CFLAGS_COMPILE = "-I${python}/include/${python.libPrefix}"
|
|
|
|
# Fix '_res_9_init: undefined symbol' error
|
|
|
|
+ (stdenv.lib.optionalString stdenv.isDarwin "-DBIND_8_COMPAT=1 -lresolv");
|
|
|
|
|
|
|
|
postInstall = with stdenv.lib; ''
|
|
|
|
for p in ${concatMapStringsSep " " (p: p.name) enabledPlugins}; do
|
|
|
|
from=$out/lib/weechat/plugins/$p.so
|
|
|
|
to=''${!p}/lib/weechat/plugins/$p.so
|
|
|
|
mkdir -p $(dirname $to)
|
|
|
|
mv $from $to
|
|
|
|
done
|
|
|
|
'';
|
2010-08-05 17:47:15 +02:00
|
|
|
|
2017-11-03 11:25:22 +01:00
|
|
|
meta = {
|
|
|
|
homepage = http://www.weechat.org/;
|
|
|
|
description = "A fast, light and extensible chat client";
|
2018-04-04 14:42:06 +02:00
|
|
|
longDescription = ''
|
|
|
|
You can find more documentation as to how to customize this package
|
|
|
|
(eg. adding python modules for scripts that would require them, etc.)
|
|
|
|
on https://nixos.org/nixpkgs/manual/#sec-weechat .
|
|
|
|
'';
|
2017-11-03 11:25:22 +01:00
|
|
|
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";
|
|
|
|
};
|
|
|
|
};
|
2014-05-14 03:31:43 +02:00
|
|
|
|
2017-11-03 11:25:22 +01:00
|
|
|
inherit (config) plugins;
|
2012-12-28 02:17:04 +01:00
|
|
|
|
2017-11-03 11:25:22 +01:00
|
|
|
pluginsDir = runCommand "weechat-plugins" {} ''
|
|
|
|
mkdir -p $out/plugins
|
|
|
|
for plugin in ${lib.concatMapStringsSep " " (p: p.pluginFile) plugins} ; do
|
|
|
|
ln -s $plugin $out/plugins
|
|
|
|
done
|
|
|
|
'';
|
2018-06-13 00:57:18 +02:00
|
|
|
in (writeScriptBin "weechat" ''
|
2017-11-03 11:25:22 +01:00
|
|
|
#!${stdenv.shell}
|
|
|
|
export WEECHAT_EXTRA_LIBDIR=${pluginsDir}
|
|
|
|
${lib.concatMapStringsSep "\n" (p: lib.optionalString (p ? extraEnv) p.extraEnv) plugins}
|
|
|
|
exec ${weechat}/bin/weechat "$@"
|
2018-04-04 14:45:08 +02:00
|
|
|
'') // {
|
|
|
|
unwrapped = weechat;
|
|
|
|
meta = weechat.meta;
|
|
|
|
}
|