services/matrix: modify config for 22.05

This commit is contained in:
Max Headroom 2022-05-30 22:15:39 +02:00
parent e223885972
commit 399fb4b5d8

View file

@ -3,7 +3,7 @@ let
inherit (tools.meta) domain; inherit (tools.meta) domain;
listener = { listener = {
port = 8008; port = 8008;
bind_address = "127.0.0.1"; bind_addresses = lib.singleton "127.0.0.1";
type = "http"; type = "http";
tls = false; tls = false;
x_forwarded = true; x_forwarded = true;
@ -22,27 +22,6 @@ let
"im.vector.riot.jitsi".preferredDomain = config.services.jitsi-meet.hostName; "im.vector.riot.jitsi".preferredDomain = config.services.jitsi-meet.hostName;
}; };
clientConfigJSON = pkgs.writeText "matrix-client-config.json" (builtins.toJSON clientConfig); clientConfigJSON = pkgs.writeText "matrix-client-config.json" (builtins.toJSON clientConfig);
extraConfig = {
experimental_features.spaces_enabled = true;
federation_ip_range_blacklist = cfg.url_preview_ip_range_blacklist;
admin_contact = "mailto:admins@${domain}";
max_upload_size = "32M";
max_spider_size = "10M";
emable_registration = true;
allow_guest_access = true;
push.include_content = true;
group_creation_prefix = "unofficial/";
app_service_config_files = [
"/etc/synapse/discord-registration.yaml"
];
turn_uris = let
combinations = lib.cartesianProductOfSets {
proto = [ "udp" "tcp" ];
scheme = [ "turns" "turn" ];
};
makeTurnServer = x: "${x.scheme}:turn.${domain}?transport=${x.proto}";
in map makeTurnServer combinations;
};
cfg = config.services.matrix-synapse; cfg = config.services.matrix-synapse;
in { in {
imports = [ imports = [
@ -82,27 +61,44 @@ in {
enable = true; enable = true;
plugins = [ pkgs.matrix-synapse-plugins.matrix-synapse-ldap3 ]; plugins = [ pkgs.matrix-synapse-plugins.matrix-synapse-ldap3 ];
server_name = domain; settings = {
listeners = lib.singleton listener; server_name = domain;
listeners = lib.singleton listener;
url_preview_enabled = true;
experimental_features.spaces_enabled = true;
admin_contact = "mailto:admins@${domain}";
max_upload_size = "32M";
max_spider_size = "10M";
emable_registration = true;
allow_guest_access = true;
push.include_content = true;
group_creation_prefix = "unofficial/";
app_service_config_files = [
"/etc/synapse/discord-registration.yaml"
];
turn_uris = let
combinations = lib.cartesianProductOfSets {
proto = [ "udp" "tcp" ];
scheme = [ "turns" "turn" ];
};
makeTurnServer = x: "${x.scheme}:turn.${domain}?transport=${x.proto}";
in map makeTurnServer combinations;
};
url_preview_enabled = true; extraConfigFiles = map (x: config.age.secrets.${x}.path) [
extraConfigFiles = [
(pkgs.writeText "synapse-extra-config.yaml" (builtins.toJSON extraConfig))
] ++ (map (x: config.age.secrets.${x}.path) [
"synapse-ldap" "synapse-ldap"
"synapse-db" "synapse-db"
"synapse-turn" "synapse-turn"
"synapse-keys" "synapse-keys"
]); ];
}; };
services.nginx.virtualHosts = tools.nginx.mappers.mapSubdomains { services.nginx.virtualHosts = tools.nginx.mappers.mapSubdomains {
matrix = tools.nginx.vhosts.basic // { matrix = tools.nginx.vhosts.basic // {
locations."/".return = "204"; locations."/".return = "204";
locations."/_matrix" = { locations."/_matrix" = {
proxyPass = with listener; "${type}://${bind_address}:${builtins.toString port}"; proxyPass = "http://127.0.0.1:8008";
extraConfig = "client_max_body_size ${extraConfig.max_upload_size};"; extraConfig = "client_max_body_size ${cfg.settings.max_upload_size};";
}; };
locations."= /.well-known/matrix/client".alias = clientConfigJSON; locations."= /.well-known/matrix/client".alias = clientConfigJSON;
}; };