diff options
Diffstat (limited to 'nix/deuxfleurs.nix')
-rw-r--r-- | nix/deuxfleurs.nix | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/nix/deuxfleurs.nix b/nix/deuxfleurs.nix index 4423318..0f5c185 100644 --- a/nix/deuxfleurs.nix +++ b/nix/deuxfleurs.nix @@ -19,7 +19,7 @@ in }; staticIPv6.address = mkOption { description = "Static public IPv6 address of this node"; - type = str; + type = nullOr str; }; isRaftServer = mkOption { description = "Make this node a RAFT server for the Nomad and Consul deployments"; @@ -129,8 +129,10 @@ in clusterAddress = clusterNodeCfg.address; node_meta = { "site" = cfg.siteName; - "public_ipv6" = cfg.staticIPv6.address; } // + (if cfg.staticIPv6.address != null + then { "public_ipv6" = cfg.staticIPv6.address; } + else {}) // (if cfg.publicIPv4 != null then { "public_ipv4" = cfg.publicIPv4; } else {}) // @@ -156,11 +158,12 @@ in # IPv4 configuration is obtained by DHCP by default, # unless a static v4 address and default gateway are given noDHCP = cfg.staticIPv4.address != null && cfg.staticIPv4.defaultGateway != null; - # IPv6 configuration is obtained through router advertisements - # (RA), using a static token to ensure a static IPv6, - # unless defaultGateway is specified, in which case RAs are - # disabled entirely - noRA = cfg.staticIPv6.defaultGateway != null; + # IPv6 configuration is obtained through router advertisements (RA), + # possibly using a static token to ensure a static IPv6, + # unless a static v6 address and default gateway are given, + # in which case RAs are disabled entirely + noRA = cfg.staticIPv6.address != null && cfg.staticIPv6.defaultGateway != null; + staticV6 = cfg.staticIPv6.address != null; in { matchConfig.Name = "en* eth*"; @@ -189,7 +192,7 @@ in # Dynamic IPv6: only fetch default route, use static # address and no DNS servers - ipv6AcceptRAConfig.Token = mkIf (!noRA) "static:${cfg.staticIPv6.address}"; + ipv6AcceptRAConfig.Token = mkIf (!noRA && staticV6) "static:${cfg.staticIPv6.address}"; ipv6AcceptRAConfig.UseDNS = mkIf (!noRA) false; # Static IPv6: disable all router advertisements and |