Skip to content

Commit

Permalink
nixos/printing: add option to disable browsed daemon
Browse files Browse the repository at this point in the history
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 981a63b)
  • Loading branch information
LeSuisse authored and github-actions[bot] committed Sep 26, 2024
1 parent 8f7b5c9 commit 48db5e7
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions nixos/modules/services/printing/cupsd.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 = "";
Expand Down Expand Up @@ -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" ];
Expand Down

0 comments on commit 48db5e7

Please sign in to comment.