Add Signal and WhatsApp bridges for matrix-synapse
All checks were successful
Check flake / build-amd64-linux (push) Successful in 2m50s

This commit is contained in:
Jordan Holt 2024-07-09 00:13:27 +01:00
parent 832c1bbd08
commit 7f7f133bbf
Signed by: jordan
GPG Key ID: B8CFFF61F1CCF520

View File

@ -7,6 +7,10 @@
let
cfg = config.modules.services.matrix-synapse;
validBridges = [
"signal"
"whatsapp"
];
in {
options.modules.services.matrix-synapse = {
enable = lib.mkOption {
@ -17,6 +21,16 @@ in {
default = true;
example = false;
};
bridges = lib.mkOption {
type = lib.types.listOf lib.types.str;
description = "A list of bridges to configure with Synapse.";
example = [ "signal" "whatsapp" ];
default = [];
apply = bridges:
if lib.all (bridge: lib.elem bridge validBridges) bridges
then bridges
else throw "Invalid bridge(s) specified. Valid bridges are: ${lib.concatStringsSep ", " validBridges}";
};
serverName = lib.mkOption {
type = lib.types.str;
default = "vimium.com";
@ -29,6 +43,27 @@ in {
};
config = let
commonBridgeSettings = bridge: {
appservice = {
database = lib.mkIf cfg.usePostgresql {
type = "postgres";
uri = "postgresql:///mautrix-${bridge}?host=/run/postgresql";
};
};
bridge = {
encryption = {
allow = true;
default = true;
require = true;
};
permissions = {
"${cfg.serverName}" = "user";
};
provisioning = {
shared_secret = "disable";
};
};
};
matrixClientConfig = {
"m.homeserver" = {
base_url = "https://matrix.${cfg.serverName}";
@ -149,5 +184,25 @@ in {
"matrix-synapse"
];
};
services.mautrix-signal = lib.mkIf (lib.elem "signal" cfg.bridges) {
enable = true;
settings = commonBridgeSettings "signal";
};
services.mautrix-whatsapp = lib.mkIf (lib.elem "whatsapp" cfg.bridges) {
enable = true;
settings = {
bridge = {
history_sync = {
backfill = true;
max_initial_conversations = -1;
message_count = 50;
request_full_sync = false;
};
mute_bridging = true;
};
} // commonBridgeSettings "whatsapp";
};
};
}