nixos/virtualbox: fix systemd-networkd-wait-online.service waiting for vboxnet0
While switching NixOS configurations with both
networking.useNetworkd = true;
virtualisation.virtualbox.host.enable;
You often end up waiting for systemd-networkd-wait-online.service.
This happens because the vboxnet0 device doesn't have a carrier until
virtualbox machines are started, so networkd gets stuck in
"Configuring":
⇒ networkctl list
IDX LINK TYPE OPERATIONAL SETUP
1 lo loopback carrier unmanaged
2 wlp2s0 wlan routable unmanaged
3 vboxnet0 ether no-carrier configuring
This updates the NixOS virtualbox host module to include a
RequiredForOnline=no statement in the generated 40-vboxnet0.network
file, so networkd doesn't consider it necessary for
systemd-networkd-wait-online.service to finish.
commit32fd88726b7e43fbe65f93966bdd54f3d2ed10f5
authorFlorian Klink <flokli@flokli.de>
dateSat 26 Oct 2019, 00:45 (7 years ago)
parentc3098d1
nixos/modules/virtualisation/virtualbox-host.nix+8−1
@@ -149,5 +149,12 @@ in
149149 # Make sure NetworkManager won't assume this interface being up
150150 # means we have internet access.
151151 networking.networkmanager.unmanaged = ["vboxnet0"];
152− })]);
152+ }) (mkIf config.networking.useNetworkd {
153+ systemd.network.networks."40-vboxnet0".extraConfig = ''
154+ [Link]
155+ RequiredForOnline=no
156+ '';
157+ })
158+
159+]);
153160}