Skip to content

Commit

Permalink
Merge pull request #65040 from matthewbauer/cups-fixes
Browse files Browse the repository at this point in the history
nixos/cups fixes
  • Loading branch information
matthewbauer authored Aug 14, 2019
2 parents dd49cf7 + e9b7085 commit 1af546a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 12 deletions.
9 changes: 9 additions & 0 deletions nixos/doc/manual/release-notes/rl-1909.xml
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,15 @@
If IBus support in Qt 4.x applications is required, add the <literal>ibus-qt</literal> package to your <xref linkend="opt-environment.systemPackages" /> manually.
</para>
</listitem>
<listitem>
<para>
The CUPS Printing service now uses socket-based activation by
default, only starting when needed. The previous behavior can
be restored by setting
<option>services.cups.startWhenNeeded</option> to
<literal>false</literal>.
</para>
</listitem>
</itemizedlist>
</section>

Expand Down
20 changes: 14 additions & 6 deletions nixos/modules/services/printing/cupsd.nix
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ in

startWhenNeeded = mkOption {
type = types.bool;
default = false;
default = true;
description = ''
If set, CUPS is socket-activated; that is,
instead of having it permanently running as a daemon,
Expand Down Expand Up @@ -296,11 +296,16 @@ in
# gets loaded, and then cups cannot access the printers.
boot.blacklistedKernelModules = [ "usblp" ];

# Some programs like print-manager rely on this value to get
# printer test pages.
environment.sessionVariables.CUPS_DATADIR = "${bindir}/share/cups";

systemd.packages = [ cups.out ];

systemd.sockets.cups = mkIf cfg.startWhenNeeded {
wantedBy = [ "sockets.target" ];
listenStreams = map (x: replaceStrings ["localhost"] ["127.0.0.1"] (removePrefix "*:" x)) cfg.listenAddresses;
listenStreams = [ "/run/cups/cups.sock" ]
++ map (x: replaceStrings ["localhost"] ["127.0.0.1"] (removePrefix "*:" x)) cfg.listenAddresses;
};

systemd.services.cups =
Expand Down Expand Up @@ -362,10 +367,10 @@ in
{ description = "CUPS Remote Printer Discovery";

wantedBy = [ "multi-user.target" ];
wants = [ "cups.service" "avahi-daemon.service" ];
bindsTo = [ "cups.service" "avahi-daemon.service" ];
partOf = [ "cups.service" "avahi-daemon.service" ];
after = [ "cups.service" "avahi-daemon.service" ];
wants = [ "avahi-daemon.service" ] ++ optional (!cfg.startWhenNeeded) "cups.service";
bindsTo = [ "avahi-daemon.service" ] ++ optional (!cfg.startWhenNeeded) "cups.service";
partOf = [ "avahi-daemon.service" ] ++ optional (!cfg.startWhenNeeded) "cups.service";
after = [ "avahi-daemon.service" ] ++ optional (!cfg.startWhenNeeded) "cups.service";

path = [ cups ];

Expand Down Expand Up @@ -421,4 +426,7 @@ in
security.pam.services.cups = {};

};

meta.maintainers = with lib.maintainers; [ matthewbauer ];

}
6 changes: 1 addition & 5 deletions nixos/tests/printing.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import ./make-test.nix ({pkgs, ... }: {
name = "printing";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ domenkozar eelco ];
maintainers = [ domenkozar eelco matthewbauer ];
};

nodes = {
Expand Down Expand Up @@ -34,10 +34,6 @@ import ./make-test.nix ({pkgs, ... }: {
''
startAll;
# Make sure that cups is up on both sides.
$server->waitForUnit("cups.service");
$client->waitForUnit("cups.service");
$client->sleep(10); # wait until cups is fully initialized
$client->succeed("lpstat -r") =~ /scheduler is running/ or die;
# check local encrypted connections work without error
$client->succeed("lpstat -E -r") =~ /scheduler is running/ or die;
Expand Down
2 changes: 1 addition & 1 deletion pkgs/misc/cups/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ stdenv.mkDerivation rec {
homepage = https://cups.org/;
description = "A standards-based printing system for UNIX";
license = licenses.gpl2; # actually LGPL for the library and GPL for the rest
maintainers = with maintainers; [ ];
maintainers = with maintainers; [ matthewbauer ];
platforms = platforms.unix;
};
}

0 comments on commit 1af546a

Please sign in to comment.