From af614b53d1e1662c2ecf8f207a1a36bf3d4b0a91 Mon Sep 17 00:00:00 2001 From: Marco Rebhan Date: Sun, 25 Jun 2023 14:45:08 +0200 Subject: [PATCH] nixos/avahi: Add package option Allows replacing the avahi package (e.g. for debugging) without having to use an overlay, avoiding unnecessary package rebuilds. --- .../services/networking/avahi-daemon.nix | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/nixos/modules/services/networking/avahi-daemon.nix b/nixos/modules/services/networking/avahi-daemon.nix index 3a7519c7230b..bdbf9aad9acc 100644 --- a/nixos/modules/services/networking/avahi-daemon.nix +++ b/nixos/modules/services/networking/avahi-daemon.nix @@ -56,6 +56,15 @@ in ''; }; + package = mkOption { + type = types.package; + default = pkgs.avahi; + defaultText = literalExpression "pkgs.avahi"; + description = lib.mdDoc '' + The avahi package to use for running the daemon. + ''; + }; + hostName = mkOption { type = types.str; default = config.networking.hostName; @@ -260,7 +269,7 @@ in (mkAfter [ "mdns" ]) # after dns ]); - environment.systemPackages = [ pkgs.avahi ]; + environment.systemPackages = [ cfg.package ]; environment.etc = (mapAttrs' (n: v: nameValuePair @@ -286,19 +295,19 @@ in # return a sensible value. environment.LD_LIBRARY_PATH = config.system.nssModules.path; - path = [ pkgs.coreutils pkgs.avahi ]; + path = [ pkgs.coreutils cfg.package ]; serviceConfig = { NotifyAccess = "main"; BusName = "org.freedesktop.Avahi"; Type = "dbus"; - ExecStart = "${pkgs.avahi}/sbin/avahi-daemon --syslog -f ${avahiDaemonConf}"; + ExecStart = "${cfg.package}/sbin/avahi-daemon --syslog -f ${avahiDaemonConf}"; ConfigurationDirectory = "avahi/services"; }; }; services.dbus.enable = true; - services.dbus.packages = [ pkgs.avahi ]; + services.dbus.packages = [ cfg.package ]; networking.firewall.allowedUDPPorts = mkIf cfg.openFirewall [ 5353 ]; };