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
|
||||
# consolidated into one namespace.
|
||||
#
|
||||
# `mkRenamedOptionModule` maps the old path to the new one *and* emits a
|
||||
# deprecation warning naming both, so an existing hive keeps evaluating and
|
||||
# its operator is told exactly what to rename. That is the whole reason the
|
||||
# move is safe to make in one commit: nothing has to be edited in lockstep.
|
||||
# One rename per moved *namespace*, not per option: `mkRenamedOptionModule`
|
||||
# takes the attrset path and carries the whole subtree, nested children
|
||||
# included. An existing hive keeps evaluating, and its operator gets a single
|
||||
# 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
|
||||
# per-agent `hyperhive.forge.url` (`nix/agent-modules/forge.nix`) is a
|
||||
# client pointer at whatever forge an agent talks to — it shares a word with
|
||||
# the service and nothing else, and it does not move.
|
||||
# per-agent `hyperhive.forge.url` (`nix/agent-modules/forge.nix`) is a client
|
||||
# pointer at whatever forge an agent talks to — it shares a word with the
|
||||
# service and nothing else, and it does not move.
|
||||
{ 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 =
|
||||
map forgeOption [
|
||||
"httpPort"
|
||||
"sshPort"
|
||||
"domain"
|
||||
"publicUrl"
|
||||
"package"
|
||||
"behindGateway"
|
||||
"rootUrl"
|
||||
"openFirewall"
|
||||
"mirrors"
|
||||
]
|
||||
++ map forgeCiOption [
|
||||
"enable"
|
||||
"name"
|
||||
"concurrency"
|
||||
"labels"
|
||||
"package"
|
||||
"jobTimeout"
|
||||
];
|
||||
imports = [
|
||||
(lib.mkRenamedOptionModule
|
||||
[ "services" "hyperhive" "forge" ]
|
||||
[ "services" "hyperhive" "swarm" "forge" ]
|
||||
)
|
||||
];
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue