diff --git a/nixos/modules/services/networking/avahi-daemon.nix b/nixos/modules/services/networking/avahi-daemon.nix index 3ba61a6598ad..ab54eafb6877 100644 --- a/nixos/modules/services/networking/avahi-daemon.nix +++ b/nixos/modules/services/networking/avahi-daemon.nix @@ -323,6 +323,11 @@ in description = "Avahi mDNS/DNS-SD Stack Activation Socket"; listenStreams = [ "/run/avahi-daemon/socket" ]; wantedBy = [ "sockets.target" ]; + after = [ + # Ensure that `/run/avahi-daemon` owned by `avahi` is created by `systemd.tmpfiles.rules` before the `avahi-daemon.socket`, + # otherwise `avahi-daemon.socket` will automatically create it owned by `root`, which will cause `avahi-daemon.service` to fail. + "systemd-tmpfiles-setup.service" + ]; }; systemd.tmpfiles.rules = [ "d /run/avahi-daemon - avahi avahi -" ];