swarm-controller: fix forgeTokenFile default referencing a nonexistent forge.enable

This commit is contained in:
damocles 2026-08-16 19:24:49 +02:00
commit 4122960530

View file

@ -231,10 +231,20 @@ in
forgeTokenFile = lib.mkOption { forgeTokenFile = lib.mkOption {
type = lib.types.nullOr lib.types.str; type = lib.types.nullOr lib.types.str;
default = if forgeCfg.enable then forgeCfg.hostSwarmControllerTokenFile else null; # `services.hyperhive.swarm.forge` has no `enable` of its own to
# check — the module activates on the general
# `config.services.hyperhive.enable` instead (see
# `hive-forge/default.nix`'s own `config = lib.mkIf
# config.services.hyperhive.enable { ... }`), so that's the
# condition to match here too. Referencing a `forge.enable` that
# doesn't exist threw `attribute 'enable' missing` on every host
# that turns swarm-controller on — caught in review, not by
# `nix flake check` (nothing in its checked combinations forced
# this particular default to actually evaluate).
default = if config.services.hyperhive.enable then forgeCfg.hostSwarmControllerTokenFile else null;
defaultText = lib.literalExpression '' defaultText = lib.literalExpression ''
forge's own `hostSwarmControllerTokenFile` when this host runs forge's own `hostSwarmControllerTokenFile` when this host runs
forge, else null hyperhive at all (forge has no separate enable), else null
''; '';
example = "/var/lib/secrets/swarm-controller-forge.token"; example = "/var/lib/secrets/swarm-controller-forge.token";
description = '' description = ''
@ -243,15 +253,16 @@ in
`forgejo-swarm-controller-account` + `hive-forge-swarm-controller-token` `forgejo-swarm-controller-account` + `hive-forge-swarm-controller-token`
units, which mint and collect it onto forge's own host). units, which mint and collect it onto forge's own host).
Defaults to forge's own delivery path only when forge runs on Defaults to forge's own delivery path on every host running
this same host. On any other host the token has to get here hyperhive (forge deploys unconditionally alongside it see
somehow copy it out of forge's `hive-forge/default.nix`, it has no `enable` of its own).
Override explicitly if forge's actual token file ends up
somewhere else copy it out of forge's
{option}`services.hyperhive.swarm.forge.hostSwarmControllerTokenFile` {option}`services.hyperhive.swarm.forge.hostSwarmControllerTokenFile`
with whatever secret management this deployment already uses, with whatever secret management this deployment already uses,
the same shape `swarm.nix`'s `clientSecretFile` documents for the same shape `swarm.nix`'s `clientSecretFile` documents for
the analogous cross-host case. `null` (the default when forge its own cross-host case. `null` means no forge access the
isn't local and nothing else was set) means no forge access daemon logs that and continues without it, the same
the daemon logs that and continues without it, the same
graceful-absence shape the queue coordinates already use. graceful-absence shape the queue coordinates already use.
''; '';
}; };