Add Signal and WhatsApp bridges for matrix-synapse
All checks were successful
Check flake / build-amd64-linux (push) Successful in 2m50s
All checks were successful
Check flake / build-amd64-linux (push) Successful in 2m50s
This commit is contained in:
parent
832c1bbd08
commit
7f7f133bbf
@ -7,6 +7,10 @@
|
|||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.modules.services.matrix-synapse;
|
cfg = config.modules.services.matrix-synapse;
|
||||||
|
validBridges = [
|
||||||
|
"signal"
|
||||||
|
"whatsapp"
|
||||||
|
];
|
||||||
in {
|
in {
|
||||||
options.modules.services.matrix-synapse = {
|
options.modules.services.matrix-synapse = {
|
||||||
enable = lib.mkOption {
|
enable = lib.mkOption {
|
||||||
@ -17,6 +21,16 @@ in {
|
|||||||
default = true;
|
default = true;
|
||||||
example = false;
|
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 {
|
serverName = lib.mkOption {
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
default = "vimium.com";
|
default = "vimium.com";
|
||||||
@ -29,6 +43,27 @@ in {
|
|||||||
};
|
};
|
||||||
|
|
||||||
config = let
|
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 = {
|
matrixClientConfig = {
|
||||||
"m.homeserver" = {
|
"m.homeserver" = {
|
||||||
base_url = "https://matrix.${cfg.serverName}";
|
base_url = "https://matrix.${cfg.serverName}";
|
||||||
@ -149,5 +184,25 @@ in {
|
|||||||
"matrix-synapse"
|
"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";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user