enableRequiredServices asserts the services that exist once per swarm and are optional -- its own description says so -- and the queue meets that rule. It was left out because this file predates the swarm-nats container by nine days and was never revisited, not because anyone decided against it. The all-local mode already derives nats.autoGenerateCallout, so it was minting the queue's callout nkeys and never starting the queue. With this the mode's loopback derivation for the controller points at something that is actually running.
62 lines
2.6 KiB
Nix
62 lines
2.6 KiB
Nix
# "The swarm-wide services run HERE."
|
|
#
|
|
# A swarm has one forge, one matrix, one SSO. This says this host is
|
|
# where they live, and asserts the per-service `enable`s that follow —
|
|
# the same mode-not-default shape as ./local-defaults.nix, one tier down.
|
|
#
|
|
# Only the *optional* services derive: matrix and authelia. The forge has
|
|
# no `enable` to assert, because it is not optional — it is the canonical
|
|
# store for the meta flake and every agent's config repo, so it deploys
|
|
# with hyperhive itself.
|
|
{
|
|
lib,
|
|
config,
|
|
...
|
|
}:
|
|
let
|
|
swarmCfg = config.services.hyperhive.swarm;
|
|
in
|
|
{
|
|
options.services.hyperhive.swarm.enableRequiredServices = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = false;
|
|
example = true;
|
|
description = ''
|
|
Host the swarm's shared services on this hive. The services that
|
|
exist once per swarm rather than once per hive and are *optional*
|
|
— the matrix homeserver, the SSO provider — have their `enable`
|
|
asserted from this, so a swarm's service host is declared in one
|
|
place.
|
|
|
|
The forge is swarm-wide too but has nothing to assert: it is the
|
|
canonical store for the meta flake and every agent's config repo,
|
|
so it deploys with hyperhive itself and is not optional.
|
|
|
|
`services.hyperhive.enableAllLocalDefaults` turns this on as part
|
|
of the all-on-one-box mode. Set it directly to run the swarm's
|
|
services on a host that is not otherwise all-local — a dedicated
|
|
services box with hives elsewhere is exactly that shape.
|
|
|
|
With it off, this hive is a *client* of those services: it still
|
|
configures how to reach them, it just doesn't run them.
|
|
'';
|
|
};
|
|
|
|
# Same precedence reasoning as ./local-defaults.nix: fills in for an
|
|
# operator who hasn't spoken, yields to one who has.
|
|
config.services.hyperhive.swarm = {
|
|
matrix.enable = lib.mkDefault swarmCfg.enableRequiredServices;
|
|
authelia.enable = lib.mkDefault swarmCfg.enableRequiredServices;
|
|
# The queue. Added later than the two above and missed at the time —
|
|
# this file predates the `swarm-nats` container by nine days and had
|
|
# not been revisited since, so its absence was sequence rather than
|
|
# intent. It meets the rule in the option's own description exactly:
|
|
# once per swarm, and optional.
|
|
#
|
|
# The tell that it was an omission: `local-defaults.nix` already
|
|
# derives `nats.autoGenerateCallout` from the all-local mode, so that
|
|
# mode was minting the queue's callout nkeys and then never starting
|
|
# the queue they authenticate against.
|
|
nats.enable = lib.mkDefault swarmCfg.enableRequiredServices;
|
|
};
|
|
}
|