{ config, lib, pkgs, ... }: let cfg = config.matrix; in { options.matrix = { serverName = lib.mkOption { type = lib.types.str; }; apiDomain = lib.mkOption { type = lib.types.str; }; }; config = { services = { matrix-synapse = { enable = true; settings = { server_name = cfg.serverName; }; }; nginx.virtualHosts.${cfg.apiDomain} = { enableACME = true; forceSSL = true; # TODO: add locations."/" with some message # Forward all Matrix API calls to the synapse Matrix homeserver. A trailing slash # *must not* be used here. locations."/_matrix".proxyPass = "http://127.0.0.1:8008"; # Forward requests for e.g. SSO and password-resets. locations."/_synapse/client".proxyPass = "http://127.0.0.1:8008"; }; }; }; }