2020-12-28 18:42:26 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
2022-07-20 16:34:14 +02:00
|
|
|
with pkgs;
|
|
|
|
|
|
|
|
# NOTE Reference the environment variable set in the corresponding agenix secret
|
2022-10-23 17:34:55 +02:00
|
|
|
let
|
|
|
|
database = {
|
|
|
|
connection_string = "$DB_STRING";
|
|
|
|
max_open_conns = 100;
|
|
|
|
max_idle_conns = 5;
|
|
|
|
conn_max_lifetime = -1;
|
|
|
|
};
|
2022-07-20 16:34:14 +02:00
|
|
|
|
|
|
|
in {
|
2020-12-28 18:42:26 +01:00
|
|
|
# Matrix server configuration
|
2022-07-20 16:34:14 +02:00
|
|
|
services.dendrite = {
|
2020-12-28 18:42:26 +01:00
|
|
|
enable = true;
|
2022-07-20 16:34:14 +02:00
|
|
|
httpPort = 8008;
|
|
|
|
environmentFile = config.age.secrets.dendrite-postgres.path;
|
|
|
|
loadCredential = [ "private_key:${config.age.secrets.dendrite.path}" ];
|
2022-03-21 16:24:28 +01:00
|
|
|
settings = {
|
2022-07-20 16:34:14 +02:00
|
|
|
global = {
|
|
|
|
server_name = "coolneng.duckdns.org";
|
|
|
|
private_key = config.age.secrets.dendrite.path;
|
|
|
|
inherit database;
|
2022-10-23 17:34:55 +02:00
|
|
|
dns_cache.enabled = true;
|
2022-07-20 16:34:14 +02:00
|
|
|
};
|
|
|
|
# HACK Inherit postgres connection string for the rest of the DBs
|
2022-07-20 19:18:10 +02:00
|
|
|
app_service_api = {
|
|
|
|
inherit database;
|
|
|
|
config_files = [
|
|
|
|
"/var/lib/matrix-as-facebook/facebook-registration.yaml"
|
|
|
|
"/var/lib/matrix-as-signal/signal-registration.yaml"
|
|
|
|
"/var/lib/matrix-as-telegram/telegram-registration.yaml"
|
|
|
|
];
|
|
|
|
};
|
2022-07-20 16:34:14 +02:00
|
|
|
media_api = { inherit database; };
|
|
|
|
room_server = { inherit database; };
|
|
|
|
push_server = { inherit database; };
|
|
|
|
mscs = {
|
|
|
|
inherit database;
|
|
|
|
mscs = [ "msc2836" "msc2946" ];
|
|
|
|
};
|
|
|
|
sync_api = { inherit database; };
|
|
|
|
key_server = { inherit database; };
|
|
|
|
federation_api = { inherit database; };
|
|
|
|
user_api = {
|
|
|
|
account_database = database;
|
|
|
|
device_database = database;
|
|
|
|
};
|
2022-03-21 16:24:28 +01:00
|
|
|
};
|
2020-12-28 18:42:26 +01:00
|
|
|
};
|
|
|
|
|
2022-07-20 16:34:14 +02:00
|
|
|
# Matrix bridges
|
|
|
|
services.matrix-appservices = {
|
|
|
|
homeserver = "dendrite";
|
2022-07-20 19:18:10 +02:00
|
|
|
homeserverDomain = "coolneng.duckdns.org";
|
|
|
|
homeserverURL = "https://matrix.coolneng.duckdns.org";
|
2022-07-20 16:34:14 +02:00
|
|
|
addRegistrationFiles = true;
|
|
|
|
services = {
|
|
|
|
telegram = {
|
2021-02-03 18:38:41 +01:00
|
|
|
port = 8118;
|
2022-07-20 16:34:14 +02:00
|
|
|
format = "mautrix-python";
|
|
|
|
package = mautrix-telegram;
|
2022-07-20 22:38:20 +02:00
|
|
|
serviceConfig.EnvironmentFile = config.age.secrets.telegram.path;
|
2022-07-22 17:14:00 +02:00
|
|
|
settings = {
|
2022-11-14 00:58:06 +01:00
|
|
|
homeserver.software = "standard";
|
2022-07-22 17:14:00 +02:00
|
|
|
telegram = {
|
|
|
|
api_id = "$API_ID";
|
|
|
|
api_hash = "$API_HASH";
|
|
|
|
};
|
|
|
|
bridge = {
|
|
|
|
permissions."@coolneng:coolneng.duckdns.org" = "admin";
|
|
|
|
backfill.normal_groups = true;
|
|
|
|
};
|
2022-07-20 22:38:20 +02:00
|
|
|
};
|
2022-07-20 16:34:14 +02:00
|
|
|
};
|
|
|
|
facebook = {
|
|
|
|
port = 8228;
|
|
|
|
format = "mautrix-python";
|
|
|
|
package = mautrix-facebook;
|
2022-11-02 22:21:36 +01:00
|
|
|
settings.homeserver.software = "standard";
|
2022-07-20 16:34:14 +02:00
|
|
|
};
|
|
|
|
signal = {
|
|
|
|
port = 8338;
|
|
|
|
format = "mautrix-python";
|
|
|
|
package = mautrix-signal;
|
|
|
|
serviceConfig = {
|
|
|
|
StateDirectory = [ "matrix-as-signal" "signald" ];
|
|
|
|
JoinNamespaceOf = "signald.service";
|
|
|
|
SupplementaryGroups = [ "signald" ];
|
|
|
|
};
|
2022-11-14 00:58:06 +01:00
|
|
|
settings = {
|
|
|
|
homeserver.software = "standard";
|
|
|
|
signal = {
|
|
|
|
socket_path = config.services.signald.socketPath;
|
|
|
|
outgoing_attachment_dir = "/var/lib/signald/tmp";
|
|
|
|
};
|
2022-07-20 16:34:14 +02:00
|
|
|
};
|
2020-12-28 18:42:26 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2022-07-20 16:34:14 +02:00
|
|
|
|
|
|
|
# Additional settings for mautrix-signal
|
2022-07-20 22:37:52 +02:00
|
|
|
services.signald = {
|
|
|
|
enable = true;
|
|
|
|
user = "matrix-as-signal";
|
|
|
|
};
|
2022-07-20 16:34:14 +02:00
|
|
|
systemd.services.matrix-as-signal = {
|
|
|
|
requires = [ "signald.service" ];
|
|
|
|
after = [ "signald.service" ];
|
2022-11-14 12:27:25 +01:00
|
|
|
unitConfig.JoinsNamespaceOf = "signald.service";
|
2022-08-29 21:41:53 +02:00
|
|
|
path = [ ffmpeg ];
|
2022-07-20 16:34:14 +02:00
|
|
|
};
|
|
|
|
|
2022-11-14 12:27:25 +01:00
|
|
|
# Enable voice messages for facebook
|
|
|
|
systemd.services.matrix-as-facebook.path = [ ffmpeg ];
|
|
|
|
|
2020-12-28 18:42:26 +01:00
|
|
|
}
|