summary refs log tree commit diff
path: root/nixos/modules/system/boot/networkd.nix
diff options
context:
space:
mode:
authorMaximilian Bosch <maximilian@mbosch.me>2020-01-25 16:46:39 +0100
committerMaximilian Bosch <maximilian@mbosch.me>2020-01-25 17:38:15 +0100
commitbc130855a7d683618157362cb83fdf42caa5cb1a (patch)
treeb19babc68ff2dedad09fd5bfe84deac673032942 /nixos/modules/system/boot/networkd.nix
parent21ae4ae8795f8cd06421a123dbb5ddaea9bb219c (diff)
downloadnixpkgs-bc130855a7d683618157362cb83fdf42caa5cb1a.tar
nixpkgs-bc130855a7d683618157362cb83fdf42caa5cb1a.tar.gz
nixpkgs-bc130855a7d683618157362cb83fdf42caa5cb1a.tar.bz2
nixpkgs-bc130855a7d683618157362cb83fdf42caa5cb1a.tar.lz
nixpkgs-bc130855a7d683618157362cb83fdf42caa5cb1a.tar.xz
nixpkgs-bc130855a7d683618157362cb83fdf42caa5cb1a.tar.zst
nixpkgs-bc130855a7d683618157362cb83fdf42caa5cb1a.zip
nixos/networkd: add `vrfConfig` option to netdevs
Diffstat (limited to 'nixos/modules/system/boot/networkd.nix')
-rw-r--r--nixos/modules/system/boot/networkd.nix25
1 files changed, 25 insertions, 0 deletions
diff --git a/nixos/modules/system/boot/networkd.nix b/nixos/modules/system/boot/networkd.nix
index 56a9d6b1138..a684238a2ad 100644
--- a/nixos/modules/system/boot/networkd.nix
+++ b/nixos/modules/system/boot/networkd.nix
@@ -55,6 +55,11 @@ let
     (assertMacAddress "MACAddress")
   ];
 
+  checkVRF = checkUnitConfig "VRF" [
+    (assertOnlyFields [ "Table" ])
+    (assertMinimum "Table" 0)
+  ];
+
   # NOTE The PrivateKey directive is missing on purpose here, please
   # do not add it to this list. The nix store is world-readable let's
   # refrain ourselves from providing a footgun.
@@ -349,6 +354,21 @@ let
       '';
     };
 
+    vrfConfig = mkOption {
+      default = {};
+      example = { Table = 2342; };
+      type = types.addCheck (types.attrsOf unitOption) checkVRF;
+      description = ''
+        Each attribute in this set specifies an option in the
+        <literal>[VRF]</literal> section of the unit. See
+        <citerefentry><refentrytitle>systemd.netdev</refentrytitle>
+        <manvolnum>5</manvolnum></citerefentry> for details.
+        A detailed explanation about how VRFs work can be found in the
+        <link xlink:href="https://www.kernel.org/doc/Documentation/networking/vrf.txt">kernel
+        docs</link>.
+      '';
+    };
+
     wireguardConfig = mkOption {
       default = {};
       example = {
@@ -845,6 +865,11 @@ let
             ${attrsToSection def.xfrmConfig}
 
           ''}
+          ${optionalString (def.vrfConfig != { }) ''
+            [VRF]
+            ${attrsToSection def.vrfConfig}
+
+          ''}
           ${optionalString (def.wireguardConfig != { }) ''
             [WireGuard]
             ${attrsToSection def.wireguardConfig}