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