diff --git a/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml b/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml index 9535d441740..b4a33777851 100644 --- a/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml +++ b/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml @@ -1401,6 +1401,35 @@ versions. + + + A new option group + systemd.network.wait-online was added, with + options to configure + systemd-networkd-wait-online.service: + + + + + anyInterface allows specifying that the + network should be considered online when at + least one interface is online (useful on + laptops) + + + + + timeout defines how long to wait for + the network to come online + + + + + extraArgs for everything else + + + + The influxdb2 package was split into diff --git a/nixos/doc/manual/release-notes/rl-2205.section.md b/nixos/doc/manual/release-notes/rl-2205.section.md index 377dd1b5cae..560d80514d6 100644 --- a/nixos/doc/manual/release-notes/rl-2205.section.md +++ b/nixos/doc/manual/release-notes/rl-2205.section.md @@ -498,6 +498,11 @@ In addition to numerous new and upgraded packages, this release has the followin still under heavy development and behavior is not always flawless. Furthermore, not all Electron apps use the latest Electron versions. +- A new option group `systemd.network.wait-online` was added, with options to configure `systemd-networkd-wait-online.service`: + - `anyInterface` allows specifying that the network should be considered online when *at least one* interface is online (useful on laptops) + - `timeout` defines how long to wait for the network to come online + - `extraArgs` for everything else + - The `influxdb2` package was split into `influxdb2-server` and `influxdb2-cli`, matching the split that took place upstream. A combined `influxdb2` package is still provided in this release for diff --git a/nixos/modules/system/boot/networkd.nix b/nixos/modules/system/boot/networkd.nix index ac1e4ef34b4..092b7b8863a 100644 --- a/nixos/modules/system/boot/networkd.nix +++ b/nixos/modules/system/boot/networkd.nix @@ -1741,6 +1741,48 @@ in })); }; + systemd.network.wait-online = { + anyInterface = mkOption { + description = '' + 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. + ''; + type = types.bool; + default = false; + }; + + ignoredInterfaces = mkOption { + description = '' + Network interfaces to be ignored when deciding if the system is online. + ''; + type = with types; listOf str; + default = []; + example = [ "wg0" ]; + }; + + timeout = mkOption { + description = '' + Time to wait for the network to come online, in seconds. Set to 0 to disable. + ''; + type = types.ints.unsigned; + default = 120; + example = 0; + }; + + extraArgs = mkOption { + description = '' + Extra command-line arguments to pass to systemd-networkd-wait-online. + These also affect per-interface systemd-network-wait-online@ services. + + See + systemd-networkd-wait-online.service8 + for all available options. + ''; + type = with types; listOf str; + default = []; + }; + }; + }; config = mkMerge [ @@ -1749,6 +1791,11 @@ in { systemd.network.units = mapAttrs' (n: v: nameValuePair "${n}.link" (linkToUnit n v)) cfg.links; environment.etc = unitFiles; + + systemd.network.wait-online.extraArgs = + [ "--timeout=${toString cfg.wait-online.timeout}" ] + ++ optional cfg.wait-online.anyInterface "--any" + ++ map (i: "--ignore=${i}") cfg.wait-online.ignoredInterfaces; } (mkIf config.systemd.network.enable { @@ -1777,6 +1824,10 @@ in systemd.services.systemd-networkd-wait-online = { wantedBy = [ "network-online.target" ]; + serviceConfig.ExecStart = [ + "" + "${config.systemd.package}/lib/systemd/systemd-networkd-wait-online ${utils.escapeSystemdExecArgs cfg.wait-online.extraArgs}" + ]; }; systemd.services."systemd-network-wait-online@" = { @@ -1787,7 +1838,7 @@ in serviceConfig = { Type = "oneshot"; RemainAfterExit = true; - ExecStart = "${config.systemd.package}/lib/systemd/systemd-networkd-wait-online -i %I"; + ExecStart = "${config.systemd.package}/lib/systemd/systemd-networkd-wait-online -i %I ${utils.escapeSystemdExecArgs cfg.wait-online.extraArgs}"; }; };