nix(c0re): set HIVE_FORGE_URL to the gateway URL directly, drop dead if/else

Per mara's review of #1718: this env block only exists when hyperhive is
enabled (it lives inside `config = mkIf cfg.enable`), so the
`if hyperhive.enable then gateway else loopback` branch was dead — the
loopback fallback could never be reached. Set HIVE_FORGE_URL to the
gateway vhost directly.

HIVE_MATRIX_URL drops the same redundant `hyperhive.enable` term but
keeps the gatewayHost null-guard — that one is a real fallback for a
domain-less config, not the dead enable branch.
This commit is contained in:
atlas 2026-06-17 16:56:26 +02:00
commit e8c2ef087c

View file

@ -750,38 +750,26 @@ in
HYPERHIVE_SWARM_NAME = config.services.hyperhive.swarmName; HYPERHIVE_SWARM_NAME = config.services.hyperhive.swarmName;
} }
// lib.optionalAttrs config.services.hyperhive.forge.enable { // lib.optionalAttrs config.services.hyperhive.forge.enable {
# In-cluster forge URL. # In-cluster forge URL. Network isolation is unconditional (the
# - Isolated (private netns): containers resolve `forge.<domain>` via # shared-netns mode was removed), so agents always resolve
# the bridge dnsmasq and reach nginx on port 80. No raw forge port # `forge.<domain>` via the bridge dnsmasq and reach nginx on port 80
# needed — nginx proxies to forgejo as it does for the operator. # (nginx proxies to forgejo as it does for the operator) — there is
# - Shared netns: host loopback is reachable, use direct port. # no host-loopback path. This env is only set when hyperhive is
# enabled, so the gateway URL is unconditionally correct here.
# See `docs/gateway.md::HIVE_FORGE_URL`. # See `docs/gateway.md::HIVE_FORGE_URL`.
# Network isolation is now unconditional (the shared-netns mode was HIVE_FORGE_URL = "http://${config.services.hyperhive.forge.domain}";
# removed), so agents always reach the forge through the gateway
# vhost rather than host loopback. Guard on the top-level
# `hyperhive.enable` (not the deprecated `network.enable`): the
# network is always on with hyperhive, so the deprecated toggle has
# no effect here either — the loopback branch only covers a config
# with hyperhive itself disabled (no agents to serve).
HIVE_FORGE_URL =
if config.services.hyperhive.enable then
"http://${config.services.hyperhive.forge.domain}"
else
"http://127.0.0.1:${toString config.services.hyperhive.forge.httpPort}";
} }
// lib.optionalAttrs config.services.hyperhive.matrix.enable { // lib.optionalAttrs config.services.hyperhive.matrix.enable {
# In-cluster matrix homeserver URL for each agent's # In-cluster matrix homeserver URL for each agent's
# hive-matrix-daemon. Same shape + rationale as HIVE_FORGE_URL: # hive-matrix-daemon — the gateway vhost (`matrix.<domain>`) on plain
# network isolation is now unconditional, so agents reach tuwunel # http:80. Network isolation is unconditional, so there is no
# via the gateway vhost (`matrix.<domain>`) on plain http:80 rather # host-loopback path; the only remaining conditional is the
# than host loopback. Guard on the top-level `hyperhive.enable` (the # gatewayHost null-guard, which falls back to loopback so a
# deprecated `network.enable` has no effect); the gatewayHost # domain-less config still evals. Forwarded to agents by meta.rs
# null-guard falls back to loopback so a domain-less config still # alongside HIVE_FORGE_URL; shares the same env-forwarding ordering
# evals. Forwarded to agents by meta.rs alongside HIVE_FORGE_URL; # caveat (value baked at config-generation time).
# shares the same env-forwarding ordering caveat (value baked at
# config-generation time).
HIVE_MATRIX_URL = HIVE_MATRIX_URL =
if config.services.hyperhive.enable && config.services.hyperhive.matrix.gatewayHost != null then if config.services.hyperhive.matrix.gatewayHost != null then
"http://${config.services.hyperhive.matrix.gatewayHost}" "http://${config.services.hyperhive.matrix.gatewayHost}"
else else
"http://127.0.0.1:${toString config.services.hyperhive.matrix.httpPort}"; "http://127.0.0.1:${toString config.services.hyperhive.matrix.httpPort}";