mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-03-22 16:39:07 +01:00
nebula: Move advertise address/port options
This commit is contained in:
parent
ef17aad9d1
commit
b4f740e7be
3 changed files with 24 additions and 27 deletions
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue