2023-09-11 20:23:04 +02:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
with lib; let
|
2023-09-11 21:20:14 +02:00
|
|
|
inherit (config.machine) networkD;
|
2023-09-11 20:23:04 +02:00
|
|
|
in {
|
2019-02-26 13:44:40 +01:00
|
|
|
networking = {
|
2023-09-11 21:20:14 +02:00
|
|
|
inherit (config.machine) hostName;
|
2023-08-26 08:02:47 +02:00
|
|
|
useNetworkd = networkD.enable;
|
|
|
|
useDHCP = !networkD.enable;
|
|
|
|
dhcpcd.enable = !networkD.enable;
|
2021-10-28 15:13:40 +02:00
|
|
|
};
|
|
|
|
# Based on
|
|
|
|
# https://github.com/NixOS/nixpkgs/issues/10001#issuecomment-905532069
|
2023-08-26 08:02:47 +02:00
|
|
|
systemd.network = mkIf networkD.enable {
|
2021-10-28 15:13:40 +02:00
|
|
|
enable = true;
|
|
|
|
networks = let
|
|
|
|
networkConfig = {
|
|
|
|
DHCP = "yes";
|
|
|
|
DNSSEC = "yes";
|
|
|
|
DNSOverTLS = "yes";
|
2023-09-11 20:23:04 +02:00
|
|
|
DNS = ["1.1.1.1" "1.0.0.1"];
|
2021-10-28 15:13:40 +02:00
|
|
|
};
|
|
|
|
in {
|
|
|
|
"40-wired" = {
|
|
|
|
enable = true;
|
|
|
|
name = "en*";
|
|
|
|
dhcpV4Config.RouteMetric = 2048;
|
|
|
|
inherit networkConfig;
|
|
|
|
};
|
|
|
|
"40-wireless" = {
|
|
|
|
enable = true;
|
|
|
|
name = "wl*";
|
|
|
|
dhcpV4Config.RouteMetric = 1024;
|
|
|
|
inherit networkConfig;
|
|
|
|
};
|
2023-08-26 08:02:47 +02:00
|
|
|
"50-vlan" = {
|
|
|
|
enable = true;
|
|
|
|
matchConfig = {
|
|
|
|
Name = "br0";
|
|
|
|
};
|
|
|
|
networkConfig = {
|
|
|
|
DNS = "10.0.0.1";
|
|
|
|
Address = "10.0.0.100/16";
|
|
|
|
# DHCPServer = true;
|
|
|
|
# IPMasquerade = true;
|
|
|
|
};
|
|
|
|
# dhcpServerConfig = {
|
|
|
|
# ServerAddress = "172.16.9.1/12";
|
|
|
|
# PoolOffset = 100;
|
|
|
|
# EmitDNS = false;
|
|
|
|
# };
|
|
|
|
};
|
2021-10-28 15:13:40 +02:00
|
|
|
};
|
2019-02-26 13:44:40 +01:00
|
|
|
};
|
2021-10-28 15:13:40 +02:00
|
|
|
# Wait for any interface to become available, not for all
|
2023-08-26 08:02:47 +02:00
|
|
|
systemd.services."systemd-networkd-wait-online" = {
|
|
|
|
enable = mkForce networkD.waitOnline;
|
|
|
|
serviceConfig.ExecStart = [
|
2023-09-11 20:23:04 +02:00
|
|
|
""
|
|
|
|
"${config.systemd.package}/lib/systemd/systemd-networkd-wait-online --any"
|
2023-08-26 08:02:47 +02:00
|
|
|
];
|
|
|
|
};
|
2019-02-26 13:44:40 +01:00
|
|
|
}
|