run nixfmt
This commit is contained in:
@@ -50,20 +50,39 @@ let
|
||||
};
|
||||
|
||||
cfg = config.modules.vlans;
|
||||
vlans = lib.mapAttrsToList (attrName: { name ? attrName, ... }@vlan: ({ inherit name; } // vlan)) cfg.networks;
|
||||
vlanAttrs = lib.listToAttrs (lib.map ({ name, ... }@value: { inherit name value; }) vlans);
|
||||
vlans = lib.mapAttrsToList (
|
||||
attrName:
|
||||
{
|
||||
name ? attrName,
|
||||
...
|
||||
}@vlan:
|
||||
({ inherit name; } // vlan)
|
||||
) cfg.networks;
|
||||
vlanAttrs = lib.listToAttrs (
|
||||
lib.map (
|
||||
{ name, ... }@value:
|
||||
{
|
||||
inherit name value;
|
||||
}
|
||||
) vlans
|
||||
);
|
||||
|
||||
buildNetdev = name: { id, ... }: {
|
||||
name = "20-${name}";
|
||||
value = {
|
||||
netdevConfig = {
|
||||
Name = name;
|
||||
Kind = "vlan";
|
||||
MACAddress = "00:0d:b9:49:d2:${toString id}";
|
||||
buildNetdev =
|
||||
name:
|
||||
{ id, ... }:
|
||||
{
|
||||
name = "20-${name}";
|
||||
value = {
|
||||
netdevConfig = {
|
||||
Name = name;
|
||||
Kind = "vlan";
|
||||
MACAddress = "00:0d:b9:49:d2:${toString id}";
|
||||
};
|
||||
vlanConfig = {
|
||||
Id = id;
|
||||
};
|
||||
};
|
||||
vlanConfig = { Id = id; };
|
||||
};
|
||||
};
|
||||
|
||||
buildStaticLease = macAddress: address: ''
|
||||
[DHCPServerStaticLease]
|
||||
@@ -71,27 +90,35 @@ let
|
||||
Address=${address}
|
||||
'';
|
||||
|
||||
buildNetwork = name: { id, ipv6, staticLeases, ... }: {
|
||||
name = "30-${name}";
|
||||
value = {
|
||||
matchConfig = {
|
||||
Name = name;
|
||||
buildNetwork =
|
||||
name:
|
||||
{
|
||||
id,
|
||||
ipv6,
|
||||
staticLeases,
|
||||
...
|
||||
}:
|
||||
{
|
||||
name = "30-${name}";
|
||||
value = {
|
||||
matchConfig = {
|
||||
Name = name;
|
||||
};
|
||||
networkConfig = {
|
||||
Address = "10.${toString id}.0.1/23";
|
||||
IPMasquerade = "ipv4";
|
||||
DHCPServer = true;
|
||||
IPv6AcceptRA = false;
|
||||
IPv6SendRA = ipv6;
|
||||
DHCPPrefixDelegation = ipv6;
|
||||
};
|
||||
dhcpServerConfig = {
|
||||
PoolOffset = 255;
|
||||
DNS = "10.${toString id}.0.1";
|
||||
};
|
||||
extraConfig = lib.concatLines (lib.mapAttrsToList buildStaticLease staticLeases);
|
||||
};
|
||||
networkConfig = {
|
||||
Address = "10.${toString id}.0.1/23";
|
||||
IPMasquerade = "ipv4";
|
||||
DHCPServer = true;
|
||||
IPv6AcceptRA = false;
|
||||
IPv6SendRA = ipv6;
|
||||
DHCPPrefixDelegation = ipv6;
|
||||
};
|
||||
dhcpServerConfig = {
|
||||
PoolOffset = 255;
|
||||
DNS = "10.${toString id}.0.1";
|
||||
};
|
||||
extraConfig = lib.concatLines (lib.mapAttrsToList buildStaticLease staticLeases);
|
||||
};
|
||||
};
|
||||
|
||||
vlanIds = lib.mapAttrsToList (_: { id, ... }: id) vlanAttrs;
|
||||
|
||||
@@ -108,25 +135,39 @@ let
|
||||
'';
|
||||
|
||||
bridgeNetDev =
|
||||
if (cfg.bridge.enable) then {
|
||||
"${cfg.bridge.netdev}".bridgeConfig = {
|
||||
VLANFiltering = true;
|
||||
DefaultPVID = cfg.bridge.pvid;
|
||||
};
|
||||
} else { };
|
||||
if (cfg.bridge.enable) then
|
||||
{
|
||||
"${cfg.bridge.netdev}".bridgeConfig = {
|
||||
VLANFiltering = true;
|
||||
DefaultPVID = cfg.bridge.pvid;
|
||||
};
|
||||
}
|
||||
else
|
||||
{ };
|
||||
|
||||
bridgeBindNetwork =
|
||||
if (cfg.bridge.enable) then {
|
||||
${cfg.bridge.bindNetwork}.extraConfig = bridgeVLANConfig;
|
||||
} else { };
|
||||
if (cfg.bridge.enable) then
|
||||
{
|
||||
${cfg.bridge.bindNetwork}.extraConfig = bridgeVLANConfig;
|
||||
}
|
||||
else
|
||||
{ };
|
||||
|
||||
bridgeNetwork =
|
||||
if (cfg.bridge.enable) then {
|
||||
"${cfg.bridge.network}" = {
|
||||
vlan = lib.map ({ name, ... }: name) vlans;
|
||||
bridgeVLANs = lib.map ({ id, ... }: { VLAN = id; }) vlans;
|
||||
};
|
||||
} else { };
|
||||
if (cfg.bridge.enable) then
|
||||
{
|
||||
"${cfg.bridge.network}" = {
|
||||
vlan = lib.map ({ name, ... }: name) vlans;
|
||||
bridgeVLANs = lib.map (
|
||||
{ id, ... }:
|
||||
{
|
||||
VLAN = id;
|
||||
}
|
||||
) vlans;
|
||||
};
|
||||
}
|
||||
else
|
||||
{ };
|
||||
|
||||
netdevs = lib.mergeAttrsList [
|
||||
(lib.mapAttrs' buildNetdev vlanAttrs)
|
||||
|
||||
Reference in New Issue
Block a user