git.iko.soy/typeable/nixpkgs
on master help sign in
nixos/systemd-networkd: allow [Link] section in .network files
commit3e69c650abf8bc1c0bcc2a60d97802c70c06c68e authorFlorian Jacob <projects+git@florianjacob.de> dateThu 27 Jul 2017, 19:49 (9 years ago) parente09bb50
1 file changed+30
nixos/modules/system/boot/networkd.nix+30
nixos/modules/system/boot/networkd.nix+30
@@ -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)}