nixos/networkd: delete unnecessary new lines in config files

This commit is contained in:
datafoo 2020-07-01 19:27:49 +02:00
parent bb3ba3e515
commit 6e1a9bbd9b

View File

@ -1335,153 +1335,155 @@ let
linkToUnit = name: def: linkToUnit = name: def:
{ inherit (def) enable; { inherit (def) enable;
text = commonMatchText def + text = commonMatchText def
'' + ''
[Link] [Link]
${attrsToSection def.linkConfig} ${attrsToSection def.linkConfig}
''
${def.extraConfig} + def.extraConfig;
'';
}; };
netdevToUnit = name: def: netdevToUnit = name: def:
{ inherit (def) enable; { inherit (def) enable;
text = commonMatchText def + text = commonMatchText def
'' + ''
[NetDev] [NetDev]
${attrsToSection def.netdevConfig} ${attrsToSection def.netdevConfig}
''
${optionalString (def.vlanConfig != { }) '' + optionalString (def.vlanConfig != { }) ''
[VLAN] [VLAN]
${attrsToSection def.vlanConfig} ${attrsToSection def.vlanConfig}
''
''} + optionalString (def.macvlanConfig != { }) ''
${optionalString (def.macvlanConfig != { }) ''
[MACVLAN] [MACVLAN]
${attrsToSection def.macvlanConfig} ${attrsToSection def.macvlanConfig}
''
''} + optionalString (def.vxlanConfig != { }) ''
${optionalString (def.vxlanConfig != { }) ''
[VXLAN] [VXLAN]
${attrsToSection def.vxlanConfig} ${attrsToSection def.vxlanConfig}
''
''} + optionalString (def.tunnelConfig != { }) ''
${optionalString (def.tunnelConfig != { }) ''
[Tunnel] [Tunnel]
${attrsToSection def.tunnelConfig} ${attrsToSection def.tunnelConfig}
''
''} + optionalString (def.peerConfig != { }) ''
${optionalString (def.peerConfig != { }) ''
[Peer] [Peer]
${attrsToSection def.peerConfig} ${attrsToSection def.peerConfig}
''
''} + optionalString (def.tunConfig != { }) ''
${optionalString (def.tunConfig != { }) ''
[Tun] [Tun]
${attrsToSection def.tunConfig} ${attrsToSection def.tunConfig}
''
''} + optionalString (def.tapConfig != { }) ''
${optionalString (def.tapConfig != { }) ''
[Tap] [Tap]
${attrsToSection def.tapConfig} ${attrsToSection def.tapConfig}
''
''} + optionalString (def.wireguardConfig != { }) ''
${optionalString (def.wireguardConfig != { }) ''
[WireGuard] [WireGuard]
${attrsToSection def.wireguardConfig} ${attrsToSection def.wireguardConfig}
''
''} + flip concatMapStrings def.wireguardPeers (x: ''
${flip concatMapStrings def.wireguardPeers (x: ''
[WireGuardPeer] [WireGuardPeer]
${attrsToSection x.wireguardPeerConfig} ${attrsToSection x.wireguardPeerConfig}
'')
'')} + optionalString (def.bondConfig != { }) ''
${optionalString (def.bondConfig != { }) ''
[Bond] [Bond]
${attrsToSection def.bondConfig} ${attrsToSection def.bondConfig}
''
''} + optionalString (def.xfrmConfig != { }) ''
${optionalString (def.xfrmConfig != { }) ''
[Xfrm] [Xfrm]
${attrsToSection def.xfrmConfig} ${attrsToSection def.xfrmConfig}
''
''} + optionalString (def.vrfConfig != { }) ''
${optionalString (def.vrfConfig != { }) ''
[VRF] [VRF]
${attrsToSection def.vrfConfig} ${attrsToSection def.vrfConfig}
''
''} + def.extraConfig;
${def.extraConfig}
'';
}; };
networkToUnit = name: def: networkToUnit = name: def:
{ inherit (def) enable; { inherit (def) enable;
text = commonMatchText def + text = commonMatchText def
'' + optionalString (def.linkConfig != { }) ''
${optionalString (def.linkConfig != { }) ''
[Link] [Link]
${attrsToSection def.linkConfig} ${attrsToSection def.linkConfig}
''
''} + ''
[Network] [Network]
${attrsToSection def.networkConfig} ''
+ attrsToSection def.networkConfig
+ optionalString (def.address != [ ]) ''
${concatStringsSep "\n" (map (s: "Address=${s}") def.address)} ${concatStringsSep "\n" (map (s: "Address=${s}") def.address)}
''
+ optionalString (def.gateway != [ ]) ''
${concatStringsSep "\n" (map (s: "Gateway=${s}") def.gateway)} ${concatStringsSep "\n" (map (s: "Gateway=${s}") def.gateway)}
''
+ optionalString (def.dns != [ ]) ''
${concatStringsSep "\n" (map (s: "DNS=${s}") def.dns)} ${concatStringsSep "\n" (map (s: "DNS=${s}") def.dns)}
''
+ optionalString (def.ntp != [ ]) ''
${concatStringsSep "\n" (map (s: "NTP=${s}") def.ntp)} ${concatStringsSep "\n" (map (s: "NTP=${s}") def.ntp)}
''
+ optionalString (def.bridge != [ ]) ''
${concatStringsSep "\n" (map (s: "Bridge=${s}") def.bridge)} ${concatStringsSep "\n" (map (s: "Bridge=${s}") def.bridge)}
''
+ optionalString (def.bond != [ ]) ''
${concatStringsSep "\n" (map (s: "Bond=${s}") def.bond)} ${concatStringsSep "\n" (map (s: "Bond=${s}") def.bond)}
''
+ optionalString (def.vrf != [ ]) ''
${concatStringsSep "\n" (map (s: "VRF=${s}") def.vrf)} ${concatStringsSep "\n" (map (s: "VRF=${s}") def.vrf)}
''
+ optionalString (def.vlan != [ ]) ''
${concatStringsSep "\n" (map (s: "VLAN=${s}") def.vlan)} ${concatStringsSep "\n" (map (s: "VLAN=${s}") def.vlan)}
''
+ optionalString (def.macvlan != [ ]) ''
${concatStringsSep "\n" (map (s: "MACVLAN=${s}") def.macvlan)} ${concatStringsSep "\n" (map (s: "MACVLAN=${s}") def.macvlan)}
''
+ optionalString (def.vxlan != [ ]) ''
${concatStringsSep "\n" (map (s: "VXLAN=${s}") def.vxlan)} ${concatStringsSep "\n" (map (s: "VXLAN=${s}") def.vxlan)}
''
+ optionalString (def.tunnel != [ ]) ''
${concatStringsSep "\n" (map (s: "Tunnel=${s}") def.tunnel)} ${concatStringsSep "\n" (map (s: "Tunnel=${s}") def.tunnel)}
''
+ optionalString (def.xfrm != [ ]) ''
${concatStringsSep "\n" (map (s: "Xfrm=${s}") def.xfrm)} ${concatStringsSep "\n" (map (s: "Xfrm=${s}") def.xfrm)}
''
+ ''
${flip concatMapStrings def.addresses (x: '' ''
+ flip concatMapStrings def.addresses (x: ''
[Address] [Address]
${attrsToSection x.addressConfig} ${attrsToSection x.addressConfig}
'')
'')} + flip concatMapStrings def.routingPolicyRules (x: ''
${flip concatMapStrings def.routingPolicyRules (x: ''
[RoutingPolicyRule] [RoutingPolicyRule]
${attrsToSection x.routingPolicyRuleConfig} ${attrsToSection x.routingPolicyRuleConfig}
'')
'')} + flip concatMapStrings def.routes (x: ''
${flip concatMapStrings def.routes (x: ''
[Route] [Route]
${attrsToSection x.routeConfig} ${attrsToSection x.routeConfig}
'')
'')} + optionalString (def.dhcpV4Config != { }) ''
${optionalString (def.dhcpV4Config != { }) ''
[DHCPv4] [DHCPv4]
${attrsToSection def.dhcpV4Config} ${attrsToSection def.dhcpV4Config}
''
''} + optionalString (def.dhcpV6Config != { }) ''
${optionalString (def.dhcpV6Config != {}) ''
[DHCPv6] [DHCPv6]
${attrsToSection def.dhcpV6Config} ${attrsToSection def.dhcpV6Config}
''
''} + optionalString (def.dhcpServerConfig != { }) ''
${optionalString (def.dhcpServerConfig != { }) ''
[DHCPServer] [DHCPServer]
${attrsToSection def.dhcpServerConfig} ${attrsToSection def.dhcpServerConfig}
''
''} + optionalString (def.ipv6PrefixDelegationConfig != { }) ''
${optionalString (def.ipv6PrefixDelegationConfig != {}) ''
[IPv6PrefixDelegation] [IPv6PrefixDelegation]
${attrsToSection def.ipv6PrefixDelegationConfig} ${attrsToSection def.ipv6PrefixDelegationConfig}
''
''} + flip concatMapStrings def.ipv6Prefixes (x: ''
${flip concatMapStrings def.ipv6Prefixes (x: ''
[IPv6Prefix] [IPv6Prefix]
${attrsToSection x.ipv6PrefixConfig} ${attrsToSection x.ipv6PrefixConfig}
'')
'')} + def.extraConfig;
${def.extraConfig}
'';
}; };
unitFiles = listToAttrs (map (name: { unitFiles = listToAttrs (map (name: {