forked from zentralwerk/network
nixos-module/container/upstream: style
This commit is contained in:
parent
9615317bf6
commit
8bdeedea9a
|
@ -4,12 +4,15 @@ let
|
|||
upstreamInterfaces =
|
||||
lib.filterAttrs (_: { upstream, ... }: upstream != null)
|
||||
config.site.hosts.${hostName}.interfaces;
|
||||
|
||||
firstUpstreamInterface =
|
||||
if builtins.length (builtins.attrNames upstreamInterfaces) > 0
|
||||
then builtins.head (
|
||||
builtins.attrNames upstreamInterfaces
|
||||
)
|
||||
else null;
|
||||
|
||||
enabled = (firstUpstreamInterface != null);
|
||||
in
|
||||
{
|
||||
systemd.network.networks = {
|
||||
|
@ -32,6 +35,7 @@ in
|
|||
networkConfig.IPv6AcceptRA = true;
|
||||
dhcpV6Config.PrefixDelegationHint = "::/56";
|
||||
|
||||
# Traffic Shaping
|
||||
extraConfig = ''
|
||||
[CAKE]
|
||||
Parent = root
|
||||
|
@ -41,7 +45,7 @@ in
|
|||
'';
|
||||
}) upstreamInterfaces;
|
||||
|
||||
networking.nat = lib.optionalAttrs (firstUpstreamInterface != null) {
|
||||
networking.nat = lib.optionalAttrs enabled {
|
||||
enable = true;
|
||||
internalInterfaces = [ "core" ];
|
||||
externalInterface = firstUpstreamInterface;
|
||||
|
|
Loading…
Reference in New Issue
Block a user