diff --git a/configurations/camelot/default.nix b/configurations/camelot/default.nix index 6e0ac4d..bac8aa6 100644 --- a/configurations/camelot/default.nix +++ b/configurations/camelot/default.nix @@ -43,6 +43,7 @@ ./wireguard.nix ./nextcloud.nix ./gotosocial.nix + ./matrix.nix ]; swapDeviceUUID = "a7c628ab-c5cb-4094-89d0-19b153fbead4"; diff --git a/configurations/camelot/matrix.nix b/configurations/camelot/matrix.nix new file mode 100644 index 0000000..6c4c582 --- /dev/null +++ b/configurations/camelot/matrix.nix @@ -0,0 +1,65 @@ +{ config, ... }: +let + conduitConfig = config.services.matrix-conduit.settings; +in { + services.matrix-conduit = { + enable = true; + + settings = { + global = { + server_name = "dalaran.fr"; + address = "127.0.0.1"; + database_backend = "rocksdb"; + + enable_lightning_bolt = false; + allow_registration = false; + well_known = { + client = "https://matrix.dalaran.fr"; + server = "matrix.dalaran.fr:443"; + }; + }; + }; + }; + + services.nginx.virtualHosts = { + "dalaran.fr".locations."/.well-known/matrix/" = { + return = "301 https://matrix.dalaran.fr$request_uri"; + }; + + "matrix.dalaran.fr" = { + enableACME = true; + addSSL = true; + listen = [ + { + addr = "0.0.0.0"; + port = 8448; + ssl = true; + } + { + addr= "[::]"; + port = 8448; + ssl = true; + } + { + addr = "0.0.0.0"; + port = 443; + ssl = true; + } + { + addr= "[::]"; + port = 443; + ssl = true; + } + ]; + + locations."/" = { + recommendedProxySettings = true; + proxyPass = "http://${conduitConfig.global.address}:${builtins.toString conduitConfig.global.port}"; + }; + + extraConfig = "client_max_body_size 20M;"; + }; + }; + + networking.firewall.allowedTCPPorts = [ 443 8448 ]; +}