Mautrix-Discord
Source: modules/services/matrix/mautrix-discord
Upstream documentation: https://docs.mau.fi/bridges/go/discord/index.html
Mautrix-Discord is a Matrix-Discord bridge.
Basic Usage
The common setup is to enable the bridge, point it at your homeserver, and set the permissions you want to allow:
- Set
services.mautrix-discord.enabletotrue. - Set
services.mautrix-discord.settings.homeserver.addressandservices.mautrix-discord.settings.homeserver.domain. - Override
services.mautrix-discord.settings.bridge.permissionsif the default relay permissions do not fit your deployment.
The module provides sensible defaults for the appservice listener, registration tokens, and relay permissions.
Basic Example
{
services.mautrix-discord = {
enable = true;
registerToSynapse = true;
settings = {
homeserver = {
address = "http://localhost:8008";
domain = "example.com";
};
bridge.permissions = {
"example.com" = "user";
"@admin:example.com" = "admin";
};
};
};
}
Server Defaults
By default, the bridge listens on http://localhost:29334 and generates its appservice tokens automatically.
Authentication
If you want to store the bridge database outside the default SQLite file, set settings.appservice.database to use PostgreSQL instead of SQLite:
{
services.mautrix-discord.settings.appservice.database = {
type = "postgres";
uri = "postgresql:///mautrix-discord?host=/run/postgresql";
};
}
If the connection needs a password, combine it with services.mautrix-discord.environmentFile:
{
services.mautrix-discord = {
environmentFile = "/run/secrets/mautrix-discord-env";
settings.appservice.database.uri = "postgresql://mautrix:$DB_PASSWORD@localhost/mautrix-discord";
};
}
Use services.mautrix-discord.environmentFile for any secret you do not want in the Nix store.
This includes database passwords, shared secrets, and similar values.
Example:
{
services.mautrix-discord = {
environmentFile = "/run/secrets/mautrix-discord-env";
settings.bridge.login_shared_secret_map = {
"example.com" = "$SHARED_SECRET";
};
};
}
Bridge Setup
After the service starts, open a chat with @discordbot:example.com, send login, and follow the instructions to link your Discord account.
For more detail, see the Mautrix-Discord documentation.
Advanced Configuration
The upstream default configuration is available at example-config.yaml. To print the generated default configuration from the package, run:
nix-shell -p mautrix-discord --run "mautrix-discord -e"
Encryption
{
services.mautrix-discord.settings.bridge.encryption = {
allow = true;
default = true;
require = false;
};
}
Encryption needs additional bridge-side setup. See the bridge encryption documentation for details.
Backfill
{
services.mautrix-discord.settings.bridge.backfill.forward_limits.initial = {
dm = 50;
channel = 50;
thread = 50;
};
}
Double Puppeting
{
services.mautrix-discord = {
environmentFile = "/run/secrets/mautrix-discord-env";
settings.bridge.login_shared_secret_map = {
"example.com" = "$SHARED_SECRET";
};
};
}
where /run/secrets/mautrix-discord-env contains
SHARED_SECRET=aProtectedSecret
Synapse Integration
When services.mautrix-discord.registerToSynapse is true, the bridge writes its registration file automatically and Synapse picks it up.
If Synapse is enabled, this option defaults to true.
Troubleshooting
- View logs with
journalctl -u mautrix-discord.service -f. - Check
systemctl status mautrix-discordif the bridge does not start. - Verify the homeserver can reach the configured appservice address.
- Ensure the registration file exists and Synapse can read it.
For more help, see the Mautrix-Discord documentation or the support room at #discord:maunium.net.