From 69b630d89352730abb90be82d448af1cb5cac190 Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Sat, 28 Dec 2024 11:26:28 +0100 Subject: [PATCH 1/2] nixos/networkmanager: match upstream units Install sections The upstream NetworkManager.service unit[1] has this Install section: [Install] WantedBy=multi-user.target Also=NetworkManager-dispatcher.service Also=NetworkManager-wait-online.service Let's just match that in NixOS and don't try to mess with network.target. The latter should only be used to order units at shutdown, not when booting. [1]: https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/main/data/NetworkManager.service.in?ref_type=heads --- nixos/modules/services/networking/networkmanager.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/networking/networkmanager.nix b/nixos/modules/services/networking/networkmanager.nix index caa7b0fffffd1..d2d49ee2eeb91 100644 --- a/nixos/modules/services/networking/networkmanager.nix +++ b/nixos/modules/services/networking/networkmanager.nix @@ -598,7 +598,7 @@ in ]; systemd.services.NetworkManager = { - wantedBy = [ "network.target" ]; + wantedBy = [ "multi-user.target" ]; restartTriggers = [ configFile ]; aliases = [ "dbus-org.freedesktop.NetworkManager.service" ]; @@ -614,7 +614,7 @@ in }; systemd.services.NetworkManager-dispatcher = { - wantedBy = [ "network.target" ]; + wantedBy = [ "multi-user.target" ]; restartTriggers = [ configFile overrideNameserversScript From a00e8271102e33bb7993a727544c02a568f2441d Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Sat, 28 Dec 2024 11:47:29 +0100 Subject: [PATCH 2/2] nixos/tests/networkmanager: test NM is started at boot --- nixos/tests/networking/networkmanager.nix | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/nixos/tests/networking/networkmanager.nix b/nixos/tests/networking/networkmanager.nix index bd989408df8a1..23517a6cc47ec 100644 --- a/nixos/tests/networking/networkmanager.nix +++ b/nixos/tests/networking/networkmanager.nix @@ -33,6 +33,17 @@ let }; } extraConfig; testCases = { + startup = { + name = "startup"; + nodes.client = { + networking.useDHCP = false; + networking.networkmanager.enable = true; + }; + testScript = '' + with subtest("NetworkManager is started automatically at boot"): + client.wait_for_unit("NetworkManager.service") + ''; + }; static = { name = "static"; nodes = {