servo: matrix: break the discord bridge out of default.nix

This commit is contained in:
colin 2022-10-06 01:54:46 -07:00
parent e1cd1be48d
commit a5393c3c84
2 changed files with 73 additions and 58 deletions

View File

@ -3,11 +3,14 @@
{ config, lib, ... }:
{
imports = [
./discord.nix
];
sane.impermanence.service-dirs = [
# TODO: mode?
# user and group are both "matrix-appservice-irc"
{ user = "993"; group = "992"; directory = "/var/lib/matrix-appservice-irc"; }
{ user = "matrix-appservice-discord"; group = "matrix-appservice-discord"; directory = "/var/lib/matrix-appservice-discord"; }
{ user = "224"; group = "224"; directory = "/var/lib/matrix-synapse"; }
];
services.matrix-synapse.enable = true;
@ -65,7 +68,6 @@
# ''];
services.matrix-synapse.settings.app_service_config_files = [
"/var/lib/matrix-appservice-irc/registration.yml" # auto-created by irc appservice
"/var/lib/matrix-appservice-discord/discord-registration.yaml" # auto-created by discord appservice
];
# new users may be registered on the CLI:
@ -80,57 +82,6 @@
# create a token with limited uses:
# curl -d '{ "uses_allowed": 1 }' --header "Authorization: Bearer <my_token>" localhost:8008/_synapse/admin/v1/registration_tokens/new
# Discord bridging
# docs: https://github.com/matrix-org/matrix-appservice-discord
services.matrix-appservice-discord.enable = true;
services.matrix-appservice-discord.settings = {
bridge = {
homeserverUrl = "http://127.0.0.1:8008";
domain = "uninsane.org";
adminMxid = "admin.matrix@uninsane.org";
# self-service bridging is when a Matrix user bridges by DMing @_discord_bot:<HS>
# i don't know what the alternative is :?
enableSelfServiceBridging = true;
presenceInterval = 30000; # milliseconds
# allows matrix users to search for Discord channels (somehow?)
disablePortalBridging = false;
# disableReadReceipts = true;
# these are Matrix -> Discord
disableJoinLeaveNotifications = true;
disableInviteNotifications = true;
disableRoomTopicNotifications = true;
};
# these are marked as required in the yaml schema
auth = {
# apparently not needed if you provide them as env vars (below).
# clientId = "FILLME";
# botToken = "FILLME";
usePrivilegedIntents = false;
};
logging = {
# silly, verbose, info, http, warn, error, silent
console = "verbose";
};
};
# contains what's ordinarily put into auth.clientId, auth.botToken
# i.e. `APPSERVICE_DISCORD_AUTH_CLIENT_I_D=...` and `APPSERVICE_DISCORD_AUTH_BOT_TOKEN=...`
services.matrix-appservice-discord.environmentFile = config.sops.secrets.matrix_appservice_discord_env.path;
systemd.services.matrix-appservice-discord.serviceConfig = {
# fix up to not use /var/lib/private, but just /var/lib
DynamicUser = lib.mkForce false;
User = "matrix-appservice-discord";
Group = "matrix-appservice-discord";
};
users.groups.matrix-appservice-discord = {};
users.users.matrix-appservice-discord = {
description = "User for the Matrix-Discord bridge";
group = "matrix-appservice-discord";
isSystemUser = true;
};
users.users.matrix-appservice-discord.uid = 2134; # TODO: move to allocations
users.groups.matrix-appservice-discord.gid = 2134; # TODO
# IRC bridging
# note: Rizon allows only FOUR simultaneous IRC connections per IP: https://wiki.rizon.net/index.php?title=Connection/Session_Limit_Exemptions
@ -221,9 +172,4 @@
sopsFile = ../../../../secrets/servo.yaml;
owner = config.users.users.matrix-synapse.name;
};
sops.secrets.matrix_appservice_discord_env = {
sopsFile = ../../../../secrets/servo/matrix_appservice_discord_env.bin;
owner = config.users.users.matrix-appservice-discord.name;
format = "binary";
};
}

View File

@ -0,0 +1,69 @@
{ config, lib, ... }:
{
sane.impermanence.service-dirs = [
{ user = "matrix-appservice-discord"; group = "matrix-appservice-discord"; directory = "/var/lib/matrix-appservice-discord"; }
];
sops.secrets.matrix_appservice_discord_env = {
sopsFile = ../../../../secrets/servo/matrix_appservice_discord_env.bin;
owner = config.users.users.matrix-appservice-discord.name;
format = "binary";
};
services.matrix-synapse.settings.app_service_config_files = [
# auto-created by discord appservice
"/var/lib/matrix-appservice-discord/discord-registration.yaml"
];
# Discord bridging
# docs: https://github.com/matrix-org/matrix-appservice-discord
services.matrix-appservice-discord.enable = true;
services.matrix-appservice-discord.settings = {
bridge = {
homeserverUrl = "http://127.0.0.1:8008";
domain = "uninsane.org";
adminMxid = "admin.matrix@uninsane.org";
# self-service bridging is when a Matrix user bridges by DMing @_discord_bot:<HS>
# i don't know what the alternative is :?
enableSelfServiceBridging = true;
presenceInterval = 30000; # milliseconds
# allows matrix users to search for Discord channels (somehow?)
disablePortalBridging = false;
# disableReadReceipts = true;
# these are Matrix -> Discord
disableJoinLeaveNotifications = true;
disableInviteNotifications = true;
disableRoomTopicNotifications = true;
};
# these are marked as required in the yaml schema
auth = {
# apparently not needed if you provide them as env vars (below).
# clientId = "FILLME";
# botToken = "FILLME";
usePrivilegedIntents = false;
};
logging = {
# silly, verbose, info, http, warn, error, silent
console = "verbose";
};
};
# contains what's ordinarily put into auth.clientId, auth.botToken
# i.e. `APPSERVICE_DISCORD_AUTH_CLIENT_I_D=...` and `APPSERVICE_DISCORD_AUTH_BOT_TOKEN=...`
services.matrix-appservice-discord.environmentFile = config.sops.secrets.matrix_appservice_discord_env.path;
systemd.services.matrix-appservice-discord.serviceConfig = {
# fix up to not use /var/lib/private, but just /var/lib
DynamicUser = lib.mkForce false;
User = "matrix-appservice-discord";
Group = "matrix-appservice-discord";
};
users.groups.matrix-appservice-discord = {};
users.users.matrix-appservice-discord = {
description = "User for the Matrix-Discord bridge";
group = "matrix-appservice-discord";
isSystemUser = true;
};
users.users.matrix-appservice-discord.uid = 2134; # TODO: move to allocations
users.groups.matrix-appservice-discord.gid = 2134; # TODO
}