nixos-config/config/services/synapse.nix

190 lines
5 KiB
Nix
Raw Normal View History

2022-06-12 15:39:15 +00:00
{
pkgs,
lib,
config,
...
}: {
2022-05-01 06:50:10 +00:00
services.matrix-synapse = {
enable = true;
settings = {
2023-04-18 16:14:54 +00:00
app_service_config_files = [
config.sops.secrets."synapse/mautrix-discord".path
config.sops.secrets."synapse/mautrix-telegram".path
config.sops.secrets."synapse/mautrix-whatsapp".path
2024-06-26 05:11:44 +00:00
config.sops.secrets."synapse/doublepuppet".path
2024-09-24 11:34:25 +00:00
config.sops.secrets."synapse/mautrix-slack".path
2023-04-18 16:14:54 +00:00
];
2022-05-01 06:50:10 +00:00
server_name = "chir.rs";
public_baseurl = "https://matrix.chir.rs/";
2022-11-23 15:58:57 +00:00
default_room_version = 10;
2022-06-12 15:39:15 +00:00
listeners = [
{
port = 8008;
tls = false;
type = "http";
x_forwarded = true;
2023-12-10 20:27:33 +00:00
bind_addresses = ["::" "0.0.0.0"];
2022-06-12 15:39:15 +00:00
resources = [
{
names = ["client" "federation" "metrics"];
compress = false;
}
];
}
];
2022-05-01 06:50:10 +00:00
admin_contact = "mailto:lotte@chir.rs";
2022-08-19 08:20:55 +00:00
retention = {
enabled = true;
2022-11-21 14:08:24 +00:00
purge_jobs = [
{
longest_max_lifetime = "3d";
interval = "12h";
}
{
shortest_max_lifetime = "3d";
interval = "1d";
}
];
2022-08-19 08:20:55 +00:00
};
2022-05-01 06:50:10 +00:00
database = {
name = "psycopg2";
txn_limit = 10000;
args = {
host = "/run/postgresql";
user = "matrix-synapse";
database = "synapse";
};
};
enable_media_repo = false;
url_preview_enabled = true;
url_preview_ip_range_blacklist = [
"127.0.0.0/8"
"10.0.0.0/8"
"172.16.0.0/12"
"192.168.0.0/16"
"100.64.0.0/10"
"192.0.0.0/24"
"169.254.0.0/16"
"192.88.99.0/24"
"198.18.0.0/15"
"192.0.2.0/24"
"198.51.100.0/24"
"203.0.113.0/24"
"224.0.0.0/4"
"fe80::/10"
"fc00::/7"
"2001:db8::/32"
"ff00::/8"
"fec0::/10"
];
enable_registration = false;
signing_key_path = config.sops.secrets."services/synapse/private_key".path;
2022-05-03 09:31:27 +00:00
enable_metrics = true;
2022-05-03 19:25:44 +00:00
experimental_features = {
2022-11-24 09:21:48 +00:00
msc3026_enabled = true;
2022-05-03 19:25:44 +00:00
msc2716_enabled = true;
2022-11-24 09:21:48 +00:00
msc3244_enabled = true;
msc3266_enabled = true;
2023-03-18 09:16:33 +00:00
2022-11-24 09:21:48 +00:00
msc2409_to_device_messages_enabled = true;
msc3202_device_masquerading_enabled = true;
msc3202_transaction_extensions = true;
msc3706_enabled = true;
faster_joins_enabled = true;
msc3720_enabled = true;
msc2654_enabled = true;
msc2815_enabled = true;
2023-03-18 09:16:33 +00:00
msc3391_enabled = true;
2022-11-24 09:21:48 +00:00
msc3773_enabled = true;
msc3664_enabled = true;
msc3848_enabled = true;
msc3852_enabled = true;
msc3881_enabled = true;
msc3882_enabled = true;
msc3874_enabled = true;
2023-03-18 09:16:33 +00:00
msc3890_enabled = true;
msc3381_polls_enabled = true;
2022-11-24 09:21:48 +00:00
msc3912_enabled = true;
2023-03-18 09:16:33 +00:00
msc1767_enabled = true;
msc3952_intentional_mentions = true;
msc3958_supress_edit_notifs = true;
msc3967_enabled = true;
msc2659_enabled = true;
2022-05-03 19:25:44 +00:00
};
2022-05-01 06:50:10 +00:00
};
withJemalloc = true;
};
2022-06-12 15:39:15 +00:00
sops.secrets."services/synapse/private_key" = {owner = "matrix-synapse";};
2022-05-01 06:50:10 +00:00
services.postgresql.ensureDatabases = [
"synapse"
];
2022-05-01 07:08:05 +00:00
systemd.services.matrix-synapse.serviceConfig.ExecStartPre = lib.mkForce (pkgs.writeShellScript "dummy" "true");
2022-08-26 15:28:14 +00:00
services.caddy.virtualHosts."matrix.int.chir.rs" = {
useACMEHost = "int.chir.rs";
2022-12-30 13:03:57 +00:00
logFormat = pkgs.lib.mkForce "";
2022-08-26 15:28:14 +00:00
extraConfig = ''
import baseConfig
2022-08-26 15:36:05 +00:00
handle /_matrix/* {
2022-08-26 16:49:55 +00:00
reverse_proxy localhost:8008 {
trusted_proxies private_ranges
}
2022-08-26 15:28:14 +00:00
}
2022-08-26 15:36:05 +00:00
handle /_synapse/* {
2022-08-26 16:49:55 +00:00
reverse_proxy localhost:8008 {
trusted_proxies private_ranges
}
2022-08-26 15:28:14 +00:00
}
2022-08-26 15:36:05 +00:00
handle /_matrix/media/* {
2022-08-26 15:28:14 +00:00
reverse_proxy {
2022-08-26 15:42:52 +00:00
to https://matrix.chir.rs
2022-08-26 16:45:19 +00:00
trusted_proxies private_ranges
2022-08-26 15:28:14 +00:00
header_up Host {upstream_hostport}
transport http {
2024-06-05 18:38:34 +00:00
versions 1.1
2022-08-26 15:28:14 +00:00
}
}
}
'';
2022-06-12 15:39:15 +00:00
};
2022-11-20 14:22:09 +00:00
services.caddy.virtualHosts."matrix-admin.int.chir.rs" = {
useACMEHost = "int.chir.rs";
2022-12-30 13:03:57 +00:00
logFormat = pkgs.lib.mkForce "";
2022-11-20 14:22:09 +00:00
extraConfig = ''
import baseConfig
root * ${pkgs.synapse-admin}
file_server
'';
};
2023-04-18 16:14:54 +00:00
sops.secrets."synapse/mautrix-discord" = {
key = "services/mautrix/discord.yaml";
2023-04-18 18:44:25 +00:00
owner = "matrix-synapse";
2023-04-18 16:14:54 +00:00
};
sops.secrets."synapse/mautrix-signal" = {
key = "services/mautrix/signal.yaml";
2023-04-18 18:44:25 +00:00
owner = "matrix-synapse";
2023-04-18 16:14:54 +00:00
};
sops.secrets."synapse/mautrix-telegram" = {
key = "services/mautrix/telegram.yaml";
2023-04-18 18:44:25 +00:00
owner = "matrix-synapse";
2023-04-18 16:14:54 +00:00
};
sops.secrets."synapse/mautrix-whatsapp" = {
key = "services/mautrix/whatsapp.yaml";
2023-04-18 18:52:02 +00:00
owner = "matrix-synapse";
2023-04-18 16:14:54 +00:00
};
2024-09-24 11:34:25 +00:00
sops.secrets."synapse/mautrix-slack" = {
key = "services/mautrix/slack.yaml";
owner = "matrix-synapse";
};
2024-06-26 05:11:44 +00:00
sops.secrets."synapse/doublepuppet" = {
key = "services/mautrix/doublepuppet.yaml";
owner = "matrix-synapse";
};
2022-05-01 06:50:10 +00:00
}