From 5af71ea2319de44e8dcadfb48b931163c841682e Mon Sep 17 00:00:00 2001 From: Jack O'Sullivan Date: Sun, 15 Nov 2026 19:44:32 +0000 Subject: [PATCH] nixos/middleman: Add self-hosted Paseo relay Package paseo-relay and add a small `my.paseo-relay` module running it as a single node without Erlang distribution. Publish it on `paseo-relay.nul.ie` so Paseo daemons and the app can use our own relay instead of the hosted one. Co-Authored-By: Claude Opus 5.5 --- docs/sites/colony/shill/README.md | 2 +- .../colony/shill/containers/middleman.md | 16 ++++- .../shill/containers/middleman/default.nix | 2 + .../vms/shill/containers/middleman/vhosts.nix | 16 +++++ nixos/modules/_list.nix | 1 + nixos/modules/paseo-relay.nix | 69 +++++++++++++++++++ pkgs/default.nix | 1 + pkgs/paseo-relay.nix | 30 ++++++++ 8 files changed, 134 insertions(+), 3 deletions(-) create mode 100644 nixos/modules/paseo-relay.nix create mode 100644 pkgs/paseo-relay.nix diff --git a/docs/sites/colony/shill/README.md b/docs/sites/colony/shill/README.md index 58fc2eb..4d6a46c 100644 --- a/docs/sites/colony/shill/README.md +++ b/docs/sites/colony/shill/README.md @@ -48,7 +48,7 @@ their current addresses. Each container has its own page: | Container | Role | |---|---| -| [`middleman`](containers/middleman.md) | Reverse proxy, ACME, nginx-sso, librespeed | +| [`middleman`](containers/middleman.md) | Reverse proxy, ACME, nginx-sso, librespeed, Paseo relay | | [`vaultwarden`](containers/vaultwarden.md) | Password manager | | [`colony-psql`](containers/colony-psql.md) | Shared PostgreSQL (14) | | [`chatterbox`](containers/chatterbox.md) | Matrix Synapse + bridges | diff --git a/docs/sites/colony/shill/containers/middleman.md b/docs/sites/colony/shill/containers/middleman.md index 04f592b..a24ec6c 100644 --- a/docs/sites/colony/shill/containers/middleman.md +++ b/docs/sites/colony/shill/containers/middleman.md @@ -3,7 +3,7 @@ The front-end reverse proxy for the colony's public web services — the single ingress that `estuary` DNATs HTTP/HTTPS (and Matrix federation on `:8448`) to. Terminates TLS with wildcard certificates it issues itself, provides nginx-sso for gated vhosts, and runs a librespeed -backend. +backend and a Paseo relay. - **Source:** [`shill/containers/middleman/`](../../../../../nixos/boxes/colony/vms/shill/containers/middleman) (`default.nix`, `vhosts.nix`) @@ -42,6 +42,17 @@ username/password provider. Its cookie domain is `.nul.ie`; gated vhosts include The frontend and backend are published as `speed.nul.ie` and `librespeed.ams1.int.nul.ie`, both proxied to `localhost:8989`. +### Paseo relay + +[`paseo-relay`](https://github.com/getpaseo/paseo-relay) (the `my.paseo-relay` module, package +`pkgs/paseo-relay.nix`) relays end-to-end encrypted traffic between Paseo daemons and the Paseo +app, in place of Paseo's hosted relay. + +- Single node with no Erlang distribution, listening on `127.0.0.1:4000` and published as + `paseo-relay.nul.ie`. It keeps no state, so a restart only drops connections. +- The relay can't read or forge messages, so the vhost is open to the world. Its Prometheus + `/metrics` is not exposed; `/health` and `/ready` are. + ## Network assignments See the consolidated [network assignments](../../../../networking.md#box-assignments) table (this box: `middleman`). @@ -78,6 +89,7 @@ all vhosts are `onlySSL`, kTLS and HTTP/2. "SSO" = gated behind nginx-sso (`gene | `mc-map-kink.nul.ie` | `kinkcraft-oci:8100` | Minecraft map ([`whale2`](../../whale2.md#game-servers)) | | `speed.nul.ie` | `localhost:8989` | librespeed | | `librespeed.ams1.int.nul.ie` | `localhost:8989` | librespeed on the internal domain (internal wildcard cert) | +| `paseo-relay.nul.ie` | `localhost:4000` | Paseo relay; websockets with long timeouts; `/metrics` blocked | | `md.nul.ie` | `object-ctr:3000` | HedgeDoc; websockets | | `pb.nul.ie` | `object-ctr:8088` | wastebin | | `photos.nul.ie` | `jackflix-ctr:2342` | PhotoPrism; websockets | @@ -90,6 +102,6 @@ all vhosts are `onlySSL`, kTLS and HTTP/2. "SSO" = gated behind nginx-sso (`gene ## Notable config files -- [`nixos/boxes/colony/vms/shill/containers/middleman/default.nix`](../../../../../nixos/boxes/colony/vms/shill/containers/middleman/default.nix) — container definition: nginx, ACME, nginx-sso, librespeed, secrets +- [`nixos/boxes/colony/vms/shill/containers/middleman/default.nix`](../../../../../nixos/boxes/colony/vms/shill/containers/middleman/default.nix) — container definition: nginx, ACME, nginx-sso, librespeed, Paseo relay, secrets - [`nixos/boxes/colony/vms/shill/containers/middleman/vhosts.nix`](../../../../../nixos/boxes/colony/vms/shill/containers/middleman/vhosts.nix) — all virtual hosts, the SSO include helpers, and the `.well-known` tree - [`nixos/boxes/colony/vms/shill/containers/middleman/default.html`](../../../../../nixos/boxes/colony/vms/shill/containers/middleman/default.html) — default vhost landing page diff --git a/nixos/boxes/colony/vms/shill/containers/middleman/default.nix b/nixos/boxes/colony/vms/shill/containers/middleman/default.nix index 52b20e2..55b5ee0 100644 --- a/nixos/boxes/colony/vms/shill/containers/middleman/default.nix +++ b/nixos/boxes/colony/vms/shill/containers/middleman/default.nix @@ -138,6 +138,8 @@ in extraSettingsFile = config.age.secrets."librespeed.toml".path; }; }; + + paseo-relay.enable = true; }; users = { diff --git a/nixos/boxes/colony/vms/shill/containers/middleman/vhosts.nix b/nixos/boxes/colony/vms/shill/containers/middleman/vhosts.nix index fbbe5a9..defb117 100644 --- a/nixos/boxes/colony/vms/shill/containers/middleman/vhosts.nix +++ b/nixos/boxes/colony/vms/shill/containers/middleman/vhosts.nix @@ -378,6 +378,22 @@ in useACMEHost = pubDomain; }; + "paseo-relay.${pubDomain}" = { + locations = { + "/" = { + proxyPass = "http://127.0.0.1:${toString config.my.paseo-relay.port}"; + proxyWebsockets = true; + extraConfig = '' + ${proxyHeaders} + proxy_read_timeout 1h; + proxy_send_timeout 1h; + ''; + }; + "= /metrics".return = "404"; + }; + useACMEHost = pubDomain; + }; + "md.${pubDomain}" = { locations."/" = { proxyPass = "http://object-ctr.${domain}:3000"; diff --git a/nixos/modules/_list.nix b/nixos/modules/_list.nix index 8cd1796..1516717 100644 --- a/nixos/modules/_list.nix +++ b/nixos/modules/_list.nix @@ -20,6 +20,7 @@ nvme = ./nvme; spdk = ./spdk.nix; librespeed = ./librespeed; + paseo-relay = ./paseo-relay.nix; netboot = ./netboot; }; } diff --git a/nixos/modules/paseo-relay.nix b/nixos/modules/paseo-relay.nix new file mode 100644 index 0000000..f59ecc9 --- /dev/null +++ b/nixos/modules/paseo-relay.nix @@ -0,0 +1,69 @@ +{ lib, pkgs, config, ... }: +let + inherit (lib) mkIf mapAttrs; + inherit (lib.my) mkOpt' mkBoolOpt'; + + cfg = config.my.paseo-relay; +in +{ + options.my.paseo-relay = with lib.types; { + enable = mkBoolOpt' false "Whether to enable the Paseo relay."; + package = mkOpt' package pkgs.paseo-relay "Paseo relay package."; + host = mkOpt' str "127.0.0.1" "Address to listen on."; + port = mkOpt' port 4000 "Port to listen on (plain HTTP / WebSocket)."; + environment = mkOpt' (attrsOf (oneOf [ str int bool ])) { } + "Extra `PASEO_RELAY_*` environment variables (see the relay's README)."; + }; + + config = mkIf cfg.enable { + systemd.services.paseo-relay = { + description = "Paseo relay"; + wants = [ "network-online.target" ]; + after = [ "network-online.target" ]; + + environment = { + PASEO_RELAY_HOST = cfg.host; + PASEO_RELAY_PORT = toString cfg.port; + # Single node: no Erlang distribution (and so no epmd) + RELEASE_DISTRIBUTION = "none"; + RELEASE_TMP = "/run/paseo-relay"; + HOME = "/run/paseo-relay"; + } // mapAttrs (_: v: if v == true then "true" else if v == false then "false" else toString v) + cfg.environment; + + # The release script requires a cookie even without distribution + script = '' + RELEASE_COOKIE="$(head -c 32 /dev/urandom | sha256sum | cut -d' ' -f1)" + export RELEASE_COOKIE + exec ${cfg.package}/bin/paseo_relay start + ''; + + serviceConfig = { + DynamicUser = true; + RuntimeDirectory = "paseo-relay"; + Restart = "always"; + RestartSec = 5; + + CapabilityBoundingSet = ""; + NoNewPrivileges = true; + PrivateDevices = true; + PrivateTmp = true; + ProtectClock = true; + ProtectControlGroups = true; + ProtectHome = true; + ProtectHostname = true; + ProtectKernelLogs = true; + ProtectKernelModules = true; + ProtectKernelTunables = true; + ProtectProc = "invisible"; + ProtectSystem = "strict"; + RestrictAddressFamilies = [ "AF_INET" "AF_INET6" "AF_UNIX" ]; + RestrictNamespaces = true; + RestrictRealtime = true; + LockPersonality = true; + SystemCallArchitectures = "native"; + }; + wantedBy = [ "multi-user.target" ]; + }; + }; +} diff --git a/pkgs/default.nix b/pkgs/default.nix index e930345..7972feb 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -7,6 +7,7 @@ in monocraft' = callPackage ./monocraft.nix { }; vfio-pci-bind = callPackage ./vfio-pci-bind.nix { }; librespeed-go = callPackage ./librespeed-go.nix { }; + paseo-relay = callPackage ./paseo-relay.nix { }; # modrinth-app = callPackage ./modrinth-app { }; chocolate-doom2xx = callPackage ./chocolate-doom2xx { }; windowtolayer = callPackage ./windowtolayer.nix { }; diff --git a/pkgs/paseo-relay.nix b/pkgs/paseo-relay.nix new file mode 100644 index 0000000..cf8c64a --- /dev/null +++ b/pkgs/paseo-relay.nix @@ -0,0 +1,30 @@ +{ lib, beam, fetchFromGitHub, ... }: +let + beamPackages = beam.packages.erlang_29.overrideScope (final: prev: { + elixir = prev.elixir_1_20; + }); +in +beamPackages.mixRelease rec { + pname = "paseo-relay"; + version = "0.1.0-unstable-2026-10-28"; + + src = fetchFromGitHub { + owner = "getpaseo"; + repo = "paseo-relay"; + rev = "5f4b7636af41a85ef20200c0b7e99dd1ea2ee1f2"; + hash = "sha256-F4PQg5vU9sI3d9XWukbINdBmhbfcehBzeUVxPKZ06Jg="; + }; + + mixFodDeps = beamPackages.fetchMixDeps { + pname = "mix-deps-${pname}"; + inherit src version; + hash = "sha256-3J2C4XGqjdM0TYf+Vkv5/AY59tiKLVX81Gxrs9pvKuY="; + }; + + meta = { + description = "WebSocket relay for Paseo daemons and clients"; + homepage = "https://github.com/getpaseo/paseo-relay"; + license = lib.licenses.asl20; + mainProgram = "paseo_relay"; + }; +}