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,
config,
@ -45,10 +51,7 @@ in
websocket = false;
ping_interval_seconds = 0;
};
description = ''
Homeserver configuration.
See the mautrix-mattermost example-config.yaml for more information.
'';
description = "Homeserver configuration.";
};
appservice = lib.mkOption {
@ -57,14 +60,6 @@ in
address = "http://localhost:29335";
hostname = "0.0.0.0";
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";
bot = {
username = "mattermostbot";
@ -73,72 +68,85 @@ in
};
ephemeral_events = true;
async_transactions = false;
username_template = "mattermost_{{.}}";
as_token = "This value is generated when generating the registration";
hs_token = "This value is generated when generating the registration";
};
description = ''
Appservice configuration.
See the mautrix-mattermost example-config.yaml for more information.
'';
description = "Appservice configuration.";
};
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 {
type = lib.types.attrs;
default = {
username_template = "mattermost_{{.}}";
command_prefix = "!mm";
double_puppet_server_map = { };
double_puppet_allow_discovery = false;
login_shared_secret_map = { };
management_room_text = {
welcome = "Hello, I'm a Mattermost bridge bot.";
welcome_connected = "Use `help` for help.";
welcome_unconnected = "Use `help` for help or `login` to log in.";
additional_help = "";
};
encryption = {
allow = false;
default = false;
appservice = false;
require = false;
allow_key_sharing = false;
plaintext_mentions = false;
delete_keys = {
delete_outbound_on_ack = false;
dont_store_outbound = false;
ratchet_on_decrypt = false;
delete_fully_used_on_decrypt = false;
delete_prev_on_new_session = false;
delete_on_device_delete = false;
periodically_delete_expired = false;
delete_outdated_inbound = false;
};
verification_levels = {
receive = "unverified";
send = "unverified";
share = "cross-signed-tofu";
};
rotation = {
enable_custom = false;
milliseconds = 604800000;
messages = 100;
disable_device_change_key_rotation = false;
};
};
provisioning = {
prefix = "/_matrix/provision";
shared_secret = "generate";
debug_endpoints = false;
personal_filtering_spaces = true;
private_chat_portal_meta = true;
relay = {
enabled = false;
admin_only = true;
default_relays = [ ];
};
permissions = {
"*" = "relay";
};
};
description = ''
Bridge configuration.
See the mautrix-mattermost example-config.yaml for more information.
'';
description = "Bridge configuration (bridgev2 format).";
};
encryption = lib.mkOption {
type = lib.types.attrs;
default = {
allow = false;
default = false;
require = false;
appservice = false;
msc4190 = false;
allow_key_sharing = false;
plaintext_mentions = false;
delete_keys = {
delete_outbound_on_ack = false;
dont_store_outbound = false;
ratchet_on_decrypt = false;
delete_fully_used_on_decrypt = false;
delete_prev_on_new_session = false;
delete_on_device_delete = false;
periodically_delete_expired = false;
delete_outdated_inbound = false;
};
verification_levels = {
receive = "unverified";
send = "unverified";
share = "cross-signed-tofu";
};
rotation = {
enable_custom = false;
milliseconds = 604800000;
messages = 100;
disable_device_change_key_rotation = false;
};
};
description = "End-to-bridge encryption configuration.";
};
network = lib.mkOption {
type = lib.types.attrs;
default = { };
description = "Mattermost-specific network configuration.";
};
logging = lib.mkOption {
type = lib.types.attrs;
default = {
@ -149,10 +157,7 @@ in
time_format = " ";
};
};
description = ''
Logging configuration.
See the mautrix-mattermost example-config.yaml for more information.
'';
description = "Logging configuration.";
};
};
};
@ -175,9 +180,7 @@ in
dataDir = lib.mkOption {
type = lib.types.path;
default = "/var/lib/mautrix-mattermost";
description = ''
Directory to store the bridge's configuration and database files.
'';
description = "Directory to store the bridge's configuration and database files.";
};
environmentFile = lib.mkOption {
@ -186,7 +189,6 @@ in
description = ''
File containing environment variables to substitute when copying the configuration
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-conduit && config.services.matrix-conduit.enable) "matrix-conduit.service")
++ (lib.lists.optional (config.services ? dendrite && config.services.dendrite.enable) "dendrite.service");
description = ''
List of Systemd services to require and wait for when starting the application service.
'';
description = "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 = ''
The option `services.mautrix-mattermost.settings.bridge.permissions` has to be set.
'';