{ config, lib, ... }: { services.nginx.virtualHosts."${config.domains.p1}" = lib.mkIf config.system.server.enable { enableACME = true; addSSL = true; globalRedirect = "www.${config.domains.p2}"; locations = { "/.well-known/matrix/client".extraConfig = '' default_type application/json; return 200 ' { "m.homeserver": { "base_url": "https://matrix.${config.domains.p1}" }, "m.identity_server": { "base_url": "https://matrix.org" } } '; ''; "/.well-known/matrix/server".extraConfig = '' default_type application/json; return 200 '{ "m.server": "matrix.${config.domains.p1}:443" }'; ''; }; }; }