mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-01-21 12:51:34 +01:00
nebula: Allow non-lighthouse nodes to be static hosts
This commit is contained in:
parent
cb5177f595
commit
61f4ac9053
1 changed files with 11 additions and 7 deletions
|
|
@ -9,13 +9,16 @@ let
|
||||||
|
|
||||||
hostname = config.networking.hostName;
|
hostname = config.networking.hostName;
|
||||||
|
|
||||||
lighthouses =
|
nodes =
|
||||||
self.nixosConfigurations
|
self.nixosConfigurations
|
||||||
|> lib.filterAttrs (name: _: name != hostname)
|
|> lib.filterAttrs (name: _: name != hostname)
|
||||||
|> lib.attrValues
|
|> lib.attrValues
|
||||||
|> lib.map (value: value.config.custom.services.nebula.node)
|
|> lib.map (value: value.config.custom.services.nebula.node)
|
||||||
|> lib.filter (nebula: nebula.enable)
|
|> lib.filter (node: node.enable);
|
||||||
|> lib.filter (nebula: nebula.isLighthouse);
|
|
||||||
|
lighthouses = nodes |> lib.filter (node: node.isLighthouse);
|
||||||
|
|
||||||
|
routableNodes = nodes |> lib.filter (node: node.routableAddress != null);
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.custom.services.nebula.node = {
|
options.custom.services.nebula.node = {
|
||||||
|
|
@ -28,15 +31,15 @@ in
|
||||||
type = lib.types.nonEmptyStr;
|
type = lib.types.nonEmptyStr;
|
||||||
default = "";
|
default = "";
|
||||||
};
|
};
|
||||||
|
|
||||||
isLighthouse = lib.mkEnableOption "";
|
isLighthouse = lib.mkEnableOption "";
|
||||||
|
|
||||||
routableAddress = lib.mkOption {
|
routableAddress = lib.mkOption {
|
||||||
type = lib.types.nullOr lib.types.nonEmptyStr;
|
type = lib.types.nullOr lib.types.nonEmptyStr;
|
||||||
default = null;
|
default = null;
|
||||||
};
|
};
|
||||||
routablePort = lib.mkOption {
|
routablePort = lib.mkOption {
|
||||||
type = lib.types.nullOr lib.types.port;
|
type = lib.types.nullOr lib.types.port;
|
||||||
default = if cfg.isLighthouse then 47141 else null;
|
default = if cfg.routableAddress != null then 47141 else null;
|
||||||
};
|
};
|
||||||
|
|
||||||
pubPath = lib.mkOption {
|
pubPath = lib.mkOption {
|
||||||
|
|
@ -50,7 +53,7 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
meta.ports.udp = lib.optional (cfg.routablePort != 0) cfg.routablePort;
|
meta.ports.udp = lib.optional (cfg.routablePort != null) cfg.routablePort;
|
||||||
|
|
||||||
sops.secrets."nebula/host-key" = {
|
sops.secrets."nebula/host-key" = {
|
||||||
owner = config.users.users.nebula-main.name;
|
owner = config.users.users.nebula-main.name;
|
||||||
|
|
@ -70,8 +73,9 @@ in
|
||||||
lighthouses = lib.mkIf (!cfg.isLighthouse) (
|
lighthouses = lib.mkIf (!cfg.isLighthouse) (
|
||||||
lighthouses |> lib.map (lighthouse: lighthouse.address)
|
lighthouses |> lib.map (lighthouse: lighthouse.address)
|
||||||
);
|
);
|
||||||
|
|
||||||
staticHostMap =
|
staticHostMap =
|
||||||
lighthouses
|
routableNodes
|
||||||
|> lib.map (lighthouse: {
|
|> lib.map (lighthouse: {
|
||||||
name = lighthouse.address;
|
name = lighthouse.address;
|
||||||
value = lib.singleton "${lighthouse.routableAddress}:${toString lighthouse.routablePort}";
|
value = lib.singleton "${lighthouse.routableAddress}:${toString lighthouse.routablePort}";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue