about summary refs log tree commit diff
path: root/modules
diff options
context:
space:
mode:
authorsefidel <contact@sefidel.net>2023-12-22 01:51:21 +0900
committersefidel <contact@sefidel.net>2023-12-22 01:51:21 +0900
commitae5670a754b50462120ccf7eaaa8ca70301a72b0 (patch)
treedaad2d97ad8af247503568f57c6b76943365b268 /modules
parent249adb0e6ca1f7b1844122633e8e1a8696d10315 (diff)
downloadinfra-ae5670a754b50462120ccf7eaaa8ca70301a72b0.tar.gz
infra-ae5670a754b50462120ccf7eaaa8ca70301a72b0.zip
feat(modules/matrix-bridge): add mautrix-discord
Diffstat (limited to 'modules')
-rw-r--r--modules/services/matrix-bridge.nix49
1 files changed, 48 insertions, 1 deletions
diff --git a/modules/services/matrix-bridge.nix b/modules/services/matrix-bridge.nix
index 3422a76..c70942f 100644
--- a/modules/services/matrix-bridge.nix
+++ b/modules/services/matrix-bridge.nix
@@ -7,6 +7,7 @@ in
 {
   imports = [
     ../../overlays/mautrix-signal-module.nix
+    ../../overlays/mautrix-discord-module.nix
   ];
 
   options.modules.services.matrix-bridge = {
@@ -179,16 +180,56 @@ in
       };
     };
 
+    services.mautrix-discord = {
+      enable = true;
+      environmentFile = cfg.secrets.mautrix-envs;
+      serviceDependencies = [ "matrix-synapse.service" ];
+
+      settings = {
+        homeserver.address = "https://${cfg.realHost}";
+        homeserver.domain = cfg.domain;
+        homeserver.verify_ssl = true;
+        appservice = {
+          address = "http://localhost:29320";
+          port = 29320;
+          database = {
+            type = "postgres";
+            uri = "postgres://mautrix-discord:@/mautrix-discord?host=/run/postgresql";
+          };
+          bot_avatar = "mxc://maunium.net/nIdEykemnwdisvHbpxflpDlC";
+          id = "discord";
+          max_body_size = 1;
+          provisioning.enabled = false;
+        };
+
+        bridge = {
+          username_template = "dsc_{{.}}";
+          delivery_receipts = true;
+          encryption = {
+            allow = true;
+            default = true;
+            require = true;
+            allow_key_sharing = true;
+          };
+          permissions = {
+            "@sef:exotic.sh" = "admin";
+            "exotic.sh" = "full";
+          };
+        };
+      };
+    };
+
 
     environment.persistence."/persist".directories = [
       "/var/lib/private/mautrix-telegram"
       "/var/lib/private/mautrix-signal"
       "/var/lib/private/mautrix-whatsapp"
+      "/var/lib/private/mautrix-discord"
       "/var/lib/signald"
     ];
 
     modules.services.postgresql.enable = true;
-    services.postgresql.ensureDatabases = [ "mautrix-telegram" "mautrix-signal" "mautrix-whatsapp" ];
+    services.postgresql.ensureDatabases = [ "mautrix-telegram" "mautrix-signal" "mautrix-whatsapp" "mautrix-discord" ];
     services.postgresql.ensureUsers = [
       {
         name = "mautrix-telegram";
@@ -202,18 +243,24 @@ in
         name = "mautrix-whatsapp";
         ensureDBOwnership = true;
       }
+      {
+        name = "mautrix-discord";
+        ensureDBOwnership = true;
+      }
     ];
 
     systemd.services.matrix-synapse.serviceConfig.LoadCredential = [
       "mautrix-telegram:/var/lib/mautrix-telegram/telegram-registration.yaml"
       "mautrix-signal:/var/lib/mautrix-signal/signal-registration.yaml"
       "mautrix-whatsapp:/var/lib/mautrix-whatsapp/whatsapp-registration.yaml"
+      "mautrix-discord:/var/lib/mautrix-discord/discord-registration.yaml"
     ];
 
     services.matrix-synapse.settings.app_service_config_files = [
       "/run/credentials/matrix-synapse.service/mautrix-telegram"
       "/run/credentials/matrix-synapse.service/mautrix-signal"
       "/run/credentials/matrix-synapse.service/mautrix-whatsapp"
+      "/run/credentials/matrix-synapse.service/mautrix-discord"
     ];
   };
 }