From 48db5e72f2c9efd0025f7d16057814bd41866a7e Mon Sep 17 00:00:00 2001 From: Thomas Gerbet Date: Thu, 26 Sep 2024 19:49:52 +0200 Subject: [PATCH] nixos/printing: add option to disable browsed daemon It is currently tied to `services.avahi.enable` which might not be desirable. With this change it is possible to disable the service with `services.printing.browsed.enable = false` (cherry picked from commit 981a63b005475121efadf9a6bcead017b101bee4) --- nixos/modules/services/printing/cupsd.nix | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/nixos/modules/services/printing/cupsd.nix b/nixos/modules/services/printing/cupsd.nix index 668bccab2e2d..2e128f49c86b 100644 --- a/nixos/modules/services/printing/cupsd.nix +++ b/nixos/modules/services/printing/cupsd.nix @@ -9,7 +9,6 @@ let cfg = config.services.printing; cups = cfg.package; - avahiEnabled = config.services.avahi.enable; polkitEnabled = config.security.polkit.enable; additionalBackends = pkgs.runCommand "additional-cups-backends" { @@ -99,7 +98,7 @@ let cupsdFile (writeConf "client.conf" cfg.clientConf) (writeConf "snmp.conf" cfg.snmpConf) - ] ++ optional avahiEnabled browsedFile + ] ++ optional cfg.browsed.enable browsedFile ++ cfg.drivers; pathsToLink = [ "/etc/cups" ]; ignoreCollisions = true; @@ -270,6 +269,15 @@ in ''; }; + browsed.enable = mkOption { + type = types.bool; + default = config.services.avahi.enable; + defaultText = literalExpression "config.services.avahi.enable"; + description = '' + Whether to enable the CUPS Remote Printer Discovery (browsed) daemon. + ''; + }; + browsedConf = mkOption { type = types.lines; default = ""; @@ -419,7 +427,7 @@ in serviceConfig.PrivateTmp = true; }; - systemd.services.cups-browsed = mkIf avahiEnabled + systemd.services.cups-browsed = mkIf cfg.browsed.enable { description = "CUPS Remote Printer Discovery"; wantedBy = [ "multi-user.target" ];