Merge pull request #166142 from ncfavier/wait-online
nixos/networkd: add `wait-online` options
This commit is contained in:
commit
401cb86da1
|
@ -1401,6 +1401,35 @@
|
||||||
versions.
|
versions.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
A new option group
|
||||||
|
<literal>systemd.network.wait-online</literal> was added, with
|
||||||
|
options to configure
|
||||||
|
<literal>systemd-networkd-wait-online.service</literal>:
|
||||||
|
</para>
|
||||||
|
<itemizedlist spacing="compact">
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
<literal>anyInterface</literal> allows specifying that the
|
||||||
|
network should be considered online when <emphasis>at
|
||||||
|
least one</emphasis> interface is online (useful on
|
||||||
|
laptops)
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
<literal>timeout</literal> defines how long to wait for
|
||||||
|
the network to come online
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
<literal>extraArgs</literal> for everything else
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</itemizedlist>
|
||||||
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
The <literal>influxdb2</literal> package was split into
|
The <literal>influxdb2</literal> package was split into
|
||||||
|
|
|
@ -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.
|
still under heavy development and behavior is not always flawless.
|
||||||
Furthermore, not all Electron apps use the latest Electron versions.
|
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
|
- The `influxdb2` package was split into `influxdb2-server` and
|
||||||
`influxdb2-cli`, matching the split that took place upstream. A
|
`influxdb2-cli`, matching the split that took place upstream. A
|
||||||
combined `influxdb2` package is still provided in this release for
|
combined `influxdb2` package is still provided in this release for
|
||||||
|
|
|
@ -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 <literal>systemd-network-wait-online@</literal> services.
|
||||||
|
|
||||||
|
See <link xlink:href="https://www.freedesktop.org/software/systemd/man/systemd-networkd-wait-online.service.html">
|
||||||
|
<citerefentry><refentrytitle>systemd-networkd-wait-online.service</refentrytitle><manvolnum>8</manvolnum>
|
||||||
|
</citerefentry></link> for all available options.
|
||||||
|
'';
|
||||||
|
type = with types; listOf str;
|
||||||
|
default = [];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkMerge [
|
config = mkMerge [
|
||||||
|
@ -1749,6 +1791,11 @@ in
|
||||||
{
|
{
|
||||||
systemd.network.units = mapAttrs' (n: v: nameValuePair "${n}.link" (linkToUnit n v)) cfg.links;
|
systemd.network.units = mapAttrs' (n: v: nameValuePair "${n}.link" (linkToUnit n v)) cfg.links;
|
||||||
environment.etc = unitFiles;
|
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 {
|
(mkIf config.systemd.network.enable {
|
||||||
|
@ -1777,6 +1824,10 @@ in
|
||||||
|
|
||||||
systemd.services.systemd-networkd-wait-online = {
|
systemd.services.systemd-networkd-wait-online = {
|
||||||
wantedBy = [ "network-online.target" ];
|
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@" = {
|
systemd.services."systemd-network-wait-online@" = {
|
||||||
|
@ -1787,7 +1838,7 @@ in
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "oneshot";
|
Type = "oneshot";
|
||||||
RemainAfterExit = true;
|
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}";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue