matrix: forward the homeserver URL from client hives too

HIVE_MATRIX_URL was conditioned on this host deploying the homeserver,
so a hive that is a client of the swarm's matrix forwarded nothing and
every agent's hive-matrix-daemon no-opped. hive-c0re already provisions
those agents' accounts against a remote homeserver through
HIVE_MATRIX_API_URL three lines below, whose gate is `apiUrl != null` —
it registered the users and then never told them where to log in.

gatewayHost is swarm-scoped and defaults to chat.<swarm-domain>, so it
names the swarm's one homeserver from any member hive. Its being set is
the real question, and a null swarm domain is already caught by the
assertion in hive-network.nix rather than by this expression.
This commit is contained in:
atlas 2026-08-30 15:08:27 +02:00 committed by mara
commit e8813b86eb

View file

@ -159,28 +159,26 @@ in
# a reading no correctly-built hive should ever have to make. # a reading no correctly-built hive should ever have to make.
HIVE_RESERVED_NAMES = lib.concatStringsSep " " (import ../../reserved-names.nix); HIVE_RESERVED_NAMES = lib.concatStringsSep " " (import ../../reserved-names.nix);
} }
// // lib.optionalAttrs (config.services.hyperhive.swarm.matrix.gatewayHost != null) {
lib.optionalAttrs # Matrix homeserver URL for each agent's hive-matrix-daemon — the
( # gateway vhost (`chat.<swarm-domain>`). Forwarded to agents by meta.rs
config.services.hyperhive.deploy.matrix.enable # alongside HIVE_FORGE_URL; shares the same env-forwarding ordering
&& config.services.hyperhive.swarm.matrix.gatewayHost != null # caveat (value baked at config-generation time).
) #
{ # Deliberately NOT conditioned on this host running the homeserver. A
# In-cluster matrix homeserver URL for each agent's # swarm has one matrix, and every hive's agents talk to it — the hive
# hive-matrix-daemon — the gateway vhost (`matrix.<domain>`). # that hosts it is not the only hive whose agents need its address.
# Forwarded to agents by meta.rs alongside HIVE_FORGE_URL; shares the # `gatewayHost` is swarm-scoped and names that one homeserver from any
# same env-forwarding ordering caveat (value baked at # member hive, so its being set is the whole question.
# config-generation time). #
# # Null forwards nothing rather than falling back to loopback. That
# A domain-less config forwards nothing rather than falling back to # fallback reads as harmless because hive-c0re shares the host netns —
# loopback. The old fallback read as harmless because hive-c0re shares # but the value is handed to *agents*, which do not, so `127.0.0.1`
# the host netns — but the value it produced was handed to *agents*, # there names the agent itself. An absent forward leaves
# which do not, so `127.0.0.1` there names the agent itself. An absent # `hyperhive.matrix.url` null and the daemon no-ops; that is the honest
# forward leaves `hyperhive.matrix.url` null and the daemon no-ops; # answer when there is no matrix vhost to point at.
# that is the honest answer when the hive has no matrix vhost to point HIVE_MATRIX_URL = "http://${config.services.hyperhive.swarm.matrix.gatewayHost}";
# at. }
HIVE_MATRIX_URL = "http://${config.services.hyperhive.swarm.matrix.gatewayHost}";
}
// lib.optionalAttrs (config.services.hyperhive.swarm.matrix.apiUrl != null) { // lib.optionalAttrs (config.services.hyperhive.swarm.matrix.apiUrl != null) {
# Client-server API base hive-c0re uses to provision matrix (register # Client-server API base hive-c0re uses to provision matrix (register
# agent users, create the hive space + chat room, invite members). # agent users, create the hive space + chat room, invite members).