diff --git a/nixos/modules/system/boot/networkd.nix b/nixos/modules/system/boot/networkd.nix
index b9fb4b12e7d..ab748550026 100644
--- a/nixos/modules/system/boot/networkd.nix
+++ b/nixos/modules/system/boot/networkd.nix
@@ -131,6 +131,16 @@ let
(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 {
@@ -343,6 +353,18 @@ let
'';
};
+ 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
+ [DHCPServer] section of the unit. See
+ systemd.network
+ 5 for details.
+ '';
+ };
+
name = mkOption {
type = types.nullOr types.str;
default = null;
@@ -567,6 +589,11 @@ let
[DHCP]
${attrsToSection def.dhcpConfig}
+ ''}
+ ${optionalString (def.dhcpServerConfig != { }) ''
+ [DHCPServer]
+ ${attrsToSection def.dhcpServerConfig}
+
''}
${flip concatMapStrings def.addresses (x: ''
[Address]