about summary refs log tree commit diff
path: root/modules/services/matrix-moderation.nix
blob: f2b76ebc0a5832aefd416e14c49881bc1d37207b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
{ config, lib, ... }:

# TODO: rename

with lib;
let
  cfg = config.modules.services.matrix-moderation;
in
{
  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"
    ];
  };
}