Ensure Matrix bridge databases are created
This commit is contained in:
parent
10b6622997
commit
734359da5b
@ -28,7 +28,7 @@ in {
|
||||
default = [];
|
||||
apply = bridges:
|
||||
if lib.all (bridge: lib.elem bridge validBridges) bridges
|
||||
then bridges
|
||||
then lib.map (b: "mautrix-${b}") bridges
|
||||
else throw "Invalid bridge(s) specified. Valid bridges are: ${lib.concatStringsSep ", " validBridges}";
|
||||
};
|
||||
serverName = lib.mkOption {
|
||||
@ -43,11 +43,15 @@ in {
|
||||
};
|
||||
|
||||
config = let
|
||||
mkBridgeDatabase = bridge: {
|
||||
name = bridge;
|
||||
ensureDBOwnership = true;
|
||||
};
|
||||
commonBridgeSettings = bridge: {
|
||||
appservice = {
|
||||
database = lib.mkIf cfg.usePostgresql {
|
||||
type = "postgres";
|
||||
uri = "postgresql:///mautrix-${bridge}?host=/run/postgresql";
|
||||
uri = "postgresql:///${bridge}?host=/run/postgresql";
|
||||
};
|
||||
};
|
||||
bridge = {
|
||||
@ -179,18 +183,18 @@ in {
|
||||
name = "matrix-synapse";
|
||||
ensureDBOwnership = true;
|
||||
}
|
||||
];
|
||||
] ++ lib.map mkBridgeDatabase cfg.bridges;
|
||||
ensureDatabases = [
|
||||
"matrix-synapse"
|
||||
];
|
||||
] ++ cfg.bridges;
|
||||
};
|
||||
|
||||
services.mautrix-signal = lib.mkIf (lib.elem "signal" cfg.bridges) {
|
||||
services.mautrix-signal = lib.mkIf (lib.elem "mautrix-signal" cfg.bridges) {
|
||||
enable = true;
|
||||
settings = commonBridgeSettings "signal";
|
||||
settings = commonBridgeSettings "mautrix-signal";
|
||||
};
|
||||
|
||||
services.mautrix-whatsapp = lib.mkIf (lib.elem "whatsapp" cfg.bridges) {
|
||||
services.mautrix-whatsapp = lib.mkIf (lib.elem "mautrix-whatsapp" cfg.bridges) {
|
||||
enable = true;
|
||||
settings = {
|
||||
bridge = {
|
||||
@ -202,7 +206,7 @@ in {
|
||||
};
|
||||
mute_bridging = true;
|
||||
};
|
||||
} // commonBridgeSettings "whatsapp";
|
||||
} // commonBridgeSettings "mautrix-whatsapp";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user