From dddc92877c30384f6c1eb29267add64cd42d8b0a Mon Sep 17 00:00:00 2001 From: h7x4 Date: Wed, 12 Jul 2023 01:55:42 +0200 Subject: [PATCH] tsuki/matrix/matrix-appservice-irc: enable lainchan irc bouncer --- .../matrix/bridges/matrix-appservice-irc.nix | 68 ++++++++++++++++++- hosts/tsuki/services/matrix/default.nix | 5 +- 2 files changed, 69 insertions(+), 4 deletions(-) diff --git a/hosts/tsuki/services/matrix/bridges/matrix-appservice-irc.nix b/hosts/tsuki/services/matrix/bridges/matrix-appservice-irc.nix index 9b40796..96276b7 100644 --- a/hosts/tsuki/services/matrix/bridges/matrix-appservice-irc.nix +++ b/hosts/tsuki/services/matrix/bridges/matrix-appservice-irc.nix @@ -1,13 +1,77 @@ -{ secrets, ... }: -{ +{ config, secrets, ... }: let + cfg = config.services.matrix-appservice-irc; +in { services.matrix-appservice-irc = { enable = true; + registrationUrl = "http://localhost:${toString cfg.port}"; settings = { + homeserver = { + url = "https://matrix.nani.wtf"; + domain = "nani.wtf"; + enablePresence = true; + }; + database = { engine = "postgres"; connectionString = "postgres://matrix-appservice-irc:@localhost:${toString secrets.ports.postgres}/matrix-appservice-irc?sslmode=disable"; }; + + ircService.servers."irc.lainchan.org" = { + name = "lainchan"; + port = 6697; + ssl = true; + networkId = "ircLainchanOrg"; + + botConfig.enable = false; + + dynamicChannels = { + enabled = true; + createAlias = true; + aliasTemplate = "#lainchanirc_$CHANNEL"; + published = true; + useHomeserverDirectory = true; + joinRule = "public"; + federate = true; + }; + + matrixClients = { + userTemplate = "@lainanon_$NICK"; + }; + + ircClients = { + nickTemplate = "$LOCALPART[m]"; + allowNickChanges = true; + }; + + membershipLists = { + enabled = true; + global = { + ircToMatrix = { + initial = true; + incremental = true; + }; + matrixToIrc = { + initial = true; + incremental = true; + }; + }; + }; + + permissions."@h7x4:nani.wtf" = "admin"; + + # TODO: Port forward + ident.enable = true; + + # TODO: Metrics + }; }; }; + + systemd.services.matrix-appservice-irc = { + requires = [ + "matrix-synapse.service" + "postgresql.service" + ]; + }; } diff --git a/hosts/tsuki/services/matrix/default.nix b/hosts/tsuki/services/matrix/default.nix index be66a1d..cbe0201 100644 --- a/hosts/tsuki/services/matrix/default.nix +++ b/hosts/tsuki/services/matrix/default.nix @@ -3,8 +3,7 @@ imports = [ ./bridges/mautrix-facebook.nix ./bridges/mx-puppet-discord.nix - # TODO: fix irc service - # ./bridges/matrix-appservice-irc.nix + ./bridges/matrix-appservice-irc.nix ./postgres.nix ./coturn.nix @@ -58,6 +57,7 @@ enable_registration = false; registration_shared_secret = secrets.keys.matrix.registration-shared-secret; + allow_public_rooms_over_federation = true; # password_config.enabled = lib.mkForce false; @@ -79,6 +79,7 @@ "/var/lib/matrix-synapse/discord-registration.yaml" # (pkgs.writeText "facebook-registrations.yaml" (builtins.toJSON config.services.mautrix-facebook.registrationData)) "/var/lib/matrix-synapse/facebook-registration.yaml" + "/var/lib/matrix-synapse/irc-registration.yml" ]; # redis.enabled = true;