From 7fe499ee1ff7ecd88b4ecfc96b200ed2704468a7 Mon Sep 17 00:00:00 2001 From: Soispha Date: Thu, 27 Jul 2023 09:45:30 +0200 Subject: Feat(system/services/matrix/bridges): Add mautrix-whatsapp bridge --- system/services/matrix/default.nix | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'system/services/matrix/default.nix') diff --git a/system/services/matrix/default.nix b/system/services/matrix/default.nix index 62345a7..5fe9e9b 100644 --- a/system/services/matrix/default.nix +++ b/system/services/matrix/default.nix @@ -12,6 +12,10 @@ return 200 '${builtins.toJSON data}'; ''; in { + imports = [ + ./bridges/mautrix-whatsapp.nix + ]; + networking.firewall.allowedTCPPorts = [80 443]; services.postgresql.enable = true; @@ -52,6 +56,29 @@ in { }; }; + services.mautrix-whatsapp = { + enable = true; + settings = { + appservice = { + database = { + type = "postgres"; + uri = "postgres:///dbname?host=/var/run/postgresql"; + }; + whatsapp = { + # TODO: See https://github.com/tulir/whatsmeow/blob/efc632c008604016ddde63bfcfca8de4e5304da9/binary/proto/def.proto#L43-L64 for a list. + # This also determints the whatsapp icon + browser_name = "unknown"; + }; + }; + homeserver.address = "https://matrix.vhack.eu"; + bridge.permissions = { + "@soispha:vhack.eu" = "admin"; + "@sils:vhack.eu" = "admin"; + "@nightingale:vhack.eu" = "admin"; + }; + }; + }; + services.matrix-synapse = { enable = true; dataDir = "/var/lib/matrix"; -- cgit 1.4.1 From 30c0434571c975892dc09a65aaa8f3fd066017a9 Mon Sep 17 00:00:00 2001 From: Soispha Date: Thu, 27 Jul 2023 10:05:20 +0200 Subject: Fix(system/services/matrix/bridges/m-wa): Correct postgresql uri --- system/services/matrix/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/services/matrix/default.nix') diff --git a/system/services/matrix/default.nix b/system/services/matrix/default.nix index 5fe9e9b..b0219ef 100644 --- a/system/services/matrix/default.nix +++ b/system/services/matrix/default.nix @@ -62,7 +62,7 @@ in { appservice = { database = { type = "postgres"; - uri = "postgres:///dbname?host=/var/run/postgresql"; + uri = "postgres:///matrix-synapse?host=/run/postgresql"; }; whatsapp = { # TODO: See https://github.com/tulir/whatsmeow/blob/efc632c008604016ddde63bfcfca8de4e5304da9/binary/proto/def.proto#L43-L64 for a list. -- cgit 1.4.1 From 911c3a166b08e2a6a4864980fa197b04cba83fa7 Mon Sep 17 00:00:00 2001 From: Soispha Date: Thu, 27 Jul 2023 10:12:00 +0200 Subject: Fix(system/services/matrix/bridges/m-wa): Use own database --- system/services/matrix/default.nix | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'system/services/matrix/default.nix') diff --git a/system/services/matrix/default.nix b/system/services/matrix/default.nix index b0219ef..ed3b567 100644 --- a/system/services/matrix/default.nix +++ b/system/services/matrix/default.nix @@ -20,11 +20,19 @@ in { services.postgresql.enable = true; services.postgresql.initialScript = pkgs.writeText "synapse-init.sql" '' + --Matrix: CREATE ROLE "matrix-synapse" WITH LOGIN PASSWORD 'synapse'; CREATE DATABASE "matrix-synapse" WITH OWNER "matrix-synapse" TEMPLATE template0 LC_COLLATE = "C" LC_CTYPE = "C"; + + --Whatsapp-bridge: + CREATE ROLE "mautrix-whatsapp" WITH LOGIN PASSWORD 'whatsapp'; + CREATE DATABASE "mautrix-whatsapp" WITH OWNER "mautrix-whatsapp" + TEMPLATE template0 + LC_COLLATE = "C" + LC_CTYPE = "C"; ''; services.nginx = { @@ -62,7 +70,7 @@ in { appservice = { database = { type = "postgres"; - uri = "postgres:///matrix-synapse?host=/run/postgresql"; + uri = "postgres:///mautrix-whatsapp?host=/run/postgresql"; }; whatsapp = { # TODO: See https://github.com/tulir/whatsmeow/blob/efc632c008604016ddde63bfcfca8de4e5304da9/binary/proto/def.proto#L43-L64 for a list. -- cgit 1.4.1