1{
2 lib,
3 stdenv,
4 curl,
5 fetchFromGitHub,
6 cjson,
7 olm,
8 luaffi,
9}:
10
11stdenv.mkDerivation {
12 pname = "weechat-matrix-bridge";
13 version = "unstable-2018-11-19";
14 src = fetchFromGitHub {
15 owner = "torhve";
16 repo = "weechat-matrix-protocol-script";
17 rev = "8d32e90d864a8f3f09ecc2857cd5dd6e39a8c3f7";
18 sha256 = "0qqd6qmkrdc0r3rnl53c3yp93fbcz7d3mdw3vq5gmdqxyym4s9lj";
19 };
20
21 patches = [
22 ./library-path.patch
23 ];
24
25 buildInputs = [
26 curl
27 cjson
28 olm
29 luaffi
30 ];
31
32 postPatch = ''
33 substituteInPlace matrix.lua \
34 --replace "/usr/bin/curl" "${curl}/bin/curl" \
35 --replace "__NIX_LIB_PATH__" "$out/lib/?.so" \
36 --replace "__NIX_OLM_PATH__" "$out/share/?.lua"
37
38 substituteInPlace olm.lua \
39 --replace "__NIX_LIB_PATH__" "$out/lib/?.so"
40 '';
41
42 passthru.scripts = [ "matrix.lua" ];
43
44 installPhase = ''
45 mkdir -p $out/{share,lib}
46
47 cp {matrix.lua,olm.lua} $out/share
48 cp ${cjson}/lib/lua/${cjson.lua.luaversion}/cjson.so $out/lib/cjson.so
49 cp ${olm}/lib/libolm.so $out/lib/libolm.so
50 cp ${luaffi}/lib/lua/${luaffi.lua.luaversion}/ffi.so $out/lib/ffi.so
51 '';
52
53 meta = with lib; {
54 description = "WeeChat script in Lua that implements the matrix.org chat protocol";
55 homepage = "https://github.com/torhve/weechat-matrix-protocol-script";
56 maintainers = [ ];
57 license = licenses.mit; # see https://github.com/torhve/weechat-matrix-protocol-script/blob/0052e7275ae149dc5241226391c9b1889ecc3c6b/matrix.lua#L53
58 platforms = platforms.unix;
59
60 # As of 2019-06-30, all of the dependencies are available on macOS but the
61 # package itself does not build.
62 broken = stdenv.hostPlatform.isDarwin;
63 };
64}