lib/config/options: add duplicate vlan check

master
Astro 1 year ago
parent 76086449dd
commit 2808bebffc

@ -600,5 +600,25 @@ in
in map (addr: {
assertion = builtins.length addrHosts.${addr} == 1;
message = "Address ${addr} is assigned to more than one host: ${lib.concatStringsSep " " addrHosts.${addr}}";
}) (builtins.attrNames addrHosts));
}) (builtins.attrNames addrHosts))
++
# duplicate vlan check
(let
vlanNets =
builtins.foldl' (result: net:
let
vlan = toString config.site.net.${net}.vlan;
in
if result ? ${vlan}
then result // {
"${vlan}" = result.${vlan} ++ [ net ];
}
else result // {
"${vlan}" = [ net ];
}
) {} (builtins.attrNames config.site.net);
in map (vlan: {
assertion = builtins.length vlanNets.${vlan} == 1;
message = "VLAN ${vlan} is used by more than one network: ${lib.concatStringsSep " " vlanNets.${vlan}}";
}) (builtins.attrNames vlanNets));
}

Loading…
Cancel
Save