about summary refs log tree commit diff
path: root/modules/services
diff options
context:
space:
mode:
Diffstat (limited to 'modules/services')
-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"
     ];
   };
 }