2021-10-28 15:13:40 +02:00
|
|
|
{ config, lib, ... }:
|
|
|
|
|
|
|
|
with lib;
|
2019-02-26 13:44:40 +01:00
|
|
|
|
2019-09-06 11:38:02 +02:00
|
|
|
{
|
2019-02-26 13:44:40 +01:00
|
|
|
networking = {
|
2019-03-17 11:43:14 +01:00
|
|
|
hostName = config.machine.hostName;
|
2021-10-28 15:13:40 +02:00
|
|
|
useNetworkd = config.machine.useNetworkd;
|
|
|
|
useDHCP = !config.machine.useNetworkd;
|
|
|
|
dhcpcd.enable = !config.machine.useNetworkd;
|
|
|
|
};
|
|
|
|
# Based on
|
|
|
|
# https://github.com/NixOS/nixpkgs/issues/10001#issuecomment-905532069
|
|
|
|
systemd.network = mkIf config.machine.useNetworkd {
|
|
|
|
enable = true;
|
|
|
|
networks = let
|
|
|
|
networkConfig = {
|
|
|
|
DHCP = "yes";
|
|
|
|
DNSSEC = "yes";
|
|
|
|
DNSOverTLS = "yes";
|
|
|
|
DNS = [ "1.1.1.1" "1.0.0.1" ];
|
|
|
|
};
|
|
|
|
in {
|
|
|
|
"40-wired" = {
|
|
|
|
enable = true;
|
|
|
|
name = "en*";
|
|
|
|
dhcpV4Config.RouteMetric = 2048;
|
|
|
|
inherit networkConfig;
|
|
|
|
};
|
|
|
|
"40-wireless" = {
|
|
|
|
enable = true;
|
|
|
|
name = "wl*";
|
|
|
|
dhcpV4Config.RouteMetric = 1024;
|
|
|
|
inherit networkConfig;
|
|
|
|
};
|
|
|
|
};
|
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
|
|
|
|
systemd.services."systemd-networkd-wait-online".serviceConfig.ExecStart = [
|
|
|
|
"" "${config.systemd.package}/lib/systemd/systemd-networkd-wait-online --any"
|
|
|
|
];
|
2019-02-26 13:44:40 +01:00
|
|
|
}
|