about summary refs log tree commit diff
path: root/nixos/modules
diff options
context:
space:
mode:
authorArian van Putten <arian.vanputten@gmail.com>2020-05-19 11:04:14 +0200
committerFlorian Klink <flokli@flokli.de>2020-06-13 12:23:45 +0200
commitcd1dedac67d4b077a556a660ef5724c909da8006 (patch)
tree162708398c41ba6cbe4e9bad0c75cff5703146cb /nixos/modules
parent0e18e5db994f416580e8c6fbe3351a721ee5ec35 (diff)
downloadnixlib-cd1dedac67d4b077a556a660ef5724c909da8006.tar
nixlib-cd1dedac67d4b077a556a660ef5724c909da8006.tar.gz
nixlib-cd1dedac67d4b077a556a660ef5724c909da8006.tar.bz2
nixlib-cd1dedac67d4b077a556a660ef5724c909da8006.tar.lz
nixlib-cd1dedac67d4b077a556a660ef5724c909da8006.tar.xz
nixlib-cd1dedac67d4b077a556a660ef5724c909da8006.tar.zst
nixlib-cd1dedac67d4b077a556a660ef5724c909da8006.zip
nixos/networkd: Make activatible through dbus and netlink
With this systemd buffers netlink messages in early boot from the kernel
itself; and passes them on to networkd for processing once it's started.
Makes sure no routing messages are missed.

Also makes an alias so that dbus can activate this unit. Upstream has
this too.
Diffstat (limited to 'nixos/modules')
-rw-r--r--nixos/modules/system/boot/networkd.nix10
1 files changed, 9 insertions, 1 deletions
diff --git a/nixos/modules/system/boot/networkd.nix b/nixos/modules/system/boot/networkd.nix
index 9b34b12e73a5..b0545363b330 100644
--- a/nixos/modules/system/boot/networkd.nix
+++ b/nixos/modules/system/boot/networkd.nix
@@ -1178,14 +1178,22 @@ in
       users.users.systemd-network.group = "systemd-network";
 
       systemd.additionalUpstreamSystemUnits = [
-        "systemd-networkd.service" "systemd-networkd-wait-online.service"
+        "systemd-networkd-wait-online.service"
+        "systemd-networkd.service"
+        "systemd-networkd.socket"
       ];
 
       systemd.network.units = mapAttrs' (n: v: nameValuePair "${n}.netdev" (netdevToUnit n v)) cfg.netdevs
         // mapAttrs' (n: v: nameValuePair "${n}.network" (networkToUnit n v)) cfg.networks;
 
+      # systemd-networkd is socket-activated by kernel netlink route change
+      # messages. It is important to have systemd buffer those on behalf of
+      # networkd.
+      systemd.sockets.systemd-networkd.wantedBy = [ "sockets.target" ];
+
       systemd.services.systemd-networkd = {
         wantedBy = [ "multi-user.target" ];
+        aliases = [ "dbus-org.freedesktop.network1.service" ];
         restartTriggers = map (x: x.source) (attrValues unitFiles);
         # prevent race condition with interface renaming (#39069)
         requires = [ "systemd-udev-settle.service" ];