Merge pull request #249643 from amarshall/networkd-reload

nixos/networkd: Reload (not restart) when only .network units change
This commit is contained in:
Janne Heß 2023-09-09 17:31:09 +02:00 committed by GitHub
commit 6b8306c21c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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" ];