about summary refs log tree commit diff
path: root/modules/services/matrix-moderation.nix
diff options
context:
space:
mode:
authorsefidel <contact@sefidel.net>2023-03-29 20:54:19 +0900
committersefidel <contact@sefidel.net>2023-04-03 18:32:29 +0900
commitce06f43476863da90dc60dcee606d2b6c5a89a8e (patch)
tree5d14946330cb09ff0ebd97bee59407fccee4d860 /modules/services/matrix-moderation.nix
downloadinfra-ce06f43476863da90dc60dcee606d2b6c5a89a8e.tar.gz
infra-ce06f43476863da90dc60dcee606d2b6c5a89a8e.zip
project: initial commit
Diffstat (limited to 'modules/services/matrix-moderation.nix')
-rw-r--r--modules/services/matrix-moderation.nix52
1 files changed, 52 insertions, 0 deletions
diff --git a/modules/services/matrix-moderation.nix b/modules/services/matrix-moderation.nix
new file mode 100644
index 0000000..c8f0702
--- /dev/null
+++ b/modules/services/matrix-moderation.nix
@@ -0,0 +1,52 @@
+{ config, lib, ... }:
+
+# TODO: rename
+
+with lib;
+let
+  cfg = config.modules.services.matrix-moderation;
+in
+{
+  disabledModules = [
+    "services/matrix/mjolnir.nix"
+  ];
+
+  imports = [
+    ../../overlays/mjolnir-module
+  ];
+
+  options.modules.services.matrix-moderation = {
+    enable = mkEnableOption "matrix-moderation";
+    domain = mkOption { type = types.str; };
+    realHost = mkOption { type = types.str; default = "matrix.${cfg.domain}"; };
+    secrets.userPassword = mkOption { type = types.str; description = "path to the mjolnir password"; };
+  };
+
+  config = mkIf cfg.enable {
+
+    services.mjolnir = {
+      enable = true;
+      homeserverUrl = "https://${cfg.realHost}";
+      pantalaimon.enable = true;
+      pantalaimon.username = "abuse";
+      pantalaimon.passwordFile = cfg.secrets.userPassword;
+      managementRoom = "#moderation:${cfg.domain}";
+
+      settings = {
+        homeserverUrl = "http://127.0.0.1:8009";
+        automaticallyRedactForReasons = [
+          "spam"
+          "advertising"
+          "unwanted"
+        ];
+      };
+    };
+
+    systemd.services.mjolnir.after = [ "dendrite.service" ];
+
+    environment.persistence."/persist".directories = [
+      "/var/lib/private/pantalaimon-mjolnir"
+      "/var/lib/mjolnir"
+    ];
+  };
+}