From 28ab2b278d782367c43092a31f8360c0454f3edc Mon Sep 17 00:00:00 2001 From: Jade Lovelace Date: Sun, 1 Oct 2023 15:24:11 -0700 Subject: [PATCH] nixos/networkd: make wait-online not time out A further bug to our strange multi-user.target depending on network-online.target issue is that systemd recently changed the behaviour of systemd-networkd-wait-online to no longer consider the absence of interfaces with RequiredForOnline to be sufficient to be online: https://github.com/systemd/systemd/pull/27825 On the advice of the systemd developers (https://github.com/systemd/systemd/issues/29388), this commit changes the configuration of systemd-networkd-wait-online to pass --any by default, and lets the default DHCP interfaces be RequiredForOnline as they would be by default if the option is omitted. It is plausible that systemd-networkd-wait-online may still fail if there are no interfaces at all. However, that probably cannot be avoided. --- nixos/doc/manual/release-notes/rl-2311.section.md | 3 +++ nixos/modules/system/boot/networkd.nix | 5 ++++- nixos/modules/tasks/network-interfaces-systemd.nix | 9 --------- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/nixos/doc/manual/release-notes/rl-2311.section.md b/nixos/doc/manual/release-notes/rl-2311.section.md index 37b840539ea..5ec6cb89067 100644 --- a/nixos/doc/manual/release-notes/rl-2311.section.md +++ b/nixos/doc/manual/release-notes/rl-2311.section.md @@ -91,6 +91,9 @@ ## Backward Incompatibilities {#sec-release-23.11-incompatibilities} +- `network-online.target` has been fixed to no longer time out for systems with `networking.useDHCP = true` and `networking.useNetworkd = true`. + Workarounds for this can be removed. + - The `boot.loader.raspberryPi` options have been marked deprecated, with intent for removal for NixOS 24.11. They had a limited use-case, and do not work like people expect. They required either very old installs ([before mid-2019](https://github.com/NixOS/nixpkgs/pull/62462)) or customized builds out of scope of the standard and generic AArch64 support. That option set never supported the Raspberry Pi 4 family of devices. - `python3.pkgs.sequoia` was removed in favor of `python3.pkgs.pysequoia`. The latter package is based on upstream's dedicated repository for sequoia's Python bindings, where the Python bindings from [gitlab:sequoia-pgp/sequoia](https://gitlab.com/sequoia-pgp/sequoia) were removed long ago. diff --git a/nixos/modules/system/boot/networkd.nix b/nixos/modules/system/boot/networkd.nix index ef8204e2cf5..82f8714f0d7 100644 --- a/nixos/modules/system/boot/networkd.nix +++ b/nixos/modules/system/boot/networkd.nix @@ -2724,9 +2724,12 @@ let description = lib.mdDoc '' Whether to consider the network online when any interface is online, as opposed to all of them. This is useful on portable machines with a wired and a wireless interface, for example. + + This is on by default if {option}`networking.useDHCP` is enabled. ''; type = types.bool; - default = false; + defaultText = "config.networking.useDHCP"; + default = config.networking.useDHCP; }; ignoredInterfaces = mkOption { diff --git a/nixos/modules/tasks/network-interfaces-systemd.nix b/nixos/modules/tasks/network-interfaces-systemd.nix index 679567cbb73..86eed4214f8 100644 --- a/nixos/modules/tasks/network-interfaces-systemd.nix +++ b/nixos/modules/tasks/network-interfaces-systemd.nix @@ -59,23 +59,14 @@ let # more likely to result in interfaces being configured to # use DHCP when they shouldn't. - # When wait-online.anyInterface is enabled, RequiredForOnline really - # means "sufficient for online", so we can enable it. - # Otherwise, don't block the network coming online because of default networks. matchConfig.Name = ["en*" "eth*"]; DHCP = "yes"; - linkConfig.RequiredForOnline = - lib.mkDefault (if initrd - then config.boot.initrd.systemd.network.wait-online.anyInterface - else config.systemd.network.wait-online.anyInterface); networkConfig.IPv6PrivacyExtensions = "kernel"; }; networks."99-wireless-client-dhcp" = { # Like above, but this is much more likely to be correct. matchConfig.WLANInterfaceType = "station"; DHCP = "yes"; - linkConfig.RequiredForOnline = - lib.mkDefault config.systemd.network.wait-online.anyInterface; networkConfig.IPv6PrivacyExtensions = "kernel"; # We also set the route metric to one more than the default # of 1024, so that Ethernet is preferred if both are