summary refs log tree commit diff
path: root/nixos/modules/system/boot/networkd.nix
diff options
context:
space:
mode:
authorFlorian Jacob <projects+git@florianjacob.de>2017-07-27 19:49:56 +0200
committerFranz Pletz <fpletz@fnordicwalking.de>2017-07-29 21:25:21 +0200
commit3e69c650abf8bc1c0bcc2a60d97802c70c06c68e (patch)
tree5a222f112eeae0765cfebedde6828c245af8799f /nixos/modules/system/boot/networkd.nix
parente09bb50d764c6ab7d57954891caea0c48879c493 (diff)
downloadnixpkgs-3e69c650abf8bc1c0bcc2a60d97802c70c06c68e.tar
nixpkgs-3e69c650abf8bc1c0bcc2a60d97802c70c06c68e.tar.gz
nixpkgs-3e69c650abf8bc1c0bcc2a60d97802c70c06c68e.tar.bz2
nixpkgs-3e69c650abf8bc1c0bcc2a60d97802c70c06c68e.tar.lz
nixpkgs-3e69c650abf8bc1c0bcc2a60d97802c70c06c68e.tar.xz
nixpkgs-3e69c650abf8bc1c0bcc2a60d97802c70c06c68e.tar.zst
nixpkgs-3e69c650abf8bc1c0bcc2a60d97802c70c06c68e.zip
nixos/systemd-networkd: allow [Link] section in .network files
Diffstat (limited to 'nixos/modules/system/boot/networkd.nix')
-rw-r--r--nixos/modules/system/boot/networkd.nix30
1 files changed, 30 insertions, 0 deletions
diff --git a/nixos/modules/system/boot/networkd.nix b/nixos/modules/system/boot/networkd.nix
index b151b568892..9d2cea3ad16 100644
--- a/nixos/modules/system/boot/networkd.nix
+++ b/nixos/modules/system/boot/networkd.nix
@@ -142,6 +142,18 @@ let
     (assertValueOneOf "EmitTimezone" boolValues)
   ];
 
+  # .network files have a [Link] section with different options than in .netlink files
+  checkNetworkLink = checkUnitConfig "Link" [
+    (assertOnlyFields [
+      "MACAddress" "MTUBytes" "ARP" "Unmanaged"
+    ])
+    (assertMacAddress "MACAddress")
+    (assertByteFormat "MTUBytes")
+    (assertValueOneOf "ARP" boolValues)
+    (assertValueOneOf "Unmanaged" boolValues)
+  ];
+
+
   commonNetworkOptions = {
 
     enable = mkOption {
@@ -371,6 +383,18 @@ let
       '';
     };
 
+    linkConfig = mkOption {
+      default = {};
+      example = { Unmanaged = true; };
+      type = types.addCheck (types.attrsOf unitOption) checkNetworkLink;
+      description = ''
+        Each attribute in this set specifies an option in the
+        <literal>[Link]</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;
@@ -581,6 +605,12 @@ let
     { inherit (def) enable;
       text = commonMatchText def +
         ''
+          ${optionalString (def.linkConfig != { }) ''
+            [Link]
+            ${attrsToSection def.linkConfig}
+
+          ''}
+
           [Network]
           ${attrsToSection def.networkConfig}
           ${concatStringsSep "\n" (map (s: "Address=${s}") def.address)}