From 2c144676df7b821050a971a67891e4b40938143b Mon Sep 17 00:00:00 2001 From: David Crompton Date: Wed, 11 Feb 2026 23:32:49 -0500 Subject: [PATCH] hippocampus: matrix client/server prep --- machines/hippocampus/servers/public.nix | 3 ++ .../hippocampus/servers/public/matrix.nix | 6 ++++ .../servers/public/matrix/client.nix | 36 +++++++++++++++++++ .../servers/public/matrix/server.nix | 31 ++++++++++++++++ 4 files changed, 76 insertions(+) create mode 100644 machines/hippocampus/servers/public/matrix.nix create mode 100644 machines/hippocampus/servers/public/matrix/client.nix create mode 100644 machines/hippocampus/servers/public/matrix/server.nix diff --git a/machines/hippocampus/servers/public.nix b/machines/hippocampus/servers/public.nix index 4c4538c..c130a9a 100644 --- a/machines/hippocampus/servers/public.nix +++ b/machines/hippocampus/servers/public.nix @@ -50,5 +50,8 @@ # Perfect Pitch Project ./public/perfect_pitch.nix + + # Matrix services + ./public/matrix.nix ]; } diff --git a/machines/hippocampus/servers/public/matrix.nix b/machines/hippocampus/servers/public/matrix.nix new file mode 100644 index 0000000..027bed5 --- /dev/null +++ b/machines/hippocampus/servers/public/matrix.nix @@ -0,0 +1,6 @@ +{ ... }: { + imports = [ + ./matrix/server.nix + ./matrix/client.nix + ]; +} diff --git a/machines/hippocampus/servers/public/matrix/client.nix b/machines/hippocampus/servers/public/matrix/client.nix new file mode 100644 index 0000000..dba39f3 --- /dev/null +++ b/machines/hippocampus/servers/public/matrix/client.nix @@ -0,0 +1,36 @@ +{ config, pkgs, lib, ... }: { + services.nginx.virtualHosts.cinny = { + listen = { + addr = "unix:/run/cinny.sock"; + }; + locations."/" = { + root = pkgs.cinny; + extraConfig = '' + rewrite ^/config.json$ /config.json break; + rewrite ^/manifest.json$ /manifest.json break; + + rewrite ^/sw.js$ /sw.js break; + rewrite ^/pdf.worker.min.js$ /pdf.worker.min.js break; + + rewrite ^/public/(.*)$ /public/$1 break; + rewrite ^/assets/(.*)$ /assets/$1 break; + + rewrite ^(.+)$ /index.html break; + ''; + }; + }; + services.caddy.virtualHosts = { + "glia.club" = { + extraConfig = '' + reverse_proxy unix//run/cinny.sock + ''; + }; + + "chat.glia.club" = { + extraConfig = '' + reverse_proxy unix//run/cinny.sock + ''; + }; + }; + +} diff --git a/machines/hippocampus/servers/public/matrix/server.nix b/machines/hippocampus/servers/public/matrix/server.nix new file mode 100644 index 0000000..ff81b37 --- /dev/null +++ b/machines/hippocampus/servers/public/matrix/server.nix @@ -0,0 +1,31 @@ +{ config, pkgs, lib, ... }: { + services.matrix-tuwunel = { + enable = true; + stateDirectory = "tuwunel"; + # Must be equal to whatever reverse proxy is used for the unix + # socket path to work + group = config.services.caddy.group; + settings = { + global = { + address = null; + unix_socket_path = "/run/tuwunel/tuwunel.sock"; + server_name = "glia.club"; + allow_federation = false; + allow_encryption = true; + }; + }; + }; + services.caddy.virtualHosts = { + "glia.club, glia.club:8448" = { + extraConfig = let + proxy = "unix/${config.services.matrix-tuwunel.settings.global.unix_socket_path}"; + in '' + reverse_proxy /_matrix/* ${proxy} + reverse_proxy /_tuwunel/* ${proxy} + reverse_proxy /.well-known/matrix/client ${proxy} + reverse_proxy /.well-known/matrix/server ${proxy} + reverse_proxy /.well-known/matrix/support ${proxy} + ''; + }; + }; +}