nebula: Move advertise address/port options

This commit is contained in:
SebastianStork 2026-03-04 21:50:50 +01:00
parent ef17aad9d1
commit b4f740e7be
Signed by: SebastianStork
SSH key fingerprint: SHA256:tRrGdjYOwgHxpSc/wTOZQZEjxcb15P0tyXRsbAfd+2Q
3 changed files with 24 additions and 27 deletions

View file

@ -15,10 +15,6 @@
overlay = { overlay = {
address = "10.254.250.6"; address = "10.254.250.6";
isLighthouse = true; isLighthouse = true;
advertise = {
address = "130.83.103.62";
port = 47033;
};
}; };
underlay = { underlay = {
interface = "enp2s0"; interface = "enp2s0";
@ -28,6 +24,11 @@
}; };
services = { services = {
nebula.advertise = {
address = "130.83.103.62";
port = 47033;
};
recursive-nameserver = { recursive-nameserver = {
enable = true; enable = true;
blockAds = true; blockAds = true;

View file

@ -51,22 +51,6 @@ in
}; };
isLighthouse = lib.mkEnableOption ""; isLighthouse = lib.mkEnableOption "";
advertise = {
address = lib.mkOption {
type = lib.types.nullOr lib.types.nonEmptyStr;
default =
if config.custom.networking.underlay.isPublic then
config.custom.networking.underlay.address
else
null;
};
port = lib.mkOption {
type = lib.types.nullOr lib.types.port;
default = if cfg.advertise.address != null then config.custom.services.nebula.listenPort else null;
};
};
role = lib.mkOption { role = lib.mkOption {
type = lib.types.enum [ type = lib.types.enum [
"client" "client"

View file

@ -2,6 +2,7 @@
config, config,
self, self,
lib, lib,
allHosts,
... ...
}: }:
let let
@ -27,7 +28,17 @@ in
listenPort = lib.mkOption { listenPort = lib.mkOption {
type = lib.types.port; type = lib.types.port;
default = if (netCfg.overlay.advertise.address != null) then 47141 else 0; default = if (cfg.advertise.address != null) then 47141 else 0;
};
advertise = {
address = lib.mkOption {
type = lib.types.nullOr lib.types.nonEmptyStr;
default = if netCfg.underlay.isPublic then netCfg.underlay.address else null;
};
port = lib.mkOption {
type = lib.types.nullOr lib.types.port;
default = if cfg.advertise.address != null then cfg.listenPort else null;
};
}; };
caCertificateFile = lib.mkOption { caCertificateFile = lib.mkOption {
@ -50,7 +61,7 @@ in
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
assertions = lib.singleton { assertions = lib.singleton {
assertion = netCfg.overlay.isLighthouse -> netCfg.overlay.advertise.address != null; assertion = netCfg.overlay.isLighthouse -> cfg.advertise.address != null;
message = "`${netCfg.hostName}` is a Nebula lighthouse, but `underlay.isPublic` or `overlay.advertise.address` are not set. Lighthouses must be publicly reachable."; message = "`${netCfg.hostName}` is a Nebula lighthouse, but `underlay.isPublic` or `overlay.advertise.address` are not set. Lighthouses must be publicly reachable.";
}; };
@ -96,11 +107,12 @@ in
relays = lib.mkIf (!netCfg.overlay.isLighthouse) lighthouses; relays = lib.mkIf (!netCfg.overlay.isLighthouse) lighthouses;
staticHostMap = staticHostMap =
netCfg.peers allHosts
|> lib.filter (peer: peer.overlay.advertise.address != null) |> lib.attrValues
|> lib.map (peer: { |> lib.filter (host: host.config.custom.services.nebula.advertise.address != null)
name = peer.overlay.address; |> lib.map (host: {
value = lib.singleton "${peer.overlay.advertise.address}:${toString peer.overlay.advertise.port}"; name = host.config.custom.networking.overlay.address;
value = lib.singleton "${host.config.custom.services.nebula.advertise.address}:${toString host.config.custom.services.nebula.advertise.port}";
}) })
|> lib.listToAttrs; |> lib.listToAttrs;