fix(nix): rename the forge attrset, not fifteen leaves
mara on the PR: "why deprecate individual keys instead of the whole attrset? there is no hyperhive.forge anymore after the move". Right, and mkRenamedOptionModule takes the namespace path directly - the subtree comes with it, nested ci.* included. Fifteen explicit renames collapse to one. The list was also a liability: an option added under swarm.forge later would have needed remembering here to get an alias, so it could silently fall behind the options it mirrors. Re-ran both evals against the new form. Values still map (httpPort 3999, ci.concurrency 7 through the old paths) and the warning still fires; it now names the attrset rather than the leaf, which also means one warning per hive instead of one per option an operator had set.
This commit is contained in:
parent
38c222fadd
commit
f7beea3a6f
1 changed files with 17 additions and 43 deletions
|
|
@ -2,51 +2,25 @@
|
||||||
# `services.hyperhive.swarm.*` when the swarm-global services were
|
# `services.hyperhive.swarm.*` when the swarm-global services were
|
||||||
# consolidated into one namespace.
|
# consolidated into one namespace.
|
||||||
#
|
#
|
||||||
# `mkRenamedOptionModule` maps the old path to the new one *and* emits a
|
# One rename per moved *namespace*, not per option: `mkRenamedOptionModule`
|
||||||
# deprecation warning naming both, so an existing hive keeps evaluating and
|
# takes the attrset path and carries the whole subtree, nested children
|
||||||
# its operator is told exactly what to rename. That is the whole reason the
|
# included. An existing hive keeps evaluating, and its operator gets a single
|
||||||
# move is safe to make in one commit: nothing has to be edited in lockstep.
|
# warning naming both paths rather than one per option they had set.
|
||||||
|
#
|
||||||
|
# A per-leaf list would also work and would be strictly worse: every option
|
||||||
|
# added under `swarm.forge` later would need remembering here to get an alias,
|
||||||
|
# so the list is a thing that can silently fall behind the options it mirrors.
|
||||||
#
|
#
|
||||||
# ⚠️ Only options that are genuinely **swarm-global** belong here. The
|
# ⚠️ Only options that are genuinely **swarm-global** belong here. The
|
||||||
# per-agent `hyperhive.forge.url` (`nix/agent-modules/forge.nix`) is a
|
# per-agent `hyperhive.forge.url` (`nix/agent-modules/forge.nix`) is a client
|
||||||
# client pointer at whatever forge an agent talks to — it shares a word with
|
# pointer at whatever forge an agent talks to — it shares a word with the
|
||||||
# the service and nothing else, and it does not move.
|
# service and nothing else, and it does not move.
|
||||||
{ lib, ... }:
|
{ lib, ... }:
|
||||||
let
|
|
||||||
# One entry per moved leaf. Written as a list rather than a fold over the
|
|
||||||
# option tree on purpose: a rename has to name both paths explicitly, and
|
|
||||||
# deriving them would make an accidental rename invisible in review.
|
|
||||||
renamed = old: new: lib.mkRenamedOptionModule old new;
|
|
||||||
|
|
||||||
forgeOption =
|
|
||||||
name:
|
|
||||||
renamed [ "services" "hyperhive" "forge" name ] [ "services" "hyperhive" "swarm" "forge" name ];
|
|
||||||
|
|
||||||
forgeCiOption =
|
|
||||||
name:
|
|
||||||
renamed
|
|
||||||
[ "services" "hyperhive" "forge" "ci" name ]
|
|
||||||
[ "services" "hyperhive" "swarm" "forge" "ci" name ];
|
|
||||||
in
|
|
||||||
{
|
{
|
||||||
imports =
|
imports = [
|
||||||
map forgeOption [
|
(lib.mkRenamedOptionModule
|
||||||
"httpPort"
|
[ "services" "hyperhive" "forge" ]
|
||||||
"sshPort"
|
[ "services" "hyperhive" "swarm" "forge" ]
|
||||||
"domain"
|
)
|
||||||
"publicUrl"
|
];
|
||||||
"package"
|
|
||||||
"behindGateway"
|
|
||||||
"rootUrl"
|
|
||||||
"openFirewall"
|
|
||||||
"mirrors"
|
|
||||||
]
|
|
||||||
++ map forgeCiOption [
|
|
||||||
"enable"
|
|
||||||
"name"
|
|
||||||
"concurrency"
|
|
||||||
"labels"
|
|
||||||
"package"
|
|
||||||
"jobTimeout"
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue