2024-05-23 15:44:49 +02:00
|
|
|
{ config, ... }:
|
|
|
|
let
|
|
|
|
# matrix homeserver discovery
|
|
|
|
matrix_domain = "matrix.${config.networking.domain}";
|
|
|
|
serverConfig = {
|
|
|
|
"m.server" = "${matrix_domain}:443";
|
|
|
|
};
|
|
|
|
clientConfig = {
|
|
|
|
"m.homeserver" = {
|
|
|
|
base_url = "https://${matrix_domain}";
|
|
|
|
# server_name = config.networking.domain;
|
|
|
|
};
|
|
|
|
"org.matrix.msc3575.proxy" = {
|
|
|
|
url = "https://${matrix_domain}";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in
|
|
|
|
{
|
|
|
|
services.caddy = {
|
|
|
|
enable = true;
|
|
|
|
email = "ca@${config.networking.domain}";
|
|
|
|
logFormat = "format console";
|
2024-05-31 14:51:58 +02:00
|
|
|
globalConfig = ''
|
|
|
|
servers {
|
|
|
|
metrics
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
virtualHosts.":2018".extraConfig = ''
|
|
|
|
metrics
|
|
|
|
'';
|
2024-05-23 15:44:49 +02:00
|
|
|
virtualHosts."${config.networking.domain}".extraConfig = ''
|
|
|
|
file_server browse
|
|
|
|
root * /srv/web/${config.networking.domain}
|
|
|
|
respond /.well-known/matrix/client ${builtins.toJSON clientConfig}
|
|
|
|
respond /.well-known/matrix/server ${builtins.toJSON serverConfig}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
systemd.services.caddy.environment.XDG_DATA_HOME = "/var/lib";
|
2024-05-31 14:51:58 +02:00
|
|
|
networking.firewall.allowedTCPPorts = [ 80 443 2018 ];
|
2024-05-23 15:44:49 +02:00
|
|
|
networking.firewall.allowedUDPPorts = [ 443 ];
|
|
|
|
}
|