0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-13 21:50:33 +03:00

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

@ -1328,160 +1328,162 @@ let
}; };
}; };
commonMatchText = def: optionalString (def.matchConfig != {}) '' commonMatchText = def: optionalString (def.matchConfig != { }) ''
[Match] [Match]
${attrsToSection def.matchConfig} ${attrsToSection def.matchConfig}
''; '';
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 != { }) ''
''} [VXLAN]
${optionalString (def.vxlanConfig != { }) '' ${attrsToSection def.vxlanConfig}
[VXLAN] ''
${attrsToSection def.vxlanConfig} + optionalString (def.tunnelConfig != { }) ''
[Tunnel]
''} ${attrsToSection def.tunnelConfig}
${optionalString (def.tunnelConfig != { }) '' ''
[Tunnel] + optionalString (def.peerConfig != { }) ''
${attrsToSection def.tunnelConfig} [Peer]
${attrsToSection def.peerConfig}
''} ''
${optionalString (def.peerConfig != { }) '' + optionalString (def.tunConfig != { }) ''
[Peer] [Tun]
${attrsToSection def.peerConfig} ${attrsToSection def.tunConfig}
''
''} + optionalString (def.tapConfig != { }) ''
${optionalString (def.tunConfig != { }) '' [Tap]
[Tun] ${attrsToSection def.tapConfig}
${attrsToSection def.tunConfig} ''
+ optionalString (def.wireguardConfig != { }) ''
''} [WireGuard]
${optionalString (def.tapConfig != { }) '' ${attrsToSection def.wireguardConfig}
[Tap] ''
${attrsToSection def.tapConfig} + flip concatMapStrings def.wireguardPeers (x: ''
[WireGuardPeer]
''} ${attrsToSection x.wireguardPeerConfig}
${optionalString (def.wireguardConfig != { }) '' '')
[WireGuard] + optionalString (def.bondConfig != { }) ''
${attrsToSection def.wireguardConfig} [Bond]
${attrsToSection def.bondConfig}
''} ''
${flip concatMapStrings def.wireguardPeers (x: '' + optionalString (def.xfrmConfig != { }) ''
[WireGuardPeer] [Xfrm]
${attrsToSection x.wireguardPeerConfig} ${attrsToSection def.xfrmConfig}
''
'')} + optionalString (def.vrfConfig != { }) ''
${optionalString (def.bondConfig != { }) '' [VRF]
[Bond] ${attrsToSection def.vrfConfig}
${attrsToSection def.bondConfig} ''
+ def.extraConfig;
''}
${optionalString (def.xfrmConfig != { }) ''
[Xfrm]
${attrsToSection def.xfrmConfig}
''}
${optionalString (def.vrfConfig != { }) ''
[VRF]
${attrsToSection def.vrfConfig}
''}
${def.extraConfig}
'';
}; };
networkToUnit = name: def: networkToUnit = name: def:
{ inherit (def) enable; { inherit (def) enable;
text = commonMatchText def + text = commonMatchText def
+ optionalString (def.linkConfig != { }) ''
[Link]
${attrsToSection def.linkConfig}
'' ''
${optionalString (def.linkConfig != { }) '' + ''
[Link]
${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: '' ''
[Address] + flip concatMapStrings def.addresses (x: ''
${attrsToSection x.addressConfig} [Address]
${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 != { }) ''
'')} [DHCPv4]
${optionalString (def.dhcpV4Config != { }) '' ${attrsToSection def.dhcpV4Config}
[DHCPv4] ''
${attrsToSection def.dhcpV4Config} + optionalString (def.dhcpV6Config != { }) ''
[DHCPv6]
''} ${attrsToSection def.dhcpV6Config}
${optionalString (def.dhcpV6Config != {}) '' ''
[DHCPv6] + optionalString (def.dhcpServerConfig != { }) ''
${attrsToSection def.dhcpV6Config} [DHCPServer]
${attrsToSection def.dhcpServerConfig}
''} ''
${optionalString (def.dhcpServerConfig != { }) '' + optionalString (def.ipv6PrefixDelegationConfig != { }) ''
[DHCPServer] [IPv6PrefixDelegation]
${attrsToSection def.dhcpServerConfig} ${attrsToSection def.ipv6PrefixDelegationConfig}
''
''} + flip concatMapStrings def.ipv6Prefixes (x: ''
${optionalString (def.ipv6PrefixDelegationConfig != {}) '' [IPv6Prefix]
[IPv6PrefixDelegation] ${attrsToSection x.ipv6PrefixConfig}
${attrsToSection def.ipv6PrefixDelegationConfig} '')
+ def.extraConfig;
''}
${flip concatMapStrings def.ipv6Prefixes (x: ''
[IPv6Prefix]
${attrsToSection x.ipv6PrefixConfig}
'')}
${def.extraConfig}
'';
}; };
unitFiles = listToAttrs (map (name: { unitFiles = listToAttrs (map (name: {