diff --git a/nixos/modules/system/boot/networkd.nix b/nixos/modules/system/boot/networkd.nix index 463e2b8d90b0..d88f88f9fdaf 100644 --- a/nixos/modules/system/boot/networkd.nix +++ b/nixos/modules/system/boot/networkd.nix @@ -3188,7 +3188,19 @@ let systemd.contents."/etc/systemd/networkd.conf" = renderConfig cfg.config; - systemd.services.systemd-networkd.wantedBy = [ "initrd.target" ]; + systemd.services.systemd-networkd = { + wantedBy = [ "initrd.target" ]; + # These before and conflicts lines can be removed when this PR makes it into a release: + # https://github.com/systemd/systemd/pull/27791 + before = ["initrd-switch-root.target"]; + conflicts = ["initrd-switch-root.target"]; + }; + systemd.sockets.systemd-networkd = { + wantedBy = [ "initrd.target" ]; + before = ["initrd-switch-root.target"]; + conflicts = ["initrd-switch-root.target"]; + }; + systemd.services.systemd-network-generator.wantedBy = [ "sysinit.target" ]; systemd.storePaths = [