deploy: move the wireguard mesh out of the namespace hives read
`swarm.*` is what a hive needs to be a *client* of the swarm; the mesh is none of it. A peer needs this host's `wireguardEndpoint` -- the roster entry in swarm.nix, which stays -- and nothing about the interface this host brings up. The module already said so: "plain host networking that a machine which runs no hive at all still needs." All five options move, so the namespace relocates rather than splitting. `listenPort` is the one that reads the other way: it is what this host *binds*, while the port a peer *dials* lives inside `wireguardEndpoint`. Declared in swarm-wireguard.nix under the `deploy.*` path, following swarm-victorialogs.nix; deploy.nix carries only the renames, per its own "a single file to delete when the deprecation window closes". Deliberately NOT added to deploy.nix's own options block: every entry there is a swarm service this host deploys, and the mesh is host networking. hivectl/src/wg.rs generates the config snippet an operator pastes, so it moves too -- otherwise the tool's own output trips the deprecation warning. module-eval gains a case that configures a host through the OLD path and asserts the rendered wg-hive interface, because the new path evaluates fine without the shim: dropping it reads as a clean tree.
This commit is contained in:
parent
c7c221baeb
commit
368f5d82aa
10 changed files with 85 additions and 27 deletions
|
|
@ -8,6 +8,14 @@
|
|||
# The two stay coupled by data, not by structure: the per-peer
|
||||
# `wireguard*` fields live on the peer submodule in ./swarm.nix, since
|
||||
# that is where a peer is described, and this module reads them.
|
||||
#
|
||||
# Everything declared here is `deploy.*`, not `swarm.*`: by ./deploy.nix's
|
||||
# rule, `swarm.*` is what a hive needs to be a *client* of the swarm, and
|
||||
# none of this is. A peer needs this host's `wireguardEndpoint` (the roster
|
||||
# entry in ./swarm.nix); what interface this host brings up, on which
|
||||
# address, with which key, is nobody else's business. `listenPort` included
|
||||
# — it is what this host binds, while the port a peer dials is the one
|
||||
# inside `wireguardEndpoint`.
|
||||
{
|
||||
lib,
|
||||
config,
|
||||
|
|
@ -19,7 +27,7 @@
|
|||
# `wireguardPublicKey` declared. Peers reachable over the mesh are
|
||||
# preferred for inter-hive traffic (no public TLS round-trip needed);
|
||||
# peers without a public key still work via normal HTTPS.
|
||||
options.services.hyperhive.swarm.wireguard = {
|
||||
options.services.hyperhive.deploy.wireguard = {
|
||||
enable = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
|
|
@ -39,7 +47,7 @@
|
|||
Path to the host's WireGuard private key file. The file must
|
||||
be readable by root and should have mode 0400. Generate with
|
||||
`wg genkey > /etc/wireguard/hive.key`. Required when
|
||||
`swarm.wireguard.enable = true`.
|
||||
`deploy.wireguard.enable = true`.
|
||||
'';
|
||||
};
|
||||
|
||||
|
|
@ -83,21 +91,21 @@
|
|||
# at all. Nothing below is c0re-specific; the peer data c0re consumes
|
||||
# (HIVE_PEER_CA_PATHS) is rendered in ./hive-c0re and stays gated
|
||||
# there.
|
||||
config = lib.mkIf config.services.hyperhive.swarm.wireguard.enable {
|
||||
config = lib.mkIf config.services.hyperhive.deploy.wireguard.enable {
|
||||
assertions = [
|
||||
{
|
||||
assertion = config.services.hyperhive.swarm.wireguard.privateKeyFile != null;
|
||||
assertion = config.services.hyperhive.deploy.wireguard.privateKeyFile != null;
|
||||
message = ''
|
||||
services.hyperhive.swarm.wireguard.enable requires
|
||||
services.hyperhive.swarm.wireguard.privateKeyFile to be set.
|
||||
services.hyperhive.deploy.wireguard.enable requires
|
||||
services.hyperhive.deploy.wireguard.privateKeyFile to be set.
|
||||
Generate a key: wg genkey > /etc/wireguard/hive.key
|
||||
'';
|
||||
}
|
||||
{
|
||||
assertion = config.services.hyperhive.swarm.wireguard.address != "";
|
||||
assertion = config.services.hyperhive.deploy.wireguard.address != "";
|
||||
message = ''
|
||||
services.hyperhive.swarm.wireguard.enable requires
|
||||
services.hyperhive.swarm.wireguard.address to be set
|
||||
services.hyperhive.deploy.wireguard.enable requires
|
||||
services.hyperhive.deploy.wireguard.address to be set
|
||||
(e.g. "10.100.0.1/24").
|
||||
'';
|
||||
}
|
||||
|
|
@ -107,7 +115,7 @@
|
|||
# connects to each peer that has `wireguardPublicKey` set.
|
||||
networking.wireguard.interfaces =
|
||||
let
|
||||
wgCfg = config.services.hyperhive.swarm.wireguard;
|
||||
wgCfg = config.services.hyperhive.deploy.wireguard;
|
||||
# `peerHives` is `swarm.hives` minus this hive (../swarm.nix) —
|
||||
# a mesh that included our own entry would configure a tunnel to
|
||||
# ourselves.
|
||||
|
|
@ -139,7 +147,7 @@
|
|||
# Open the WireGuard UDP port on the host firewall (host-level
|
||||
# networking — not inside containers).
|
||||
networking.firewall.allowedUDPPorts = [
|
||||
config.services.hyperhive.swarm.wireguard.listenPort
|
||||
config.services.hyperhive.deploy.wireguard.listenPort
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue