aboutsummaryrefslogtreecommitdiff
path: root/nix
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2023-04-21 14:36:10 +0200
committerAlex Auvolat <alex@adnab.me>2023-04-21 14:36:10 +0200
commit607add3161f9a465fc061cfd3a5434aa4dbd4796 (patch)
tree516a0406ec8aa76ba8ebbdaac4ea245003bc402e /nix
parentc4598bd84fa000ea1631bab8d67a0c8f1929141c (diff)
downloadnixcfg-607add3161f9a465fc061cfd3a5434aa4dbd4796.tar.gz
nixcfg-607add3161f9a465fc061cfd3a5434aa4dbd4796.zip
make specifying an ipv6 fully optionnal
Diffstat (limited to 'nix')
-rw-r--r--nix/deuxfleurs.nix19
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