networkd: add DHCPServer config section

Changed files
+27
nixos
modules
system
+27
nixos/modules/system/boot/networkd.nix
···
(assertValueOneOf "RequestBroadcast" boolValues)
];
+
checkDhcpServer = checkUnitConfig "DHCPServer" [
+
(assertOnlyFields [
+
"PoolOffset" "PoolSize" "DefaultLeaseTimeSec" "MaxLeaseTimeSec"
+
"EmitDNS" "DNS" "EmitNTP" "NTP" "EmitTimezone" "Timezone"
+
])
+
(assertValueOneOf "EmitDNS" boolValues)
+
(assertValueOneOf "EmitNTP" boolValues)
+
(assertValueOneOf "EmitTimezone" boolValues)
+
];
+
commonNetworkOptions = {
enable = mkOption {
···
'';
};
+
dhcpServerConfig = mkOption {
+
default = {};
+
example = { PoolOffset = 50; EmitDNS = false; };
+
type = types.addCheck (types.attrsOf unitOption) checkDhcpServer;
+
description = ''
+
Each attribute in this set specifies an option in the
+
<literal>[DHCPServer]</literal> section of the unit. See
+
<citerefentry><refentrytitle>systemd.network</refentrytitle>
+
<manvolnum>5</manvolnum></citerefentry> for details.
+
'';
+
};
+
name = mkOption {
type = types.nullOr types.str;
default = null;
···
${optionalString (def.dhcpConfig != { }) ''
[DHCP]
${attrsToSection def.dhcpConfig}
+
+
''}
+
${optionalString (def.dhcpServerConfig != { }) ''
+
[DHCPServer]
+
${attrsToSection def.dhcpServerConfig}
''}
${flip concatMapStrings def.addresses (x: ''