From 81464019a4ddd57068ca5acc67e8ec4c763d81e3 Mon Sep 17 00:00:00 2001 From: Evie Litherland-Smith Date: Mon, 10 Jun 2024 07:42:56 +0100 Subject: [PATCH] Update (and rename) matrix-synapse service file --- services/matrix-synapse.nix | 41 ++++++++++++++++++++++++++++++++++ services/matrix.nix | 44 ------------------------------------- 2 files changed, 41 insertions(+), 44 deletions(-) create mode 100644 services/matrix-synapse.nix delete mode 100644 services/matrix.nix diff --git a/services/matrix-synapse.nix b/services/matrix-synapse.nix new file mode 100644 index 00000000..c310cfad --- /dev/null +++ b/services/matrix-synapse.nix @@ -0,0 +1,41 @@ +{...}: let + baseUrl = "xenia.me.uk"; + port = 8008; +in { + imports = [./caddy.nix]; + services = { + matrix-synapse = { + enable = true; + settings = { + server_name = baseUrl; + public_baseurl = baseUrl; + listeners = [ + { + inherit port; + bind_addresses = ["127.0.0.1" "::1"]; + type = "http"; + tls = false; + x_forwarded = true; + resources = [ + { + names = ["client" "federation"]; + compress = true; + } + ]; + } + ]; + }; + extraConfigFiles = ["/run/secrets/matrix-shared-secret"]; + }; + caddy.virtualHosts."xenia.me.uk".extraConfig = '' + header /.well-known/matrix/* Content-Type application/json + header /.well-known/matrix/* Access-Control-Allow-Origin * + respond /.well-known/matrix/server `{"m.server": "matrix.${baseUrl}:443"}` + respond /.well-known/matrix/client `{"m.homeserver":{"base_url":"https://matrix.${baseUrl}"}}` + ''; + caddy.virtualHosts."matrix.xenia.me.uk".extraConfig = '' + reverse_proxy /_matrix/* localhost:${port} + reverse_proxy /_synapse/client/* localhost:${port} + ''; + }; +} diff --git a/services/matrix.nix b/services/matrix.nix deleted file mode 100644 index 1217daba..00000000 --- a/services/matrix.nix +++ /dev/null @@ -1,44 +0,0 @@ -{pkgs, ...}: { - imports = [./caddy.nix]; - services.postgresql.enable = true; - services.postgresql.initialScript = pkgs.writeText "synapse-init.sql" '' - CREATE ROLE "matrix-synapse" WITH LOGIN PASSWORD 'synapse'; - CREATE DATABASE "matrix-synapse" WITH OWNER "matrix-synapse" - TEMPLATE template0 - LC_COLLATE = "C" - LC_CTYPE = "C"; - ''; - - services = { - matrix-synapse = { - enable = true; - settings.server_name = "xenia.me.uk"; - settings.listeners = [ - { - bind_addresses = ["127.0.0.1"]; - port = 8008; - type = "http"; - tls = false; - x_forwarded = true; - resources = [ - { - names = ["client" "federation"]; - compress = true; - } - ]; - } - ]; - extraConfigFiles = ["/run/secrets/matrix-shared-secret"]; - }; - caddy.virtualHosts."xenia.me.uk".extraConfig = '' - header /.well-known/matrix/* Content-Type application/json - header /.well-known/matrix/* Access-Control-Allow-Origin * - respond /.well-known/matrix/server `{"m.server": "matrix.xenia.me.uk:443"}` - respond /.well-known/matrix/client `{"m.homeserver":{"base_url":"https://matrix.xenia.me.uk"}}` - ''; - caddy.virtualHosts."matrix.xenia.me.uk".extraConfig = '' - reverse_proxy /_matrix/* localhost:8008 - reverse_proxy /_synapse/client/* localhost:8008 - ''; - }; -}