From 7a9759ef715787648167a6bbd34e3e3a31eba919 Mon Sep 17 00:00:00 2001 From: Daniel Olsen Date: Mon, 13 Feb 2023 02:21:27 +0100 Subject: [PATCH] matrix: Add mjolnir as a moderation bot --- hosts/jokum/services/matrix/default.nix | 1 + hosts/jokum/services/matrix/mjolnir.nix | 54 +++++++++++++++++++++++++ secrets/jokum/jokum.yaml | 6 ++- 3 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 hosts/jokum/services/matrix/mjolnir.nix diff --git a/hosts/jokum/services/matrix/default.nix b/hosts/jokum/services/matrix/default.nix index d8ffccd..8d6f564 100644 --- a/hosts/jokum/services/matrix/default.nix +++ b/hosts/jokum/services/matrix/default.nix @@ -7,6 +7,7 @@ ./synapse-admin.nix ./element.nix ./coturn.nix + ./mjolnir.nix ./discord.nix ]; diff --git a/hosts/jokum/services/matrix/mjolnir.nix b/hosts/jokum/services/matrix/mjolnir.nix new file mode 100644 index 0000000..e1611b7 --- /dev/null +++ b/hosts/jokum/services/matrix/mjolnir.nix @@ -0,0 +1,54 @@ +{ config, lib, ... }: + +{ + sops.secrets."matrix/mjolnir/access_token" = { + owner = config.users.users.mjolnir.name; + group = config.users.users.mjolnir.group; + }; + + services.mjolnir = { + enable = true; + pantalaimon.enable = false; + homeserverUrl = config.services.matrix-synapse-next.settings.public_baseurl; + accessTokenFile = config.sops.secrets."matrix/mjolnir/access_token".path; + managementRoom = "!gsdeCoWjvYRBrzuiRq:pvv.ntnu.no"; + protectedRooms = map (a: "https://matrix.to/#/${a}") [ + "#pvv:pvv.ntnu.no" + "#stand:pvv.ntnu.no" + "#music:pvv.ntnu.no" + "#arts-and-crafts:pvv.ntnu.no" + "#programming:pvv.ntnu.no" + "#talks-and-texts:pvv.ntnu.no" + "#job-offers:pvv.ntnu.no" + "#vaffling:pvv.ntnu.no" + "#pvv-fadder:pvv.ntnu.no" + "#offsite:pvv.ntnu.no" + "#help:pvv.ntnu.no" + "#garniske-algoritmer:pvv.ntnu.no" + "#bouldering:pvv.ntnu.no" + "#filmclub:pvv.ntnu.no" + "#video-games:pvv.ntnu.no" + "#board-games:pvv.ntnu.no" + "#tabletop-rpgs:pvv.ntnu.no" + "#anime:pvv.ntnu.no" + "#general:pvv.ntnu.no" + "#announcements:pvv.ntnu.no" + "#memes:pvv.ntnu.no" + + "#drift:pvv.ntnu.no" + "#notifikasjoner:pvv.ntnu.no" + "#forespoersler:pvv.ntnu.no" + "#krisekanalen:pvv.ntnu.no" + + "#styret:pvv.ntnu.no" + ]; + + settings = { + admin.enableMakeRoomAdminCommand = true; + }; + + # Module wants it even when not using pantalaimon + # TODO: Fix upstream module in nixpkgs + pantalaimon.username = "bot_admin"; + }; +} diff --git a/secrets/jokum/jokum.yaml b/secrets/jokum/jokum.yaml index 22b264d..372861f 100644 --- a/secrets/jokum/jokum.yaml +++ b/secrets/jokum/jokum.yaml @@ -6,6 +6,8 @@ matrix: signing_key: ENC[AES256_GCM,data:3EeV+9X9TtqhBL7QyULTS7tNyH7ayhe88B7UtNZ/TMlQSW2E1WtSVEecqs+097A1SmdKoYVr6iz0ew==,iv:TDfAdYROu7o7FIwn6oOs60surQ7zFy0+9bqhx8LtwXg=,tag:8MpNBw5TbDMxXHF9+tmZfQ==,type:str] coturn: static-auth-secret: ENC[AES256_GCM,data:bDVbTU3QaanU0fPhQF4Fil4=,iv:MVoFWgqHm88JXaCYa5l57SkX3fSmP97Z7IzvwumHWY8=,tag:ZX121OshXiLC6eRxz2Be0g==,type:str] + mjolnir: + access_token: ENC[AES256_GCM,data:z+BG3nJyUTrJJq0eGNzT3tFatKXffgBzg3E608pqBaPvtJYsnEy4mo1vZig=,iv:VGdnprNYOArhLdY38B1BO/V9YiYGZEy39gnJyh8atgY=,tag:qJ+UryjNPTH0F6ZP5JJlEw==,type:str] registrations: mx-puppet-discord: ENC[AES256_GCM,data:nvWSaZ4we8BD50Op/bZMrlMXGBwzvG3IXGPGJe2paCZ10tTm9v4+aYGYhILNhcQM095AD9KdEJ44TAyPxZ/c5iYLqb/LJzEpa5X2jKoiF6r7PjNFGevKQs7fzJk4Y9MxHwZ2KJT+uHjtXF8erJvFDs3S3WgmuAQW1U9b5fYQNc4ZF0tY+BsWU2ehqMejpx7w93TkcIiZY7Uoj4kPMEp8aI6v/7VPIjM9g7b+R5KGZ1/yIpiNCzZuT+x2mxCtqGfbOynWON8PaCIojp7sbLaRWhX2bd4GG2wP3T5MsgwjJzQSfyXjK1Dyxzr8fVmh0R2mJoZHTYNQLLwYncLwqXQEHr6tXNWPTwxPslW+BdLsp/8//m0F04vUf4Z0dbf22NSaPkH9GdRLB3zXh07VxqG+B7OvAjDULHUmA5uwgtZq9h0G73TWDJ8U75eAxrTdsgQgmIsyhpLljFW2QSnOPL/93ieovh5qRgXjgyqrljDOkB+fhC0gdQalPeBM8l5zPI8aaJsVp/l15rx4nUIrFka0g+v+SRhAIPtQAKA=,iv:3gzyGz7T9PK/J92X46YXYT98bpTnx1uPiiwXuls/kOA=,tag:Vm+zNmA53HIb2dP8FIgP6Q==,type:str] sops: @@ -41,8 +43,8 @@ sops: SytjNlF0M1J2WDZzV05EQ0dDMU9EcW8KoCFywdfzF7197F3YdF37P43x0D+08+tt V86bls9usaxb3hfx+QS+gS+8TR1gN3fzQ5+zhkuawP0esgvUvSdOaQ== -----END AGE ENCRYPTED FILE----- - lastmodified: "2023-02-12T23:57:03Z" - mac: ENC[AES256_GCM,data:ZqzcX0DcOwvlpZ1GMBdIJL6xbEn+xcA4YRWl0OfTLX0sG45vh8pWiIhsb1aVxtAKW3pYAyQL0vRagPIz1f5/2BwbMW1hJORjH5p4BpFZvYm9/xYn34T8q5YVBsc4FBnH0+TouR8VyXIce017WKDkPqIjsdzYMgbxQ24pPOQSNJw=,iv:guVz8mQ5PSF94Roho0q4+Ihz+ZKCEZYNnpjnv8IbGtg=,tag:CKx+m5zNr5tzjvwd4Effdw==,type:str] + lastmodified: "2023-02-13T00:12:03Z" + mac: ENC[AES256_GCM,data:FolV94dIwYSL5r1ZHTPdmqMKVTAhrnePG+5M4S1H/wBYbED3sr6oPPmmxwiwm5E4K0YR1+ou4yR/vGTV3lfRdxIGWhfAT0WW8WGTZVIlcJCEk5H7Rels6rkma12BCjZ1zOGjZZCcFTm+4NI2KNv+zTc29zry4539jkkxk+8Skog=,iv:KBxSFVaFI3S5J9xG2Lc7FINUI8TRKxPtrbP3f2wXkHo=,tag:TWAtix03ZnB71+O7cF8b4A==,type:str] pgp: - created_at: "2023-01-21T21:53:31Z" enc: |