diff --git a/samsehu/matrix-conduit.nix b/samsehu/matrix-conduit.nix index 5ec3efa..6c3d9ed 100644 --- a/samsehu/matrix-conduit.nix +++ b/samsehu/matrix-conduit.nix @@ -5,27 +5,23 @@ { config, lib, pkgs, ... }: +let + homeserver-url = "samsehu.perli.casa"; +in { - # Headscale for access to the network while away from home - services.headscale.settings.dns_config.extra_records = [ - { name = "matrix.samsehu.perli.casa"; type = "A"; value = "100.64.0.3"; } - ]; - # configure matrix-conduit as a server to host chat communications with end-to-end encryption services.matrix-conduit = { enable = true; settings.global = { - server_name = "matrix.samsehu.perli.casa"; + server_name = "${homeserver-url}"; }; }; # Reverse proxy with Caddy - services.caddy.virtualHosts."matrix.samsehu.perli.casa".extraConfig = '' - respond /.well-known/matrix/server `{ "m.server": "matrix.samsehu.perli.casa" }` 200 - respond /.well-known/matrix/client `{ "m.homeserver": { "base_url": "https://matrix.samsehu.perli.casa" } }` 200 - ''; - services.caddy.virtualHosts."matrix.samsehu.perli.casa:8448".extraConfig = '' - reverse_proxy localhost:${toString config.services.matrix-conduit.settings.global.port} + services.caddy.virtualHosts."${homeserver-url}, ${homeserver-url}:8448".extraConfig = '' + respond /.well-known/matrix/server `{ "m.server": "${homeserver-url}" }` 200 + respond /.well-known/matrix/client `{ "m.homeserver": { "base_url": "https://${homeserver-url}" } }` 200 + reverse_proxy /_matrix/* localhost:${toString config.services.matrix-conduit.settings.global.port} ''; # Open ports in the firewall.