2022-12-10 17:23:41 +01:00
|
|
|
#
|
|
|
|
# System notifications
|
|
|
|
#
|
|
|
|
|
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
2022-12-27 20:15:39 +01:00
|
|
|
let
|
|
|
|
fqdn = "matrix.${config.networking.domain}";
|
|
|
|
clientConfig = {
|
|
|
|
"m.homeserver".base_url = "https://${fqdn}";
|
|
|
|
"m.identity_server" = {};
|
|
|
|
};
|
|
|
|
serverConfig."m.server" = "${config.services.matrix-synapse.settings.server_name}:443";
|
|
|
|
mkWellKnown = data: ''
|
|
|
|
add_header Content-Type application/json;
|
|
|
|
add_header Access-Control-Allow-Origin *;
|
|
|
|
return 200 '${builtins.toJSON data}';
|
|
|
|
'';
|
|
|
|
in {
|
|
|
|
services.nginx = {
|
|
|
|
enable = true;
|
|
|
|
recommendedTlsSettings = true;
|
|
|
|
recommendedOptimisation = true;
|
|
|
|
recommendedGzipSettings = true;
|
|
|
|
recommendedProxySettings = true;
|
|
|
|
virtualHosts = {
|
|
|
|
"${config.networking.domain}" = {
|
|
|
|
enableACME = true;
|
|
|
|
forceSSL = true;
|
|
|
|
locations."= /.well-known/matrix/server".extraConfig = mkWellKnown serverConfig;
|
|
|
|
locations."= /.well-known/matrix/client".extraConfig = mkWellKnown clientConfig;
|
|
|
|
};
|
|
|
|
"${fqdn}" = {
|
|
|
|
enableACME = true;
|
|
|
|
forceSSL = true;
|
|
|
|
locations."/".extraConfig = ''
|
|
|
|
return 404;
|
|
|
|
'';
|
|
|
|
locations."/_matrix".proxyPass = "http://[::1]:8008";
|
|
|
|
locations."/_synapse/client".proxyPass = "http://[::1]:8008";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-12-10 17:23:41 +01:00
|
|
|
services.matrix-synapse = {
|
|
|
|
enable = true;
|
|
|
|
settings = {
|
2022-12-27 20:15:39 +01:00
|
|
|
server_name = config.networking.domain;
|
|
|
|
listeners = [
|
|
|
|
{ port = 8008;
|
|
|
|
bind_addresses = [ "::1" ];
|
|
|
|
type = "http";
|
|
|
|
tls = false;
|
|
|
|
x_forwarded = true;
|
|
|
|
resources = [ {
|
|
|
|
names = [ "client" "federation" ];
|
|
|
|
compress = true;
|
|
|
|
} ];
|
|
|
|
}
|
|
|
|
];
|
2022-12-10 17:23:41 +01:00
|
|
|
database.args.user = "synapse";
|
|
|
|
database.args.database = "synapsedb";
|
2022-12-21 21:52:30 +01:00
|
|
|
extraConfigFiles = [
|
|
|
|
config.age.secrets."services/matrix/synapse.yml".path
|
|
|
|
];
|
2022-12-10 17:23:41 +01:00
|
|
|
};
|
2022-12-27 20:15:39 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
age.secrets."services/matrix/synapse.yml" = {
|
|
|
|
file = ../../../secrets/services/matrix/synapse.age;
|
|
|
|
owner = "synapse";
|
|
|
|
};
|
2022-12-10 17:23:41 +01:00
|
|
|
}
|