fix: mautrix-mattermost bridge

This commit is contained in:
Dominik Polakovics Polakovics 2026-03-03 09:51:35 +01:00
parent d725df2606
commit 8451acdd8f

View file

@ -1,3 +1,9 @@
# Mautrix-Mattermost bridge module (bridgev2 format)
#
# Key differences from legacy mautrix bridges (discord, whatsapp, signal):
# - database is a top-level config key, NOT under appservice
# - network section required for bridge-specific settings
# - bridge section has different fields (no username_template, etc.)
{ {
lib, lib,
config, config,
@ -45,10 +51,7 @@ in
websocket = false; websocket = false;
ping_interval_seconds = 0; ping_interval_seconds = 0;
}; };
description = '' description = "Homeserver configuration.";
Homeserver configuration.
See the mautrix-mattermost example-config.yaml for more information.
'';
}; };
appservice = lib.mkOption { appservice = lib.mkOption {
@ -57,14 +60,6 @@ in
address = "http://localhost:29335"; address = "http://localhost:29335";
hostname = "0.0.0.0"; hostname = "0.0.0.0";
port = 29335; port = 29335;
database = {
type = "sqlite3";
uri = "file:${dataDir}/mautrix-mattermost.db?_txlock=immediate";
max_open_conns = 20;
max_idle_conns = 2;
max_conn_idle_time = null;
max_conn_lifetime = null;
};
id = "mattermost"; id = "mattermost";
bot = { bot = {
username = "mattermostbot"; username = "mattermostbot";
@ -73,34 +68,52 @@ in
}; };
ephemeral_events = true; ephemeral_events = true;
async_transactions = false; async_transactions = false;
username_template = "mattermost_{{.}}";
as_token = "This value is generated when generating the registration"; as_token = "This value is generated when generating the registration";
hs_token = "This value is generated when generating the registration"; hs_token = "This value is generated when generating the registration";
}; };
description = '' description = "Appservice configuration.";
Appservice configuration. };
See the mautrix-mattermost example-config.yaml for more information.
''; database = lib.mkOption {
type = lib.types.attrs;
default = {
type = "sqlite3-fk-wal";
uri = "file:${dataDir}/mautrix-mattermost.db?_txlock=immediate";
max_open_conns = 5;
max_idle_conns = 1;
max_conn_idle_time = null;
max_conn_lifetime = null;
};
description = "Database configuration (top-level in bridgev2).";
}; };
bridge = lib.mkOption { bridge = lib.mkOption {
type = lib.types.attrs; type = lib.types.attrs;
default = { default = {
username_template = "mattermost_{{.}}";
command_prefix = "!mm"; command_prefix = "!mm";
double_puppet_server_map = { }; personal_filtering_spaces = true;
double_puppet_allow_discovery = false; private_chat_portal_meta = true;
login_shared_secret_map = { }; relay = {
management_room_text = { enabled = false;
welcome = "Hello, I'm a Mattermost bridge bot."; admin_only = true;
welcome_connected = "Use `help` for help."; default_relays = [ ];
welcome_unconnected = "Use `help` for help or `login` to log in.";
additional_help = "";
}; };
encryption = { permissions = {
"*" = "relay";
};
};
description = "Bridge configuration (bridgev2 format).";
};
encryption = lib.mkOption {
type = lib.types.attrs;
default = {
allow = false; allow = false;
default = false; default = false;
appservice = false;
require = false; require = false;
appservice = false;
msc4190 = false;
allow_key_sharing = false; allow_key_sharing = false;
plaintext_mentions = false; plaintext_mentions = false;
delete_keys = { delete_keys = {
@ -125,20 +138,15 @@ in
disable_device_change_key_rotation = false; disable_device_change_key_rotation = false;
}; };
}; };
provisioning = { description = "End-to-bridge encryption configuration.";
prefix = "/_matrix/provision";
shared_secret = "generate";
debug_endpoints = false;
}; };
permissions = {
"*" = "relay"; network = lib.mkOption {
}; type = lib.types.attrs;
}; default = { };
description = '' description = "Mattermost-specific network configuration.";
Bridge configuration.
See the mautrix-mattermost example-config.yaml for more information.
'';
}; };
logging = lib.mkOption { logging = lib.mkOption {
type = lib.types.attrs; type = lib.types.attrs;
default = { default = {
@ -149,10 +157,7 @@ in
time_format = " "; time_format = " ";
}; };
}; };
description = '' description = "Logging configuration.";
Logging configuration.
See the mautrix-mattermost example-config.yaml for more information.
'';
}; };
}; };
}; };
@ -175,9 +180,7 @@ in
dataDir = lib.mkOption { dataDir = lib.mkOption {
type = lib.types.path; type = lib.types.path;
default = "/var/lib/mautrix-mattermost"; default = "/var/lib/mautrix-mattermost";
description = '' description = "Directory to store the bridge's configuration and database files.";
Directory to store the bridge's configuration and database files.
'';
}; };
environmentFile = lib.mkOption { environmentFile = lib.mkOption {
@ -186,7 +189,6 @@ in
description = '' description = ''
File containing environment variables to substitute when copying the configuration File containing environment variables to substitute when copying the configuration
out of Nix store to the `services.mautrix-mattermost.dataDir`. out of Nix store to the `services.mautrix-mattermost.dataDir`.
Can be used for storing the secrets without making them available in the Nix store.
''; '';
}; };
@ -212,9 +214,7 @@ in
++ (lib.lists.optional config.services.matrix-synapse.enable config.services.matrix-synapse.serviceUnit) ++ (lib.lists.optional config.services.matrix-synapse.enable config.services.matrix-synapse.serviceUnit)
++ (lib.lists.optional (config.services ? matrix-conduit && config.services.matrix-conduit.enable) "matrix-conduit.service") ++ (lib.lists.optional (config.services ? matrix-conduit && config.services.matrix-conduit.enable) "matrix-conduit.service")
++ (lib.lists.optional (config.services ? dendrite && config.services.dendrite.enable) "dendrite.service"); ++ (lib.lists.optional (config.services ? dendrite && config.services.dendrite.enable) "dendrite.service");
description = '' description = "List of Systemd services to require and wait for when starting the application service.";
List of Systemd services to require and wait for when starting the application service.
'';
}; };
}; };
}; };
@ -230,7 +230,7 @@ in
''; '';
} }
{ {
assertion = cfg.settings.bridge.permissions or { } != { }; assertion = (cfg.settings.bridge.permissions or { }) != { };
message = '' message = ''
The option `services.mautrix-mattermost.settings.bridge.permissions` has to be set. The option `services.mautrix-mattermost.settings.bridge.permissions` has to be set.
''; '';