summary refs log tree commit diff
path: root/nixos/modules
diff options
context:
space:
mode:
authorRobin Gloster <mail@glob.in>2016-01-20 13:06:44 +0100
committerRobin Gloster <mail@glob.in>2016-01-20 13:06:44 +0100
commiteac8cb1ce1be30dc06a7950460b55c827b221374 (patch)
tree19941d39cb171e9d67ed8d481ffa85f444bb9183 /nixos/modules
parent5f8c3ffacac5fb4b5af0b9e3bdaf88dcf2aff0f2 (diff)
parent83a64cecc9fbe62d187428535774b2a1293afeaf (diff)
downloadnixlib-eac8cb1ce1be30dc06a7950460b55c827b221374.tar
nixlib-eac8cb1ce1be30dc06a7950460b55c827b221374.tar.gz
nixlib-eac8cb1ce1be30dc06a7950460b55c827b221374.tar.bz2
nixlib-eac8cb1ce1be30dc06a7950460b55c827b221374.tar.lz
nixlib-eac8cb1ce1be30dc06a7950460b55c827b221374.tar.xz
nixlib-eac8cb1ce1be30dc06a7950460b55c827b221374.tar.zst
nixlib-eac8cb1ce1be30dc06a7950460b55c827b221374.zip
Merge pull request #11896 from mayflower/upstream-networkd
networkd: add IPForward IPMasquerade options,  DHCPServer section
Diffstat (limited to 'nixos/modules')
-rw-r--r--nixos/modules/system/boot/networkd.nix31
1 files changed, 30 insertions, 1 deletions
diff --git a/nixos/modules/system/boot/networkd.nix b/nixos/modules/system/boot/networkd.nix
index 34eea9af83b1..ab7485500261 100644
--- a/nixos/modules/system/boot/networkd.nix
+++ b/nixos/modules/system/boot/networkd.nix
@@ -93,11 +93,13 @@ let
 
   checkNetwork = checkUnitConfig "Network" [
     (assertOnlyFields [
-      "Description" "DHCP" "DHCPServer" "IPv4LL" "IPv4LLRoute"
+      "Description" "DHCP" "DHCPServer" "IPForward" "IPMasquerade" "IPv4LL" "IPv4LLRoute"
       "LLMNR" "Domains" "Bridge" "Bond"
     ])
     (assertValueOneOf "DHCP" ["both" "none" "v4" "v6"])
     (assertValueOneOf "DHCPServer" boolValues)
+    (assertValueOneOf "IPForward" ["yes" "no" "ipv4" "ipv6"])
+    (assertValueOneOf "IPMasquerade" boolValues)
     (assertValueOneOf "IPv4LL" boolValues)
     (assertValueOneOf "IPv4LLRoute" boolValues)
     (assertValueOneOf "LLMNR" boolValues)
@@ -129,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 {
@@ -341,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
+        <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;
@@ -566,6 +590,11 @@ let
             ${attrsToSection def.dhcpConfig}
 
           ''}
+          ${optionalString (def.dhcpServerConfig != { }) ''
+            [DHCPServer]
+            ${attrsToSection def.dhcpServerConfig}
+
+          ''}
           ${flip concatMapStrings def.addresses (x: ''
             [Address]
             ${attrsToSection x.addressConfig}