forked from betamike/betamike-infra
move back to matterbridge for errything
This commit is contained in:
parent
f99cc5504c
commit
dd16d1f443
@ -22,28 +22,59 @@ in {
|
|||||||
isSystemUser = true;
|
isSystemUser = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
nixpkgs.overlays = [
|
||||||
|
(final: prev: {
|
||||||
|
matterbridge = prev.matterbridge.overrideAttrs (oldAttrs: rec {
|
||||||
|
version = "1.26.0";
|
||||||
|
|
||||||
|
src = prev.fetchFromGitHub {
|
||||||
|
owner = "42wim";
|
||||||
|
repo = "matterbridge";
|
||||||
|
rev = "v${version}";
|
||||||
|
sha256 = "sha256-APlnJUu/ttK/S2AxO+SadU2ttmEnU+js/3GUf3x0aSQ=";
|
||||||
|
};
|
||||||
|
});
|
||||||
|
})
|
||||||
|
];
|
||||||
|
|
||||||
services.matterbridge = let
|
services.matterbridge = let
|
||||||
config-file = pkgs.writeText "matterbridge.toml" ''
|
config-file = pkgs.writeText "matterbridge.toml" ''
|
||||||
[discord.cryptic]
|
[discord.cryptic]
|
||||||
Token="${secrets.matterbridge.discord.token}"
|
Token="${secrets.matterbridge.discord2.token}"
|
||||||
Server="${secrets.matterbridge.discord.server}"
|
Server="${secrets.matterbridge.discord2.server}"
|
||||||
RemoteNickFormat="{NICK} [{PROTOCOL}]"
|
RemoteNickFormat="{NICK} [{PROTOCOL}]: "
|
||||||
AutoWebhooks=true
|
AutoWebhooks=true
|
||||||
|
PreserveThreading=true
|
||||||
|
|
||||||
[slack.cryptic]
|
[slack.cryptic]
|
||||||
Token="${secrets.matterbridge.slack.token}"
|
Token="${secrets.matterbridge.slack.token}"
|
||||||
RemoteNickFormat="{NICK} [{PROTOCOL}]"
|
RemoteNickFormat="{NICK} [{PROTOCOL}]: "
|
||||||
|
PreserveThreading=true
|
||||||
|
|
||||||
# [[gateway]]
|
[matrix.wafflefarm]
|
||||||
# name="bot-test-gateway"
|
Server="https://matrix.waffle.farm"
|
||||||
# enable=true
|
Login="${secrets.matterbridge.matrix.username}"
|
||||||
# [[gateway.inout]]
|
Password="${secrets.matterbridge.matrix.password}"
|
||||||
# account="discord.cryptic"
|
RemoteNickFormat="{NICK} [{PROTOCOL}]: "
|
||||||
# channel="bot-test"
|
SpoofUsername=true
|
||||||
#
|
PreserveThreading=true
|
||||||
# [[gateway.inout]]
|
KeepQuotedReply=false
|
||||||
# account="slack.cryptic"
|
|
||||||
# channel="bot-test"
|
[[gateway]]
|
||||||
|
name="testgateway"
|
||||||
|
enable=true
|
||||||
|
|
||||||
|
[[gateway.inout]]
|
||||||
|
account="matrix.wafflefarm"
|
||||||
|
channel="#bridge-test:waffle.farm"
|
||||||
|
|
||||||
|
[[gateway.inout]]
|
||||||
|
account="slack.cryptic"
|
||||||
|
channel="bridge-test"
|
||||||
|
|
||||||
|
[[gateway.inout]]
|
||||||
|
account="discord.cryptic"
|
||||||
|
channel="bridge-test"
|
||||||
|
|
||||||
[[samechannelgateway]]
|
[[samechannelgateway]]
|
||||||
name="same-channel-gw"
|
name="same-channel-gw"
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
# adapted from https://nixos.org/manual/nixos/stable/index.html#module-services-matrix
|
# adapted from https://nixos.org/manual/nixos/stable/index.html#module-services-matrix
|
||||||
{ modulesPath, config, lib, pkgs, ... }:
|
{ modulesPath, config, lib, pkgs, ... }:
|
||||||
let
|
let
|
||||||
matrix-registration = import ../../matrix-registration/default.nix;
|
|
||||||
storage-device = "/dev/disk/by-id/scsi-0DO_Volume_matrix-storage";
|
storage-device = "/dev/disk/by-id/scsi-0DO_Volume_matrix-storage";
|
||||||
storage-dir = "/srv/matrix-data";
|
storage-dir = "/srv/matrix-data";
|
||||||
matrix-reg-dir = "${storage-dir}/matrix-registration";
|
|
||||||
slackbridge-dir = "${storage-dir}/slackbridge";
|
slackbridge-dir = "${storage-dir}/slackbridge";
|
||||||
pantalaimon-dir = "${storage-dir}/pantalaimon";
|
pantalaimon-dir = "${storage-dir}/pantalaimon";
|
||||||
secrets = builtins.fromJSON (builtins.readFile ./secrets.json);
|
secrets = builtins.fromJSON (builtins.readFile ./secrets.json);
|
||||||
@ -14,16 +12,13 @@ let
|
|||||||
discord-reg-dest-yaml = pkgs.writeText "discord-registration.yaml" "${discord-reg-source-yaml}";
|
discord-reg-dest-yaml = pkgs.writeText "discord-registration.yaml" "${discord-reg-source-yaml}";
|
||||||
discord-envs-src = (builtins.readFile ./discord_envs);
|
discord-envs-src = (builtins.readFile ./discord_envs);
|
||||||
discord-envs-dst = pkgs.writeText "discord_envs" "${discord-envs-src}";
|
discord-envs-dst = pkgs.writeText "discord_envs" "${discord-envs-src}";
|
||||||
fqdn =
|
fqdn = "${config.networking.hostName}.${config.networking.domain}";
|
||||||
let
|
|
||||||
join = hostName: domain: hostName + lib.optionalString (domain != null) ".${domain}";
|
|
||||||
in join config.networking.hostName config.networking.domain;
|
|
||||||
clientConfig = {
|
clientConfig = {
|
||||||
"m.homeserver".base_url = "https://${fqdn}";
|
"m.homeserver".base_url = "https://${fqdn}";
|
||||||
"server_name" = "${config.networking.domain}";
|
"server_name" = "${config.networking.domain}";
|
||||||
"m.identity_server" = {};
|
"m.identity_server" = {};
|
||||||
};
|
};
|
||||||
serverConfig."m.server" = "${config.services.matrix-synapse.settings.server_name}:443";
|
serverConfig."m.server" = "${fqdn}:443";
|
||||||
mkWellKnown = data: ''
|
mkWellKnown = data: ''
|
||||||
add_header Content-Type application/json;
|
add_header Content-Type application/json;
|
||||||
add_header Access-Control-Allow-Origin *;
|
add_header Access-Control-Allow-Origin *;
|
||||||
@ -40,8 +35,7 @@ in {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
environment.systemPackages = [ pkgs.jq pkgs.matrix-appservice-slack pkgs.pantalaimon pkgs.olm ];
|
||||||
environment.systemPackages = [ pkgs.jq matrix-registration pkgs.matrix-appservice-slack pkgs.pantalaimon pkgs.olm ];
|
|
||||||
services.openssh.enable = true;
|
services.openssh.enable = true;
|
||||||
networking.firewall.allowedTCPPorts = [ 22 80 443 ];
|
networking.firewall.allowedTCPPorts = [ 22 80 443 ];
|
||||||
|
|
||||||
@ -90,16 +84,9 @@ in {
|
|||||||
forceSSL = true;
|
forceSSL = true;
|
||||||
locations."= /.well-known/matrix/server".extraConfig = mkWellKnown serverConfig;
|
locations."= /.well-known/matrix/server".extraConfig = mkWellKnown serverConfig;
|
||||||
locations."= /.well-known/matrix/client".extraConfig = mkWellKnown clientConfig;
|
locations."= /.well-known/matrix/client".extraConfig = mkWellKnown clientConfig;
|
||||||
locations."/".extraConfig = ''
|
|
||||||
return 301 https://waffle.farm/register;
|
|
||||||
'';
|
|
||||||
locations."~ ^/(static|register)" = {
|
|
||||||
proxyPass = "http://localhost:5000";
|
|
||||||
};
|
|
||||||
locations."~ ^/slackbridge" = {
|
locations."~ ^/slackbridge" = {
|
||||||
proxyPass = "http://localhost:9898";
|
proxyPass = "http://localhost:9898";
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
# Reverse proxy for Matrix client-server and server-server communication
|
# Reverse proxy for Matrix client-server and server-server communication
|
||||||
${fqdn} = {
|
${fqdn} = {
|
||||||
@ -163,15 +150,6 @@ in {
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
extraConfigFiles = [ "${storage-dir}/matrix_cfg" ];
|
extraConfigFiles = [ "${storage-dir}/matrix_cfg" ];
|
||||||
# registration_shared_secret = secrets.matrix.registration_secret;
|
|
||||||
# extraConfig = ''
|
|
||||||
# allow_public_rooms_over_federation: true
|
|
||||||
# auto_join_rooms:
|
|
||||||
# - "#cryptic-chat:waffle.farm"
|
|
||||||
# app_service_config_files:
|
|
||||||
# - "${slack-reg-dest-yaml}"
|
|
||||||
# - "${discord-reg-dest-yaml}"
|
|
||||||
# '';
|
|
||||||
};
|
};
|
||||||
security.acme.acceptTerms = true;
|
security.acme.acceptTerms = true;
|
||||||
security.acme.certs = {
|
security.acme.certs = {
|
||||||
@ -179,64 +157,6 @@ in {
|
|||||||
"${config.networking.domain}".email = "mike@betamike.com";
|
"${config.networking.domain}".email = "mike@betamike.com";
|
||||||
"chat.${config.networking.domain}".email = "mike@betamike.com";
|
"chat.${config.networking.domain}".email = "mike@betamike.com";
|
||||||
};
|
};
|
||||||
users.users.matrix-registration = {
|
|
||||||
home = matrix-reg-dir;
|
|
||||||
createHome = true;
|
|
||||||
isNormalUser = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
systemd.services.matrix-registration = let
|
|
||||||
configFile = pkgs.writeText "matrix-reg-config.yaml" ''
|
|
||||||
server_location: 'https://matrix.waffle.farm:443'
|
|
||||||
base_url: ""
|
|
||||||
server_name: 'waffle.farm'
|
|
||||||
registration_shared_secret: '${secrets.matrix.registration_secret}'
|
|
||||||
admin_api_shared_secret: '${secrets.matrix.admin_api_secret}'
|
|
||||||
client_redirect: 'chat.waffle.farm'
|
|
||||||
client_logo: 'static/images/element-logo.png'
|
|
||||||
db: 'sqlite:///${matrix-reg-dir}/db.sqlite3'
|
|
||||||
host: 'localhost'
|
|
||||||
port: 5000
|
|
||||||
rate_limit: ["1000 per day", "100 per minute"]
|
|
||||||
allow_cors: false
|
|
||||||
ip_logging: false
|
|
||||||
logging:
|
|
||||||
disable_existing_loggers: false
|
|
||||||
version: 1
|
|
||||||
root:
|
|
||||||
level: DEBUG
|
|
||||||
handlers: [console]
|
|
||||||
formatters:
|
|
||||||
brief:
|
|
||||||
format: '%(name)s - %(levelname)s - %(message)s'
|
|
||||||
precise:
|
|
||||||
format: '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
|
|
||||||
handlers:
|
|
||||||
console:
|
|
||||||
class: logging.StreamHandler
|
|
||||||
level: INFO
|
|
||||||
formatter: brief
|
|
||||||
stream: ext://sys.stdout
|
|
||||||
password:
|
|
||||||
min_length: 8
|
|
||||||
username:
|
|
||||||
validation_regex: [] #list of regexes that the selected username must match. Example: '[a-zA-Z]\.[a-zA-Z]'
|
|
||||||
invalidation_regex: [] #list of regexes that the selected username must NOT match. Example: '(admin|support)'
|
|
||||||
'';
|
|
||||||
in {
|
|
||||||
enable = true;
|
|
||||||
after = [ "matrix-synapse.service" ];
|
|
||||||
bindsTo = [ "matrix-synapse.service" ];
|
|
||||||
description = "Matrix-registration daemon";
|
|
||||||
wantedBy = [ "multi-user.target" ];
|
|
||||||
serviceConfig = {
|
|
||||||
Type = "simple";
|
|
||||||
WorkingDirectory = matrix-registration;
|
|
||||||
ExecStart = "${matrix-registration}/bin/matrix-registration --config-path ${configFile} serve";
|
|
||||||
User = "matrix-registration";
|
|
||||||
Restart = "always";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
users.users.slackbridge = {
|
users.users.slackbridge = {
|
||||||
home = slackbridge-dir;
|
home = slackbridge-dir;
|
||||||
@ -244,90 +164,90 @@ username:
|
|||||||
isNormalUser = true;
|
isNormalUser = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.services.matrix-appservice-slack = let
|
# systemd.services.matrix-appservice-slack = let
|
||||||
slackbridge-config-file = pkgs.writeText "matrix-slack-bridge-config.yaml" ''
|
# slackbridge-config-file = pkgs.writeText "matrix-slack-bridge-config.yaml" ''
|
||||||
homeserver:
|
#homeserver:
|
||||||
server_name: waffle.farm
|
# server_name: waffle.farm
|
||||||
url: http://[::1]:8008
|
# url: http://[::1]:8008
|
||||||
media_url: "http://matrix.waffle.farm"
|
# media_url: "http://matrix.waffle.farm"
|
||||||
appservice_host: localhost
|
# appservice_host: localhost
|
||||||
appservice_port: 8090
|
# appservice_port: 8090
|
||||||
username_prefix: "slack_"
|
#username_prefix: "slack_"
|
||||||
|
|
||||||
db:
|
|
||||||
engine: "postgres"
|
|
||||||
connectionString: "postgresql://slackbridge_user:${secrets.matrix.slack_bridge.psql_password}@localhost/slack_bridge"
|
|
||||||
|
|
||||||
matrix_admin_room: "!tuUJADDNODYliJTxYK:waffle.farm"
|
|
||||||
|
|
||||||
rtm:
|
|
||||||
enable: true
|
|
||||||
logging: "debug"
|
|
||||||
|
|
||||||
slack_hook_port: 9898
|
|
||||||
inbound_uri_prefix: "https://waffle.farm/slackbridge/"
|
|
||||||
|
|
||||||
# Optional. Allow users to add channels dynamically by using oauth, or puppet themselves.
|
|
||||||
#
|
#
|
||||||
oauth2:
|
#db:
|
||||||
client_id: "4494054004.1702274627236"
|
# engine: "postgres"
|
||||||
client_secret: "${secrets.matrix.slack_bridge.client_secret}"
|
# connectionString: "postgresql://slackbridge_user:${secrets.matrix.slack_bridge.psql_password}@localhost/slack_bridge"
|
||||||
redirect_prefix: "https://waffle.farm/slackbridge/oauth"
|
#
|
||||||
|
#matrix_admin_room: "!tuUJADDNODYliJTxYK:waffle.farm"
|
||||||
# Optional. Enable metrics reporting on http://0.0.0.0:bridgePort/metrics which can be scraped by prometheus
|
#
|
||||||
enable_metrics: true
|
#rtm:
|
||||||
|
# enable: true
|
||||||
provisioning:
|
# logging: "debug"
|
||||||
enabled: true
|
#
|
||||||
require_public_room: false
|
#slack_hook_port: 9898
|
||||||
allow_private_channels: true
|
#inbound_uri_prefix: "https://waffle.farm/slackbridge/"
|
||||||
limits:
|
#
|
||||||
room_count: 20
|
## Optional. Allow users to add channels dynamically by using oauth, or puppet themselves.
|
||||||
team_count: 1
|
##
|
||||||
|
#oauth2:
|
||||||
puppeting:
|
# client_id: "4494054004.1702274627236"
|
||||||
enabled: true
|
# client_secret: "${secrets.matrix.slack_bridge.client_secret}"
|
||||||
onboard_users: true
|
# redirect_prefix: "https://waffle.farm/slackbridge/oauth"
|
||||||
|
#
|
||||||
logging:
|
## Optional. Enable metrics reporting on http://0.0.0.0:bridgePort/metrics which can be scraped by prometheus
|
||||||
console: "debug"
|
#enable_metrics: true
|
||||||
|
#
|
||||||
bot_profile:
|
#provisioning:
|
||||||
displayname: "Slack Bridger"
|
# enabled: true
|
||||||
|
# require_public_room: false
|
||||||
team_sync:
|
# allow_private_channels: true
|
||||||
T04EJ1L04:
|
# limits:
|
||||||
channels:
|
# room_count: 20
|
||||||
enabled: true
|
# team_count: 1
|
||||||
whitelist:
|
#
|
||||||
# bot-test
|
#puppeting:
|
||||||
- C04FKFUHK
|
# enabled: true
|
||||||
# generic-gaming
|
# onboard_users: true
|
||||||
- C2EEUE9UY
|
#
|
||||||
|
#logging:
|
||||||
alias_prefix: "slack_"
|
# console: "debug"
|
||||||
users:
|
#
|
||||||
enabled: true
|
#bot_profile:
|
||||||
# default for all other teams
|
# displayname: "Slack Bridger"
|
||||||
all:
|
#
|
||||||
channels:
|
#team_sync:
|
||||||
enabled: false
|
# T04EJ1L04:
|
||||||
|
# channels:
|
||||||
encryption:
|
# enabled: true
|
||||||
enabled: true
|
# whitelist:
|
||||||
pantalaimon_url: "http://localhost:8009"
|
# # bot-test
|
||||||
'';
|
# - C04FKFUHK
|
||||||
in {
|
# # generic-gaming
|
||||||
enable = false;
|
# - C2EEUE9UY
|
||||||
description = "matrix-appservice-slack daemon";
|
#
|
||||||
wantedBy = [ "multi-user.target" ];
|
# alias_prefix: "slack_"
|
||||||
serviceConfig = {
|
# users:
|
||||||
Type = "simple";
|
# enabled: true
|
||||||
ExecStart = "${pkgs.matrix-appservice-slack}/bin/matrix-appservice-slack -c ${slackbridge-config-file} -f ${slack-reg-dest-yaml} -p 8090";
|
# # default for all other teams
|
||||||
User = "slackbridge";
|
# all:
|
||||||
Restart = "always";
|
# channels:
|
||||||
};
|
# enabled: false
|
||||||
};
|
#
|
||||||
|
#encryption:
|
||||||
|
# enabled: true
|
||||||
|
# pantalaimon_url: "http://localhost:8009"
|
||||||
|
# '';
|
||||||
|
# in {
|
||||||
|
# enable = false;
|
||||||
|
# description = "matrix-appservice-slack daemon";
|
||||||
|
# wantedBy = [ "multi-user.target" ];
|
||||||
|
# serviceConfig = {
|
||||||
|
# Type = "simple";
|
||||||
|
# ExecStart = "${pkgs.matrix-appservice-slack}/bin/matrix-appservice-slack -c ${slackbridge-config-file} -f ${slack-reg-dest-yaml} -p 8090";
|
||||||
|
# User = "slackbridge";
|
||||||
|
# Restart = "always";
|
||||||
|
# };
|
||||||
|
# };
|
||||||
|
|
||||||
users.users.pantalaimon = {
|
users.users.pantalaimon = {
|
||||||
home = pantalaimon-dir;
|
home = pantalaimon-dir;
|
||||||
@ -357,18 +277,19 @@ IgnoreVerification = True
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
services.matrix-appservice-discord = {
|
# services.matrix-appservice-discord = {
|
||||||
enable = true;
|
# enable = true;
|
||||||
settings = {
|
# settings = {
|
||||||
bridge = {
|
# bridge = {
|
||||||
domain = "waffle.farm";
|
# domain = "waffle.farm";
|
||||||
homeserverUrl = "https://matrix.waffle.farm";
|
# homeserverUrl = "https://matrix.waffle.farm";
|
||||||
enableSelfServiceBridging = true;
|
# enableSelfServiceBridging = true;
|
||||||
disableJoinLeaveNotifications = true;
|
# disableJoinLeaveNotifications = true;
|
||||||
disableInviteNotifications = true;
|
# disableInviteNotifications = true;
|
||||||
};
|
# };
|
||||||
};
|
# };
|
||||||
url = "http://localhost:8008";
|
# url = "http://localhost:8008";
|
||||||
environmentFile = "${discord-envs-dst}";
|
# environmentFile = "${discord-envs-dst}";
|
||||||
};
|
# };
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user