mirror of https://gitlab.crans.org/nounous/nixos
62 lines
1.2 KiB
Nix
62 lines
1.2 KiB
Nix
{
|
|
lib,
|
|
crans,
|
|
info,
|
|
...
|
|
}:
|
|
|
|
let
|
|
cfg-net = info.networking;
|
|
|
|
inherit (lib)
|
|
mkIf
|
|
mkDefault
|
|
mapAttrs'
|
|
filterAttrs
|
|
nameValuePair
|
|
;
|
|
in
|
|
{
|
|
# Options ../info/networking.nix
|
|
config = mkIf cfg-net.enable {
|
|
networking = {
|
|
hostName = info.name;
|
|
useDHCP = false;
|
|
firewall.enable = mkDefault false;
|
|
nameservers = [
|
|
# Romanesco via adm
|
|
"172.16.10.128"
|
|
"fd00::10:0:ff:fe01:2810"
|
|
];
|
|
|
|
interfaces = mapAttrs' (
|
|
vname: _:
|
|
let
|
|
conf = cfg-net.${vname};
|
|
in
|
|
nameValuePair conf.interface (
|
|
# On itère ipv4 / ipv6
|
|
builtins.mapAttrs
|
|
(
|
|
ipvx: _:
|
|
mkIf (conf.${ipvx} != null) {
|
|
addresses = [
|
|
{
|
|
address = conf.${ipvx}.address;
|
|
prefixLength = conf.${ipvx}.prefixLength;
|
|
}
|
|
];
|
|
|
|
routes = conf.${ipvx}.routes;
|
|
}
|
|
)
|
|
{
|
|
"ipv4" = null;
|
|
"ipv6" = null;
|
|
}
|
|
)
|
|
) (filterAttrs (n: _: cfg-net.${n}.enable) crans.vlans); # On filtre les interfaces désactivées.
|
|
};
|
|
};
|
|
}
|