Why is systemd-networkd-wait-online.service
masked on Nixos? I have created a service that should wait for the network to be available. I noticed that after reboot, this service start before the network is completely online. What is the correct way in Nix to force a service to wait until the network (maybe even specific interfaces) to be online?
systemd.services."ampero-config" = rec {
serviceConfig = {
Type = "oneshot";
DynamicUser = "yes";
};
after = [ "network-online.target" ];
wants = [ "network-online.target" ];
...
$ systemctl status systemd-networkd-wait-online.service
○ systemd-networkd-wait-online.service
Loaded: masked (Reason: Unit systemd-networkd-wait-online.service is masked.)
Active: inactive (dead)
If yes, do you also have systemd.network.wait-online.enable
set in your config (the default is true)?
yes
systemd.network.enable = true;
There are no settings in my config for systemd.network.wait-online.enable
so it should default to true
. But I found out that when I set it to true
in my config I get this error:
error: The option `systemd.network.wait-online.enable' has conflicting definition values:
- In `/nix/store/rjsk8c698ar6acycydk6vbanangpd87k-source/nixos/common/networking.nix': false
- In `/nix/store/q4j2qpm4zl7ifp93ihfd6qs6zd40i6xb-source/hosts/common/global/network.nix': true
The contents of /nix/store/rjsk8c698ar6acycydk6vbanangpd87k-source/nixos/common/networking.nix
is:
{ lib, ... }:
{
# Allow PMTU / DHCP
networking.firewall.allowPing = true;
# Keep dmesg/journalctl -k output readable by NOT logging
# each refused connection on the open internet.
networking.firewall.logRefusedConnections = lib.mkDefault false;
# Use networkd instead of the pile of shell scripts
networking.useNetworkd = lib.mkDefault true;
# The notion of "online" is a broken concept
# https://github.com/systemd/systemd/blob/e1b45a756f71deac8c1aa9a008bd0dab47f64777/NEWS#L13
systemd.services.NetworkManager-wait-online.enable = false;
systemd.network.wait-online.enable = false;
# FIXME: Maybe upstream?
# Do not take down the network for too long when upgrading,
# This also prevents failures of services that are restarted instead of stopped.
# It will use `systemctl restart` rather than stopping it with `systemctl stop`
# followed by a delayed `systemctl start`.
systemd.services.systemd-networkd.stopIfChanged = false;
# Services that are only restarted might be not able to resolve when resolved is stopped before
systemd.services.systemd-resolved.stopIfChanged = false;
}
Looks like srvos/nixos/common/networking.nix at c877dc6f7920b373e5943f77377e6ef816f4dc30 · nix-community/srvos · GitHub is causing this behaviour.