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
|
|
@ -132,31 +132,9 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
# The one switch for "everything runs on this box". Every autoconf
|
||||
# toggle in the tree defaults from it, so an all-local deployment is a
|
||||
# single line rather than one line per service that grew a toggle.
|
||||
options.services.hyperhive.enableAllLocalDefaults = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
example = true;
|
||||
description = ''
|
||||
Run the whole swarm on this host: the swarm-wide services
|
||||
(`services.hyperhive.swarm.enableRequiredServices`) and the swarm
|
||||
CA (`services.hyperhive.swarm.ca.autoConfigure`) all default from
|
||||
this, and anything autoconfigurable added later should too.
|
||||
|
||||
**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 derived toggle can still be set explicitly to override this
|
||||
one, so "all local except X" needs no new option.
|
||||
'';
|
||||
};
|
||||
# `enableAllLocalDefaults` is declared in ./local-defaults.nix, with
|
||||
# the values it asserts. It is a deployment mode rather than a setting
|
||||
# this module's options read, so it lives with its consequences.
|
||||
|
||||
# Whether this hive runs "ruthless" — with no root/manager agent at
|
||||
# all. Some hives don't want a root agent — see issue tracker
|
||||
|
|
|
|||
Loading…
Reference in a new issue