refactor(nix): make all-local a deployment mode, not a default
mara: enableAllLocalDefaults is more of a deployment mode via settings set, less a default setting. That reframing is the change. A mode asserts values; an option declares what it is when nobody asks. Written as default = <flag>, every service option had to name a switch it has no relationship to, and the answer to what does all-local turn on was spread across five files. Two modules now hold the two tiers - local-defaults.nix for the mode and what it asserts directly, swarm-required-services.nix for the services-live-here switch and the per-service enables under it. Each service module keeps its own declaration and loses only the line about when a deployment wants it. mkDefault is the right precedence rather than a compromise: it beats an option default and yields to any explicit definition, so the mode fills in for an operator who has not spoken and never argues with one who has. Evaluated config is unchanged in both directions.
This commit is contained in:
parent
01680ee962
commit
048bdd29a8
8 changed files with 134 additions and 79 deletions
|
|
@ -126,36 +126,10 @@
|
|||
'';
|
||||
};
|
||||
|
||||
# "The swarm-wide services run HERE." A swarm has one forge, one
|
||||
# matrix, one SSO — this says this host is where they live. The
|
||||
# OPTIONAL ones (matrix, authelia) default their own enable from it,
|
||||
# rather than the operator enabling them one at a time; the forge has
|
||||
# no enable to derive because it is not optional.
|
||||
options.services.hyperhive.swarm.enableRequiredServices = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = config.services.hyperhive.enableAllLocalDefaults;
|
||||
defaultText = lib.literalExpression "services.hyperhive.enableAllLocalDefaults";
|
||||
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 — default their
|
||||
`enable` from this, so a swarm's service host is declared in one
|
||||
place.
|
||||
|
||||
The forge is swarm-wide too but has no `enable` to derive: 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.
|
||||
|
||||
Defaults from `services.hyperhive.enableAllLocalDefaults` (off),
|
||||
which is the all-on-one-box switch. 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.
|
||||
'';
|
||||
};
|
||||
# `enableRequiredServices` is declared in ./swarm-required-services.nix
|
||||
# together with the per-service `enable`s it asserts — it is a
|
||||
# deployment-shape switch rather than swarm bookkeeping, so it lives
|
||||
# with its consequences instead of here.
|
||||
|
||||
options.services.hyperhive.swarm.snapshotStore = {
|
||||
address = lib.mkOption {
|
||||
|
|
|
|||
Loading…
Reference in a new issue