deploy: separate "what this host deploys" from swarm-wide truth
`services.hyperhive.swarm.*` is meant to be identical on every host in a swarm — it describes the swarm, and every hive needs all of it to be a client. But it also carried the `enable` toggles, which are precisely the values that must differ per machine. The namespace that should be the same everywhere held the one thing that cannot be. Adds `services.hyperhive.deploy.*` for a host's deployment decisions, and moves the first of them (`swarm.grafana.enable` -> `deploy.grafana`) as the pattern for the rest. Flat and named for the thing deployed rather than grouped under a "swarm services" attribute: from the deploy side it does not matter what kind of thing each one is, and a grouping by service kind would re-encode the service-side taxonomy into a layer that does not care about it. Behaviour is unchanged. The move is a rename in the strict sense — same type, same meaning, new path — so `mkRenamedOptionModule` carries it and existing configs keep evaluating with one warning naming both paths. The renames live in the new module rather than the service modules, so the whole migration has a single home and a single file to delete when the deprecation window closes.
This commit is contained in:
parent
9a01906275
commit
b422367942
6 changed files with 73 additions and 16 deletions
53
nix/host-modules/deploy.nix
Normal file
53
nix/host-modules/deploy.nix
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
# "What does THIS host deploy?"
|
||||
#
|
||||
# Separated from `services.hyperhive.swarm.*` because those are two
|
||||
# different kinds of fact and only one of them varies per machine:
|
||||
#
|
||||
# swarm.* — swarm-wide truth. The swarm's name, domain, hives, peers,
|
||||
# CA, and where each service lives. **Identical on every
|
||||
# host**, byte for byte; a hive needs all of it to be a
|
||||
# *client* of the swarm.
|
||||
# deploy.* — this machine's deployment decisions. Necessarily different
|
||||
# on every host, because that is what a deployment is.
|
||||
#
|
||||
# The `enable` toggles used to live under `swarm.*`, which made the
|
||||
# namespace that is supposed to be identical everywhere carry the one
|
||||
# thing that must differ.
|
||||
#
|
||||
# Flat and named for the thing deployed — `deploy.forgejo`, not
|
||||
# `deploy.swarmServices.forgejo`. Grouping by "swarm service" would
|
||||
# re-encode the service-side taxonomy into a layer that does not care
|
||||
# about it: from here, a host deploys forgejo, or a hive, or the lot, and
|
||||
# what *kind* of thing each one is belongs to the service module.
|
||||
#
|
||||
# ⚠️ The renames below are deliberately in this one file rather than
|
||||
# spread across the service modules, so the whole move has a single home
|
||||
# and a single file to delete when the deprecation window closes — the
|
||||
# shape ./swarm-peers-removed.nix already uses.
|
||||
{ lib, ... }:
|
||||
{
|
||||
imports = [
|
||||
# Same type, same meaning, new path — so a rename carries it exactly
|
||||
# and existing configs keep evaluating with one warning naming both
|
||||
# paths. Precedent: ./hive-forge/default.nix, ./hive-matrix.nix.
|
||||
(lib.mkRenamedOptionModule
|
||||
[ "services" "hyperhive" "swarm" "grafana" "enable" ]
|
||||
[ "services" "hyperhive" "deploy" "grafana" ]
|
||||
)
|
||||
];
|
||||
|
||||
options.services.hyperhive.deploy = {
|
||||
grafana = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Run the swarm's metrics UI on this host.
|
||||
|
||||
Off by default and not derived from
|
||||
{option}`services.hyperhive.enable`: a swarm has one Grafana, so
|
||||
running it is a decision about this host rather than about
|
||||
whether hyperhive is installed.
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Reference in a new issue