Skip to content

Commit 3e69c65

Browse files
florianjacobfpletz
authored andcommittedJul 29, 2017
nixos/systemd-networkd: allow [Link] section in .network files
1 parent e09bb50 commit 3e69c65

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
 

‎nixos/modules/system/boot/networkd.nix

+30
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,18 @@ let
142142
(assertValueOneOf "EmitTimezone" boolValues)
143143
];
144144

145+
# .network files have a [Link] section with different options than in .netlink files
146+
checkNetworkLink = checkUnitConfig "Link" [
147+
(assertOnlyFields [
148+
"MACAddress" "MTUBytes" "ARP" "Unmanaged"
149+
])
150+
(assertMacAddress "MACAddress")
151+
(assertByteFormat "MTUBytes")
152+
(assertValueOneOf "ARP" boolValues)
153+
(assertValueOneOf "Unmanaged" boolValues)
154+
];
155+
156+
145157
commonNetworkOptions = {
146158

147159
enable = mkOption {
@@ -371,6 +383,18 @@ let
371383
'';
372384
};
373385

386+
linkConfig = mkOption {
387+
default = {};
388+
example = { Unmanaged = true; };
389+
type = types.addCheck (types.attrsOf unitOption) checkNetworkLink;
390+
description = ''
391+
Each attribute in this set specifies an option in the
392+
<literal>[Link]</literal> section of the unit. See
393+
<citerefentry><refentrytitle>systemd.network</refentrytitle>
394+
<manvolnum>5</manvolnum></citerefentry> for details.
395+
'';
396+
};
397+
374398
name = mkOption {
375399
type = types.nullOr types.str;
376400
default = null;
@@ -581,6 +605,12 @@ let
581605
{ inherit (def) enable;
582606
text = commonMatchText def +
583607
''
608+
${optionalString (def.linkConfig != { }) ''
609+
[Link]
610+
${attrsToSection def.linkConfig}
611+
612+
''}
613+
584614
[Network]
585615
${attrsToSection def.networkConfig}
586616
${concatStringsSep "\n" (map (s: "Address=${s}") def.address)}

0 commit comments

Comments
 (0)
Please sign in to comment.