shared-public-infra/modules/network.nix
raito 107cc6e53f infra: steal from the best
(Mic92's cluster TUM's infra.)
2023-06-05 19:25:23 +02:00

50 lines
1.2 KiB
Nix

{ config
, lib
, ...
}: {
# use networkd
networking.dhcpcd.enable = false;
systemd.network.enable = true;
# add an entry to /etc/hosts for each host
networking.extraHosts = lib.concatStringsSep "\n" (lib.mapAttrsToList
(name: host: ''
${lib.optionalString (host.ipv4 != null) "${host.ipv4} ${name}"}
${lib.optionalString (host.ipv6 != null) "${host.ipv6} ${name}"}
'')
config.networking.newtype.hosts);
# leave container interfaces alone
systemd.network.networks."05-veth".extraConfig = ''
[Match]
Driver = veth
[Link]
Unmanaged = yes
'';
systemd.network.networks."10-nat-lan" = {
matchConfig.Name = "nat-lan";
linkConfig.RequiredForOnline = true;
DHCP = "yes";
};
systemd.network.links."10-nat-lan" = {
matchConfig.MACAddress = "3c:ec:ef:7e:bd:c8";
linkConfig.Name = "nat-lan";
};
systemd.network.networks."10-wan" = {
matchConfig.Name = "wan";
linkConfig.RequiredForOnline = true;
networkConfig.Address = [ config.networking.newtype.currentHost.ipv6 ];
};
systemd.network.links."10-wan" = {
matchConfig.MACAddress = "3c:ec:ef:7e:bd:c9";
linkConfig.Name = "wan";
};
deployment.targetHost = "${config.networking.hostName}.infra.newtype.fr";
}