feat: add mautrix-discord bridge for Matrix #865

Merged
JakeHillion merged 1 commits from jj/sylwtlvmsypz into main 2026-01-12 23:24:34 +00:00
9 changed files with 140 additions and 19 deletions

No files matched your search

@@ -67,6 +67,7 @@
enable = true; enable = true;
tokenSecret = ../../modules/services/gitea/actions/boron.age; tokenSecret = ../../modules/services/gitea/actions/boron.age;
}; };
matrix.mautrix_discord = true;
zookeeper.enable = true; zookeeper.enable = true;
}; };
}; };
+1
View File
@@ -34,6 +34,7 @@ in
jellyfin = "phoenix.st.${config.ogygia.domain}"; jellyfin = "phoenix.st.${config.ogygia.domain}";
mastodon = ""; mastodon = "";
matrix = "boron.cx.${config.ogygia.domain}"; matrix = "boron.cx.${config.ogygia.domain}";
mautrix_discord = "warlock.cx.${config.ogygia.domain}";
mosquitto = "stinger.pop.${config.ogygia.domain}"; mosquitto = "stinger.pop.${config.ogygia.domain}";
nix-builder = [ nix-builder = [
"slider.pop.${config.ogygia.domain}" "slider.pop.${config.ogygia.domain}"
+1
View File
@@ -17,6 +17,7 @@
./jellyfin.nix ./jellyfin.nix
./mastodon ./mastodon
./matrix ./matrix
./mautrix-discord
./mosquitto.nix ./mosquitto.nix
./nix-builder ./nix-builder
./nix-prefetch-repos.nix ./nix-prefetch-repos.nix
+15 -3
View File
@@ -16,6 +16,12 @@ in
default = true; default = true;
type = lib.types.bool; type = lib.types.bool;
}; };
mautrix_discord = lib.mkOption {
default = false;
type = lib.types.bool;
description = "Load mautrix-discord bridge registration";
};
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
@@ -47,6 +53,12 @@ in
"matrix/matrix.hillion.co.uk/syncv3_secret" = { "matrix/matrix.hillion.co.uk/syncv3_secret" = {
file = ./matrix.hillion.co.uk/syncv3_secret.age; file = ./matrix.hillion.co.uk/syncv3_secret.age;
}; };
"mautrix-discord/registration.yaml" = lib.mkIf cfg.mautrix_discord {
file = ../mautrix-discord/registration.yaml.age;
owner = "matrix-synapse";
group = "matrix-synapse";
};
}; };
services = { services = {
@@ -133,9 +145,9 @@ in
]; ];
suppress_key_server_warning = true; suppress_key_server_warning = true;
dynamic_thumbnails = true; dynamic_thumbnails = true;
app_service_config_files = lib.mkIf cfg.heisenbridge [ app_service_config_files =
"/var/lib/heisenbridge/registration.yml" (lib.optional cfg.heisenbridge "/var/lib/heisenbridge/registration.yml") ++
]; (lib.optional cfg.mautrix_discord config.age.secrets."mautrix-discord/registration.yaml".path);
}; };
}; };
@@ -0,0 +1,95 @@
{ config, lib, pkgs, ... }:
let
cfg = config.custom.services.mautrix_discord;
in
{
options.custom.services.mautrix_discord = {
enable = lib.mkEnableOption "mautrix-discord bridge";
};
config = lib.mkIf cfg.enable {
nixpkgs.config.permittedInsecurePackages = [
"olm-3.2.16"
];
services.mautrix-discord.dataDir = lib.mkIf config.custom.impermanence.enable
"${config.custom.impermanence.base}/services/mautrix-discord";
age.secrets = {
"mautrix-discord/registration.yaml" = {
file = ./registration.yaml.age;
owner = "mautrix-discord";
group = "mautrix-discord";
};
"mautrix-discord/environment" = {
file = ./environment.age;
owner = "mautrix-discord";
group = "mautrix-discord";
};
"backups/mautrix-discord/restic/mig29" = {
file = ../../../secrets/restic/mig29.age;
};
};
services.postgresql = {
enable = true;
ensureDatabases = [ "mautrix-discord" ];
ensureUsers = [{
name = "mautrix-discord";
ensureDBOwnership = true;
}];
};
services.postgresqlBackup = {
enable = true;
compression = "none";
databases = [ "mautrix-discord" ];
};
services.restic.backups."mautrix-discord" = {
user = "root";
timerConfig = {
OnCalendar = "03:30";
RandomizedDelaySec = "60m";
};
repository = "rest:https://restic.${config.ogygia.domain}/mig29";
passwordFile = config.age.secrets."backups/mautrix-discord/restic/mig29".path;
paths = [
"${config.services.postgresqlBackup.location}/mautrix-discord.sql"
config.services.mautrix-discord.dataDir
];
};
services.mautrix-discord = {
enable = true;
registerToSynapse = false;
environmentFile = config.age.secrets."mautrix-discord/environment".path;
settings = {
homeserver = {
domain = "hillion.co.uk";
address = "http://boron.cx.${config.ogygia.domain}:8008";
};
appservice = {
hostname = "0.0.0.0";
port = 29334;
address = "http://warlock.cx.${config.ogygia.domain}:29334";
database = {
type = "postgres";
uri = "postgres:///mautrix-discord?host=/run/postgresql";
};
as_token = "$AS_TOKEN";
hs_token = "$HS_TOKEN";
bot.username = "discordbot";
};
bridge.permissions."@jake:hillion.co.uk" = "admin";
};
};
systemd.services.mautrix-discord = {
after = [ "postgresql-setup.service" ];
requires = [ "postgresql-setup.service" ];
};
};
}
Binary file not shown.
+10
View File
@@ -75,6 +75,7 @@ in
neb.cx.boron neb.cx.boron
neb.cx.rooster neb.cx.rooster
neb.cx.maverick neb.cx.maverick
neb.cx.warlock
neb.pop.stinger neb.pop.stinger
neb.rig.merlin neb.rig.merlin
neb.st.phoenix neb.st.phoenix
@@ -173,4 +174,13 @@ in
# Offline YouTube secrets # Offline YouTube secrets
"modules/services/offline-youtube/playlist.env.age".publicKeys = [ neb.st.phoenix ]; "modules/services/offline-youtube/playlist.env.age".publicKeys = [ neb.st.phoenix ];
# mautrix-discord bridge
"modules/services/mautrix-discord/registration.yaml.age".publicKeys = jake_users ++ [
neb.cx.boron # Synapse needs registration
neb.cx.warlock # Bridge needs registration
];
"modules/services/mautrix-discord/environment.age".publicKeys = jake_users ++ [
neb.cx.warlock # Bridge needs tokens
];
} }
+17 -16
View File
@@ -1,17 +1,18 @@
age-encryption.org/v1 age-encryption.org/v1
-> ssh-ed25519 iWiFbA ZwPWGTjircGCE2jAetHmpZm7CAIqnfVrOuUfhtRhw0A -> ssh-ed25519 iWiFbA 7Xmx8NaFllKUX36gJWRhpf7Ek/wokCAT4WuCpoez3Hc
uC4PkfbCup0/4j604k8zAcCNgU4HykMHu27Hwl0l3Eg EsppPEbmUususjIaHdijRkpohGWad+2moW20WuIx8Yw
-> ssh-ed25519 2Uo1TA 5CU1v9Rmn2ETyq3bbMrWJYZyhxy6gilCDLu9yY1Ri1A -> ssh-ed25519 2Uo1TA 6KiWbJx0VKqMcSIkmvpEXiQPVh5vTS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