blob: 6141f47e1d9bba41cd5b80dda955132d1ca1bb66 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
{ config, lib, mylib, ... }: {
# often hangs
systemd.network.wait-online.enable = lib.mkDefault false;
networking.useNetworkd = true;
networking.useDHCP = false;
# Do not take the network down for too long.
# From: https://github.com/numtide/srvos/commit/a99a47d
systemd.services.systemd-networkd.stopIfChanged = false;
systemd.services.systemd-resolved.stopIfChanged = false;
# The networks are called 40-NAME like the ones from
# <nixpkgs/nixos/modules/tasks/network-interfaces-systemd.nix>, so the
# settings merge into them: systemd uses only the first file that matches
# an interface, so with 00-NAME it would stay degraded (configured), and
# 99-NAME would be ignored.
systemd.network.networks = lib.mkMerge [
# Don't use DNS servers received from DHCP servers.
(mylib.genAttrs'
(builtins.attrNames config.networking.interfaces)
(name: lib.nameValuePair "40-${name}" {
dhcpV4Config.UseDNS = lib.mkDefault false;
dhcpV6Config.UseDNS = lib.mkDefault false;
}))
# Prefer ethernet: its DHCP routes get metric 512 instead of 1024.
(mylib.genAttrs'
(builtins.filter
(name:
config.hrm.network.interfaces.${name}.medium == "ethernet" &&
config.networking.interfaces ? ${name})
(builtins.attrNames config.hrm.network.interfaces))
(name: lib.nameValuePair "40-${name}" {
inherit name;
dhcpV4Config.RouteMetric = 512;
}))
];
}
|