From 5abd9a74fc493c2e8be869bfb28a2f5d60ae0d6b Mon Sep 17 00:00:00 2001 From: Andreas Rammhold Date: Sat, 7 Mar 2020 14:44:46 +0100 Subject: [PATCH] nixos/networkd: add ipv6PrefixDelegationConfig to networkd --- nixos/modules/system/boot/networkd.nix | 31 ++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/nixos/modules/system/boot/networkd.nix b/nixos/modules/system/boot/networkd.nix index 887d1de95ff3..ea86762db121 100644 --- a/nixos/modules/system/boot/networkd.nix +++ b/nixos/modules/system/boot/networkd.nix @@ -310,6 +310,20 @@ let (assertValueOneOf "ForceDHCPv6PDOtherInformation" boolValues) ]; + checkIpv6PrefixDelegation = checkUnitConfig "IPv6PrefixDelegation" [ + (assertOnlyFields [ + "Managed" "OtherInformation" "RouterLifetimeSec" + "RouterPreference" "EmitDNS" "DNS" "EmitDomains" "Domains" + "DNSLifetimeSec" + ]) + (assertValueOneOf "Managed" boolValues) + (assertValueOneOf "OtherInformation" boolValues) + (assertValueOneOf "RouterPreference" ["high" "medium" "low" "normal" "default"]) + (assertValueOneOf "EmitDNS" boolValues) + (assertValueOneOf "EmitDomains" boolValues) + (assertMinimum "DNSLifetimeSec" 0) + ]; + checkDhcpServer = checkUnitConfig "DHCPServer" [ (assertOnlyFields [ "PoolOffset" "PoolSize" "DefaultLeaseTimeSec" "MaxLeaseTimeSec" @@ -679,6 +693,18 @@ let ''; }; + ipv6PrefixDelegationConfig = mkOption { + default = {}; + example = { EmitDNS = true; Managed = true; OtherInformation = true; }; + type = types.addCheck (types.attrsOf unitOption) checkIpv6PrefixDelegation; + description = '' + Each attribute in this set specifies an option in the + [IPv6PrefixDelegation] section of the unit. See + systemd.network + 5 for details. + ''; + }; + dhcpServerConfig = mkOption { default = {}; example = { PoolOffset = 50; EmitDNS = false; }; @@ -1013,6 +1039,11 @@ let [DHCPv6] ${attrsToSection def.dhcpV6Config} + ''} + ${optionalString (def.ipv6PrefixDelegationConfig != {}) '' + [IPv6PrefixDelegation] + ${attrsToSection def.ipv6PrefixDelegationConfig} + ''} ${optionalString (def.dhcpServerConfig != { }) '' [DHCPServer]