How to use systemd-networkd-wait-online@.service on NixOS

What is the correct way to leverage systemd-networkd-wait-online@.service on NixOS? I am trying to write a module which needs to wait for a specific (virtual) network interface to be up, and it seems like this unit template is the “systemd way” to achieve that.

However, this template doesn’t seem to exist, in some fashion, on my NixOS system. I am struggling to figure out how to access its functionality from a NixOS module.

When systemd-networkd is enabled, systemd-networkd-wait-online.service is also enabled, but not “wanted by” anything by default. But that’s slightly different from systemd-networkd-wait-online@.service, which isn’t even enabled. The former waits on all managed interfaces to be configured, while the latter just waits for the one interface specified by the template. So you can either create a systemd unit dependency on systemd-networkd-wait-online.service to wait for all interfaces, or you can use systemd.additionalUpstreamSystemUnits = ["systemd-networkd-wait-online@.service"]; to enable the template unit and create the unit dependency on that instead.

or you can use systemd.additionalUpstreamSystemUnits => [“systemd-networkd-wait-online@.service”];

We should probably include this by default. There is no harm in doing it and it improves discoverability.


@ElvishJerricco @peterhoeg Thaaaaaanks guys! This is exactly what I was after. :pray: