nix: warn on the ignored swarm-ui switches instead of failing eval
deploy.swarm-ui.enable and swarm.ui.enable are declared again as nullOr bool, default null, and do nothing. Setting either adds an eval warning that swarm-ui now runs wherever swarm-controller runs.
This commit is contained in:
parent
f9954b91b4
commit
44346d8c6c
3 changed files with 36 additions and 33 deletions
|
|
@ -337,7 +337,8 @@ Where each credential lives and who reads it:
|
||||||
services.hyperhive.deploy.swarm-controller.enable = true; # the UI comes with it
|
services.hyperhive.deploy.swarm-controller.enable = true; # the UI comes with it
|
||||||
```
|
```
|
||||||
|
|
||||||
The UI has no switch of its own, and doesn't follow `allSwarmServices`:
|
The UI has no switch of its own (setting `deploy.swarm-ui.enable` or
|
||||||
|
`swarm.ui.enable` has no effect, and warns at evaluation), and doesn't follow `allSwarmServices`:
|
||||||
the UI is a view onto the controller's state and reaches it over that
|
the UI is a view onto the controller's state and reaches it over that
|
||||||
daemon's socket, so the host that runs the controller is the host that
|
daemon's socket, so the host that runs the controller is the host that
|
||||||
can serve the UI. A hive that merely _uses_ a swarm has nothing to serve.
|
can serve the UI. A hive that merely _uses_ a swarm has nothing to serve.
|
||||||
|
|
|
||||||
|
|
@ -28,13 +28,23 @@
|
||||||
# spread across the service modules, so all of them have a single home
|
# spread across the service modules, so all of them have a single home
|
||||||
# and a single file to delete when the deprecation window closes — the
|
# and a single file to delete when the deprecation window closes — the
|
||||||
# shape ./swarm-peers-removed.nix already uses.
|
# shape ./swarm-peers-removed.nix already uses.
|
||||||
{ lib, ... }:
|
{ config, lib, ... }:
|
||||||
let
|
let
|
||||||
# Shared by the two removed spellings of the swarm UI's own switch below.
|
# The swarm UI's own switch, in both spellings. Accepted and ignored: a
|
||||||
swarmUiSwitchRemoved = ''
|
# definition only produces a warning, so a host that still sets one keeps
|
||||||
swarm-ui now runs wherever swarm-controller runs. Remove this
|
# evaluating. `null` is "not set".
|
||||||
definition; services.hyperhive.deploy.swarm-controller.enable decides it.
|
swarmUiSwitchIgnored = lib.mkOption {
|
||||||
|
type = lib.types.nullOr lib.types.bool;
|
||||||
|
default = null;
|
||||||
|
visible = false;
|
||||||
|
description = ''
|
||||||
|
No effect. swarm-ui runs wherever swarm-controller runs.
|
||||||
'';
|
'';
|
||||||
|
};
|
||||||
|
swarmUiSwitchWarning =
|
||||||
|
path: value:
|
||||||
|
lib.optional (value != null)
|
||||||
|
"services.hyperhive.${path} no longer has any effect: swarm-ui now runs wherever swarm-controller runs. Remove this setting; services.hyperhive.deploy.swarm-controller.enable decides it.";
|
||||||
|
|
||||||
# Shared by the two removed spellings of the status-publishing secret below.
|
# Shared by the two removed spellings of the status-publishing secret below.
|
||||||
statusSecretRemoved = ''
|
statusSecretRemoved = ''
|
||||||
|
|
@ -98,20 +108,6 @@ in
|
||||||
be deleted.
|
be deleted.
|
||||||
''
|
''
|
||||||
)
|
)
|
||||||
(lib.mkRemovedOptionModule [
|
|
||||||
"services"
|
|
||||||
"hyperhive"
|
|
||||||
"swarm"
|
|
||||||
"ui"
|
|
||||||
"enable"
|
|
||||||
] swarmUiSwitchRemoved)
|
|
||||||
(lib.mkRemovedOptionModule [
|
|
||||||
"services"
|
|
||||||
"hyperhive"
|
|
||||||
"deploy"
|
|
||||||
"swarm-ui"
|
|
||||||
"enable"
|
|
||||||
] swarmUiSwitchRemoved)
|
|
||||||
(lib.mkRenamedOptionModule
|
(lib.mkRenamedOptionModule
|
||||||
[ "services" "hyperhive" "swarm" "authelia" "enable" ]
|
[ "services" "hyperhive" "swarm" "authelia" "enable" ]
|
||||||
[ "services" "hyperhive" "deploy" "authelia" "enable" ]
|
[ "services" "hyperhive" "deploy" "authelia" "enable" ]
|
||||||
|
|
@ -451,7 +447,7 @@ in
|
||||||
[ "services" "hyperhive" "deploy" "victoriametrics" "package" ]
|
[ "services" "hyperhive" "deploy" "victoriametrics" "package" ]
|
||||||
)
|
)
|
||||||
# With this one `services.hyperhive.swarm.ui` holds nothing at all: its
|
# With this one `services.hyperhive.swarm.ui` holds nothing at all: its
|
||||||
# `enable` is removed above and its `package` is renamed here.
|
# `enable` is an ignored switch (declared below) and its `package` is renamed here.
|
||||||
(lib.mkRenamedOptionModule
|
(lib.mkRenamedOptionModule
|
||||||
[ "services" "hyperhive" "swarm" "ui" "package" ]
|
[ "services" "hyperhive" "swarm" "ui" "package" ]
|
||||||
[ "services" "hyperhive" "deploy" "swarm-ui" "package" ]
|
[ "services" "hyperhive" "deploy" "swarm-ui" "package" ]
|
||||||
|
|
@ -490,7 +486,14 @@ in
|
||||||
# ⚠️ Only `deploy.forgejo.enable` is declared here. The rest of
|
# ⚠️ Only `deploy.forgejo.enable` is declared here. The rest of
|
||||||
# `deploy.forgejo` is in ./hive-forge/default.nix: the knobs live with the
|
# `deploy.forgejo` is in ./hive-forge/default.nix: the knobs live with the
|
||||||
# module that reads them; this file stays the registry of toggles.
|
# module that reads them; this file stays the registry of toggles.
|
||||||
|
options.services.hyperhive.swarm.ui.enable = swarmUiSwitchIgnored;
|
||||||
|
|
||||||
|
config.warnings =
|
||||||
|
swarmUiSwitchWarning "deploy.swarm-ui.enable" config.services.hyperhive.deploy.swarm-ui.enable
|
||||||
|
++ swarmUiSwitchWarning "swarm.ui.enable" config.services.hyperhive.swarm.ui.enable;
|
||||||
|
|
||||||
options.services.hyperhive.deploy = {
|
options.services.hyperhive.deploy = {
|
||||||
|
swarm-ui.enable = swarmUiSwitchIgnored;
|
||||||
forgejo.enable = lib.mkOption {
|
forgejo.enable = lib.mkOption {
|
||||||
type = lib.types.bool;
|
type = lib.types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
|
|
|
||||||
|
|
@ -75,8 +75,8 @@ let
|
||||||
# saying "it is not there" would hold just as well if it were never there.
|
# saying "it is not there" would hold just as well if it were never there.
|
||||||
# Package stubbed per this file's header: the vhost roots at it.
|
# Package stubbed per this file's header: the vhost roots at it.
|
||||||
#
|
#
|
||||||
# Also sets both removed UI switches to `false`: the vhost must render
|
# Also sets both ignored UI switches to `false`: the vhost must render
|
||||||
# regardless, and each must fail evaluation through its assertion. Neither
|
# regardless, and each must evaluate and warn. Neither
|
||||||
# is read anywhere else, so they change nothing the other arms see.
|
# is read anywhere else, so they change nothing the other arms see.
|
||||||
swarmUiHere = hive {
|
swarmUiHere = hive {
|
||||||
deploy.swarm-controller.enable = true;
|
deploy.swarm-controller.enable = true;
|
||||||
|
|
@ -245,24 +245,23 @@ let
|
||||||
ok = swarmUiHere.services.nginx.virtualHosts ? "t.local";
|
ok = swarmUiHere.services.nginx.virtualHosts ? "t.local";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
# Control: `swarmServicesHere` sets neither removed switch.
|
# Control: `swarmServicesHere` sets neither ignored switch.
|
||||||
name = "a definition of a removed swarm UI switch fails evaluation, naming the option and the controller";
|
name = "a definition of an ignored swarm UI switch evaluates and warns, naming the option and the controller";
|
||||||
ok =
|
ok =
|
||||||
let
|
let
|
||||||
refused =
|
warned =
|
||||||
m: path:
|
m: path:
|
||||||
lib.any (
|
lib.any (
|
||||||
a:
|
w:
|
||||||
!a.assertion
|
lib.hasInfix "services.hyperhive.${path} no longer has any effect" w
|
||||||
&& lib.hasInfix "services.hyperhive.${path}" a.message
|
&& lib.hasInfix "swarm-ui now runs wherever swarm-controller runs" w
|
||||||
&& lib.hasInfix "swarm-ui now runs wherever swarm-controller runs" a.message
|
) m.warnings;
|
||||||
) m.assertions;
|
|
||||||
paths = [
|
paths = [
|
||||||
"deploy.swarm-ui.enable"
|
"deploy.swarm-ui.enable"
|
||||||
"swarm.ui.enable"
|
"swarm.ui.enable"
|
||||||
];
|
];
|
||||||
in
|
in
|
||||||
lib.all (refused swarmUiHere) paths && !(lib.any (refused swarmServicesHere) paths);
|
lib.all (warned swarmUiHere) paths && !(lib.any (warned swarmServicesHere) paths);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
# The swarm-services toggle enables them explicitly, from its own
|
# The swarm-services toggle enables them explicitly, from its own
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue