about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorJanne Heß <dasJ@users.noreply.github.com>2023-09-09 17:31:09 +0200
committerGitHub <noreply@github.com>2023-09-09 17:31:09 +0200
commit6b8306c21cffff17327bad9759fe5ac1eb200773 (patch)
tree93e10ec4d3e17c3e53079ff0814db242225243ca /nixos
parent1b75ac310a4fba9e8245a23760bd796f103eb851 (diff)
parent189b14246a1992ff2454f75ae3478141fed2488b (diff)
Merge pull request #249643 from amarshall/networkd-reload
nixos/networkd: Reload (not restart) when only .network units change
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/system/boot/networkd.nix11
1 files changed, 9 insertions, 2 deletions
diff --git a/nixos/modules/system/boot/networkd.nix b/nixos/modules/system/boot/networkd.nix
index 6d0afcc57fcc6..756632a45f90a 100644
--- a/nixos/modules/system/boot/networkd.nix
+++ b/nixos/modules/system/boot/networkd.nix
@@ -2812,9 +2812,16 @@ let
 
       environment.etc."systemd/networkd.conf" = renderConfig cfg.config;
 
-      systemd.services.systemd-networkd = {
+      systemd.services.systemd-networkd = let
+        isReloadableUnitFileName = unitFileName: strings.hasSuffix ".network" unitFileName;
+        partitionedUnitFiles = lib.partition isReloadableUnitFileName unitFiles;
+        reloadableUnitFiles = partitionedUnitFiles.right;
+        nonReloadableUnitFiles = partitionedUnitFiles.wrong;
+        unitFileSources = unitFiles: map (x: x.source) (attrValues unitFiles);
+      in {
         wantedBy = [ "multi-user.target" ];
-        restartTriggers = map (x: x.source) (attrValues unitFiles) ++ [
+        reloadTriggers = unitFileSources reloadableUnitFiles;
+        restartTriggers = unitFileSources nonReloadableUnitFiles ++ [
           config.environment.etc."systemd/networkd.conf".source
         ];
         aliases = [ "dbus-org.freedesktop.network1.service" ];