weechat: 2.1 -> 2.2; improve package configuration
This aims to make the `weechat` package even more configurable. It
allows to specify scripts and commands using the `configure` function
inside a `weechat.override` expression.
The package can be configured like this:
```
with import <nixpkgs> { };
weechat.override {
plugins = { availablePlugins, ... }: {
plugins = builtins.attrValues availablePlugins;
init = ''
/set foo bar
/server add freenode chat.freenode.org
'';
scripts = [ "/path/to/script.py" ];
};
}
```
All commands are passed to `weechat --run-command "/set foo bar;/server ..."`.
The `plugins' attribute is not necessarily required anymore, if it's
sufficient to add `init' commands, the `plugins' will be
`builtins.attrValues availablePlugins' by default.
Additionally the result contains `weechat` and `weechat-headless`
(introduced in WeeChat 2.1) now.
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
{ callPackage, luaPackages, pythonPackages }:
|
||||
|
||||
{
|
||||
weechat-xmpp = callPackage ./weechat-xmpp {
|
||||
inherit (pythonPackages) pydns;
|
||||
};
|
||||
|
||||
weechat-matrix-bridge = callPackage ./weechat-matrix-bridge {
|
||||
inherit (luaPackages) cjson;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
{ stdenv, curl, fetchFromGitHub, cjson, olm, luaffi }:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "weechat-matrix-bridge-2018-05-29";
|
||||
src = fetchFromGitHub {
|
||||
owner = "torhve";
|
||||
repo = "weechat-matrix-protocol-script";
|
||||
rev = "ace3fefc0e35a627f8a528032df2e3111e41eb1b";
|
||||
sha256 = "1snf8vn5n9wzrnqnvdrcli4199s5p114jbjlgrj5c27i53173wqw";
|
||||
};
|
||||
|
||||
patches = [
|
||||
./library-path.patch
|
||||
];
|
||||
|
||||
buildInputs = [ curl cjson olm luaffi ];
|
||||
|
||||
postPatch = ''
|
||||
substituteInPlace matrix.lua \
|
||||
--replace "/usr/bin/curl" "${curl}/bin/curl" \
|
||||
--replace "__NIX_LIB_PATH__" "$out/lib/?.so" \
|
||||
--replace "__NIX_OLM_PATH__" "$out/share/?.lua"
|
||||
|
||||
substituteInPlace olm.lua \
|
||||
--replace "__NIX_LIB_PATH__" "$out/lib/?.so"
|
||||
'';
|
||||
|
||||
passthru.scripts = [ "olm.lua" "matrix.lua" ];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/{share,lib}
|
||||
|
||||
cp {matrix.lua,olm.lua} $out/share
|
||||
cp ${cjson}/lib/lua/5.2/cjson.so $out/lib/cjson.so
|
||||
cp ${olm}/lib/libolm.so $out/lib/libolm.so
|
||||
cp ${luaffi}/lib/ffi.so $out/lib/ffi.so
|
||||
'';
|
||||
|
||||
meta = with stdenv.lib; {
|
||||
description = "A WeeChat script in Lua that implements the matrix.org chat protocol";
|
||||
homepage = https://github.com/torhve/weechat-matrix-protocol-script;
|
||||
maintainers = with maintainers; [ ma27 ];
|
||||
license = licenses.mit; # see https://github.com/torhve/weechat-matrix-protocol-script/blob/0052e7275ae149dc5241226391c9b1889ecc3c6b/matrix.lua#L53
|
||||
platforms = platforms.unix;
|
||||
};
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
diff --git a/matrix.lua b/matrix.lua
|
||||
index b79f500..32b37a2 100644
|
||||
--- a/matrix.lua
|
||||
+++ b/matrix.lua
|
||||
@@ -43,6 +43,9 @@ This script maps this as follows:
|
||||
|
||||
]]
|
||||
|
||||
+package.cpath = package.cpath .. ";__NIX_LIB_PATH__"
|
||||
+package.path = package.path .. ";__NIX_OLM_PATH__"
|
||||
+
|
||||
local json = require 'cjson' -- apt-get install lua-cjson
|
||||
local olmstatus, olm = pcall(require, 'olm') -- LuaJIT olm FFI binding ln -s ~/olm/olm.lua /usr/local/share/lua/5.1
|
||||
local w = weechat
|
||||
diff --git a/olm.lua b/olm.lua
|
||||
index 114649c..4828371 100644
|
||||
--- a/olm.lua
|
||||
+++ b/olm.lua
|
||||
@@ -17,6 +17,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
--]]
|
||||
+
|
||||
+package.cpath = package.cpath .. ";__NIX_LIB_PATH__"
|
||||
+
|
||||
local ffi = require'ffi'
|
||||
|
||||
ffi.cdef[[
|
||||
@@ -0,0 +1,36 @@
|
||||
{ stdenv, fetchFromGitHub, xmpppy, pydns, substituteAll, buildEnv }:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "weechat-jabber-2017-08-30";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
repo = "weechat-xmpp";
|
||||
owner = "sleduc";
|
||||
sha256 = "0s02xs0ynld9cxxzj07al364sfglyc5ir1i82133mq0s8cpphnxv";
|
||||
rev = "8f6c21f5a160c9318c7a2d8fd5dcac7ab2e0d843";
|
||||
};
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/share
|
||||
cp jabber.py $out/share/jabber.py
|
||||
'';
|
||||
|
||||
patches = [
|
||||
(substituteAll {
|
||||
src = ./libpath.patch;
|
||||
env = "${buildEnv {
|
||||
name = "weechat-xmpp-env";
|
||||
paths = [ pydns xmpppy ];
|
||||
}}/lib/python2.7/site-packages";
|
||||
})
|
||||
];
|
||||
|
||||
passthru.scripts = [ "jabber.py" ];
|
||||
|
||||
meta = with stdenv.lib; {
|
||||
description = "A fork of the jabber plugin for weechat";
|
||||
homepage = "https://github.com/sleduc/weechat-xmpp";
|
||||
maintainers = with maintainers; [ ma27 ];
|
||||
license = licenses.gpl3Plus;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
diff --git a/jabber.py b/jabber.py
|
||||
index 27006a3..e53c2c0 100644
|
||||
--- a/jabber.py
|
||||
+++ b/jabber.py
|
||||
@@ -95,6 +95,11 @@ SCRIPT_COMMAND = SCRIPT_NAME
|
||||
import re
|
||||
import warnings
|
||||
|
||||
+import sys
|
||||
+
|
||||
+sys.path.append('@env@')
|
||||
+
|
||||
+
|
||||
import_ok = True
|
||||
|
||||
try:
|
||||
Reference in New Issue
Block a user