From aea3b8598c3e619bc8b6e7a9bea0f03e967ec199 Mon Sep 17 00:00:00 2001 From: Christoph Urlacher Date: Thu, 30 May 2024 10:52:38 +0200 Subject: [PATCH] Fix network wait-online by setting routable correctly --- lib/networking.nix | 7 ++++--- system/default.nix | 2 +- system/modules/systemd-networkd/default.nix | 13 ++++++++++++- system/nixinator/default.nix | 1 + 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/lib/networking.nix b/lib/networking.nix index 49ed1e56..f09f49c6 100644 --- a/lib/networking.nix +++ b/lib/networking.nix @@ -5,7 +5,7 @@ lib, ... }: rec { - mkSystemdNetwork = interface: { + mkSystemdNetwork = interface: routable: { # name = "enp0s31f6"; # Network interface name? enable = true; @@ -30,7 +30,7 @@ linkConfig = { # This corresponds to the [LINK] section # RequiredForOnline = "routable"; - RequiredForOnline = "no"; # Don't make nixos-rebuild wait for systemd-networkd-wait-online.service + RequiredForOnline = if routable then "routable" else "no"; # Don't make nixos-rebuild wait for systemd-networkd-wait-online.service }; }; @@ -39,6 +39,7 @@ ip, router, nameserver, + routable, }: { # name = "enp0s31f6"; # Network interface name? enable = true; @@ -75,7 +76,7 @@ linkConfig = { # This corresponds to the [LINK] section # RequiredForOnline = "routable"; - RequiredForOnline = "no"; # Don't make nixos-rebuild wait for systemd-networkd-wait-online.service + RequiredForOnline = if routable then "routable" else "no"; # Don't make nixos-rebuild wait for systemd-networkd-wait-online.service }; }; diff --git a/system/default.nix b/system/default.nix index 4aa7765b..d2c70314 100644 --- a/system/default.nix +++ b/system/default.nix @@ -30,7 +30,7 @@ with mylib.networking; { networks = { # Default wildcard ethernet network for all hosts - "50-ether" = mkSystemdNetwork "enp*"; + "50-ether" = mkSystemdNetwork "enp*" false; }; allowedTCPPorts = [ diff --git a/system/modules/systemd-networkd/default.nix b/system/modules/systemd-networkd/default.nix index fb6a9f79..83061148 100644 --- a/system/modules/systemd-networkd/default.nix +++ b/system/modules/systemd-networkd/default.nix @@ -23,7 +23,18 @@ in { # Main Networks systemd.network = { enable = true; - wait-online.anyInterface = true; # Don't wait for all networks to be configured, as e.g. wg0 will only be upon manual activation + wait-online.timeout = 10; + + # Don't wait for all networks to be configured, as e.g. wg0 will only be upon manual activation + wait-online.anyInterface = true; + + # TODO: Apparently anyInterface doesn't work? + # wait-online.ignoredInterfaces = [ + # "wg0" + # "wlp7s0" + # "enp5s0" + # ]; + networks = cfg.networks; }; diff --git a/system/nixinator/default.nix b/system/nixinator/default.nix index 93a001aa..c8b56f46 100644 --- a/system/nixinator/default.nix +++ b/system/nixinator/default.nix @@ -36,6 +36,7 @@ ip = ["192.168.86.50/24"]; router = ["192.168.86.5"]; nameserver = ["192.168.86.26"]; + routable = true; }; # "10-ether-1G" = mylib.networking.mkStaticSystemdNetwork {...}; };