`enableAllLocalDefaults` already asserts the swarm's shared services and its CA; the controller was the one swarm-level thing it left off, so the default deployment ran authelia, matrix and the forge with nothing controlling them — and, until the previous commit in this area, without `swarmctl` either. The controller's own option stays `default = false`. Running it is a statement about swarm topology rather than about hyperhive being installed, and no single host can infer that on its own. But "this box is the whole deployment" IS that statement, which is why the mode may assert what `services.hyperhive.enable` never could. Derived from the mode, not from `enableRequiredServices`: a hive in a larger swarm can legitimately want the shared services without being the host that controls them. `mkDefault`, so `enableAllLocalDefaults = true` with an explicit `controller.enable = false` still yields a controller-less box — the mode fills in for an operator who hasn't spoken and never argues with one who has.
67 lines
3 KiB
Nix
67 lines
3 KiB
Nix
# The all-local deployment mode.
|
|
#
|
|
# `enableAllLocalDefaults` is a *mode*, not a default other options read:
|
|
# it says "this box is the whole deployment" and then asserts the values
|
|
# that follow from that. mara, on the issue: it is "more of a deployment
|
|
# mode via settings set, less a default setting".
|
|
#
|
|
# That distinction is why the derivations live here as `mkDefault` in a
|
|
# `config` block rather than as `default =` inside each option. An option
|
|
# declares what IT is and what it is when nobody asks; a mode declares
|
|
# what a deployment shape implies. Written the other way round, every
|
|
# service option had to name a flag it has no relationship to, and the
|
|
# answer to "what does all-local turn on?" was spread across five files.
|
|
#
|
|
# Adding an autoconfigurable thing later means one line here — not a
|
|
# `default =` in the new module pointing back at this flag.
|
|
{
|
|
lib,
|
|
config,
|
|
...
|
|
}:
|
|
let
|
|
cfg = config.services.hyperhive;
|
|
in
|
|
{
|
|
options.services.hyperhive.enableAllLocalDefaults = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = false;
|
|
example = true;
|
|
description = ''
|
|
Run the whole swarm on this host. Turning this on asserts the
|
|
swarm-level toggles that an all-on-one-box deployment implies:
|
|
the swarm's shared services
|
|
(`services.hyperhive.swarm.enableRequiredServices`), the swarm
|
|
CA (`services.hyperhive.swarm.ca.autoConfigure`), and the swarm
|
|
controller (`services.hyperhive.swarm.controller.enable`).
|
|
|
|
**Off by default, and that is the load-bearing part.** A swarm's
|
|
services and its hives can live on different hosts, and a host has
|
|
no way to tell which ones it is meant to be — so this is an
|
|
operator saying "this is that box", never something inferred.
|
|
Turn it on for a dev box or a single-hive swarm and get a working
|
|
deployment with no further configuration; leave it off and every
|
|
swarm-level artifact is operator-provided.
|
|
|
|
Each toggle it asserts can still be set explicitly, which wins —
|
|
so "all local except X" needs no new option.
|
|
'';
|
|
};
|
|
|
|
# What the mode asserts. `mkDefault` (priority 1000) beats an option's
|
|
# own `default` (1500) and loses to any explicit definition, which is
|
|
# exactly the precedence a deployment mode wants: it fills in for an
|
|
# operator who hasn't spoken, and never argues with one who has.
|
|
config.services.hyperhive.swarm = {
|
|
enableRequiredServices = lib.mkDefault cfg.enableAllLocalDefaults;
|
|
ca.autoConfigure = lib.mkDefault cfg.enableAllLocalDefaults;
|
|
# The controller is asserted by the MODE and by nothing else. Its own
|
|
# option stays `default = false` precisely because running it is a
|
|
# statement about swarm topology — but "this box is the whole
|
|
# deployment" IS that statement, and it is the one shape where the
|
|
# answer isn't ambiguous. Deriving it from `enableRequiredServices`
|
|
# instead would be wrong: a hive in a larger swarm can legitimately
|
|
# want the shared services without being the host that controls them.
|
|
controller.enable = lib.mkDefault cfg.enableAllLocalDefaults;
|
|
};
|
|
}
|