summary refs log tree commit diff
path: root/pkgs/applications/networking/irc/weechat/scripts/weechat-matrix-bridge/default.nix
diff options
context:
space:
mode:
authorMaximilian Bosch <maximilian@mbosch.me>2018-09-05 17:01:45 +0200
committerMaximilian Bosch <maximilian@mbosch.me>2018-09-07 13:10:43 +0200
commita8efe614123e6be5ecd0661c9a9f07e9a6c57ec3 (patch)
tree3fe915661b8e24f9849568386691f4d9495ac005 /pkgs/applications/networking/irc/weechat/scripts/weechat-matrix-bridge/default.nix
parentb54987715bf9240622a4d135217fe2201d7cd3d0 (diff)
downloadnixpkgs-a8efe614123e6be5ecd0661c9a9f07e9a6c57ec3.tar
nixpkgs-a8efe614123e6be5ecd0661c9a9f07e9a6c57ec3.tar.gz
nixpkgs-a8efe614123e6be5ecd0661c9a9f07e9a6c57ec3.tar.bz2
nixpkgs-a8efe614123e6be5ecd0661c9a9f07e9a6c57ec3.tar.lz
nixpkgs-a8efe614123e6be5ecd0661c9a9f07e9a6c57ec3.tar.xz
nixpkgs-a8efe614123e6be5ecd0661c9a9f07e9a6c57ec3.tar.zst
nixpkgs-a8efe614123e6be5ecd0661c9a9f07e9a6c57ec3.zip
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.
Diffstat (limited to 'pkgs/applications/networking/irc/weechat/scripts/weechat-matrix-bridge/default.nix')
-rw-r--r--pkgs/applications/networking/irc/weechat/scripts/weechat-matrix-bridge/default.nix46
1 files changed, 46 insertions, 0 deletions
diff --git a/pkgs/applications/networking/irc/weechat/scripts/weechat-matrix-bridge/default.nix b/pkgs/applications/networking/irc/weechat/scripts/weechat-matrix-bridge/default.nix
new file mode 100644
index 00000000000..1018e46ec62
--- /dev/null
+++ b/pkgs/applications/networking/irc/weechat/scripts/weechat-matrix-bridge/default.nix
@@ -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;
+  };
+}