feat(nix): the matrix gateway host moves to chat.<swarm.domain>

Both halves change: the parent, because a swarm runs one homeserver and
every hive reaches it; and the label, because `chat` names the service
people use rather than the protocol it speaks.

⚠️ `serverName` is deliberately NOT touched, and the two are now
documented as the different things they are. `gatewayHost` is a routing
detail -- the API listener nginx proxies `/_matrix/*` to, which clients
rediscover through `.well-known`. `serverName` is the matrix identifier
baked into every user and room id: changing it is a different
homeserver, not a rename, so it still falls back to the bare hive
domain. A note at the fallback says so, since that binding is where a
future edit would most plausibly "fix" the inconsistency.

Old deployments pin `matrix.<hive domain>` -- exactly what the old
default rendered -- and dnsmasq already lists `gatewayHost` explicitly,
so a pinned or moved name stays routed either way.
This commit is contained in:
atlas 2026-08-05 22:46:13 +02:00 committed by mara
commit ff84ca947d

View file

@ -8,6 +8,12 @@ let
cfg = config.services.hyperhive.swarm.matrix;
networkCfg = config.services.hyperhive.network;
hyperhiveDomain = config.services.hyperhive.domain;
swarmDomain = config.services.hyperhive.swarm.domain;
# ⚠️ Falls back to the HIVE domain, and must keep doing so even though
# `gatewayHost` moved to the swarm's: `serverName` is the matrix
# identifier baked into every user and room id, so changing it is a
# different homeserver rather than a rename. The two are independent on
# purpose — see the `gatewayHost` description below.
effectiveServerName = if cfg.serverName != null then cfg.serverName else hyperhiveDomain;
# fluffychat-web build fixes: nixpkgs's `flutter341.buildFlutterApplication`
@ -194,23 +200,37 @@ in
gatewayHost = lib.mkOption {
type = lib.types.nullOr lib.types.str;
# Total on a null hive domain so the required-domain assertion in
# `chat.` under the SWARM domain — both halves change: a swarm runs
# one homeserver, and the label follows the service rather than the
# protocol.
#
# Total on a null swarm domain so the required-domain assertion in
# hive-network.nix is the thing that fires; see the comment there.
default = if hyperhiveDomain == null then "matrix.invalid" else "matrix.${hyperhiveDomain}";
defaultText = lib.literalExpression ''"matrix.''${services.hyperhive.domain}"'';
default = if swarmDomain == null then "chat.invalid" else "chat.${swarmDomain}";
defaultText = lib.literalExpression ''"chat.''${services.hyperhive.swarm.domain}"'';
example = "matrix.example.com";
description = ''
Public hostname for the matrix homeserver behind the gateway.
Defaults to `matrix.''${services.hyperhive.domain}` (sub-domain
shape see `docs/gateway.md`). Set to `null` to skip the
gateway vhost (tuwunel stays direct on `httpPort`). See
`docs/gateway.md` for the vhost map + matrix discovery flow,
and the federation port-8448 caveat at the bottom of that doc.
Defaults to `chat.''${services.hyperhive.swarm.domain}` the
swarm's domain, because a swarm runs **one** homeserver. Set to
`null` to skip the gateway vhost (tuwunel stays direct on
`httpPort`). See `docs/gateway.md` for the vhost map + matrix
discovery flow, and the federation port-8448 caveat at the
bottom of that doc.
Note: `gatewayHost` is the API listener hostname (where nginx
proxies `/_matrix/*`); `serverName` is the matrix-identifier
domain embedded irrevocably in user/room IDs (default = bare
hive-domain). The two are distinct.
**`gatewayHost` and `serverName` are different things, and
only this one moved.** `gatewayHost` is the API listener
hostname (where nginx proxies `/_matrix/*`) and is free to
change: it is a routing detail clients rediscover through
`.well-known`. `serverName` is the matrix-identifier domain
embedded **irrevocably** in every user and room id changing
that is a different homeserver, not a rename, so it still
defaults to the bare hive domain and is untouched here.
A deployment that was running before this moved keeps its
current name by pinning
`matrix.''${services.hyperhive.domain}` here exactly what the
old default rendered.
'';
};