From 04ea093eb6057f7d87751a293dd1ec35591098dd Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Thu, 18 Jul 2019 17:15:19 -0400 Subject: [PATCH 1/7] nixos/cupsd: Set CUPS_DATADIR globally This is used by some programs that need CUPS data files. For instance, print-manager looks here for printing test pages. --- nixos/modules/services/printing/cupsd.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nixos/modules/services/printing/cupsd.nix b/nixos/modules/services/printing/cupsd.nix index 86b0c8d69be..26f684af3dd 100644 --- a/nixos/modules/services/printing/cupsd.nix +++ b/nixos/modules/services/printing/cupsd.nix @@ -296,6 +296,10 @@ 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 { From 35e633bde520e692b91b45bbff0608ee1f1574ad Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Thu, 18 Jul 2019 17:32:41 -0400 Subject: [PATCH 2/7] nixos/cupsd: only enable cups when startWhenNeeded = false cups-browsed was pulling in cups.service even when we were using the socket-based initialization. --- nixos/modules/services/printing/cupsd.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nixos/modules/services/printing/cupsd.nix b/nixos/modules/services/printing/cupsd.nix index 26f684af3dd..35fad46af01 100644 --- a/nixos/modules/services/printing/cupsd.nix +++ b/nixos/modules/services/printing/cupsd.nix @@ -366,10 +366,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 ]; From 28040465be4d15bedd2ee9397973e670e2e5ec2c Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Thu, 18 Jul 2019 17:35:13 -0400 Subject: [PATCH 3/7] nixos/cupsd: include /run/cups/cups.sock in ListenStreams This socket should always be created by systemd. --- nixos/modules/services/printing/cupsd.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nixos/modules/services/printing/cupsd.nix b/nixos/modules/services/printing/cupsd.nix index 35fad46af01..0f75a96be3c 100644 --- a/nixos/modules/services/printing/cupsd.nix +++ b/nixos/modules/services/printing/cupsd.nix @@ -304,7 +304,8 @@ in 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 = From c0684888175476c74a9e3a6897c73e67a3bd95d9 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Fri, 9 Aug 2019 13:59:47 -0400 Subject: [PATCH 4/7] nixos/cupsd: use socket-based activation by default Make socket-based activation the default (services.printing.startWhenNeeded) --- nixos/modules/services/printing/cupsd.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/services/printing/cupsd.nix b/nixos/modules/services/printing/cupsd.nix index 0f75a96be3c..48409b5c91d 100644 --- a/nixos/modules/services/printing/cupsd.nix +++ b/nixos/modules/services/printing/cupsd.nix @@ -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, From 011b12c3cab3d9801836f5ac6d0fa249294973f2 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Thu, 18 Jul 2019 17:50:22 -0400 Subject: [PATCH 5/7] nixos: Add release notes for CUPS changes --- nixos/doc/manual/release-notes/rl-1909.xml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/nixos/doc/manual/release-notes/rl-1909.xml b/nixos/doc/manual/release-notes/rl-1909.xml index d4d87716be3..e0f71aadaba 100644 --- a/nixos/doc/manual/release-notes/rl-1909.xml +++ b/nixos/doc/manual/release-notes/rl-1909.xml @@ -254,6 +254,15 @@ If IBus support in Qt 4.x applications is required, add the ibus-qt package to your manually. + + + The CUPS Printing service now uses socket-based activation by + default, only starting when needed. The previous behavior can + be restored by setting + to + false. + + From 01cd4663d67b061e9ad580e0e2c689d093b8ae10 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Wed, 14 Aug 2019 11:43:46 -0400 Subject: [PATCH 6/7] =?UTF-8?q?tests/printing:=20don=E2=80=99t=20wait=20fo?= =?UTF-8?q?r=20unit=20services?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These are now socket activated, we don’t need it to start up front. --- nixos/tests/printing.nix | 4 ---- 1 file changed, 4 deletions(-) diff --git a/nixos/tests/printing.nix b/nixos/tests/printing.nix index e8702c1ffbf..72ee641948f 100644 --- a/nixos/tests/printing.nix +++ b/nixos/tests/printing.nix @@ -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; From e9b7085ff8dc5980ea3e60c7282e9a2260f4b8a2 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Wed, 14 Aug 2019 11:44:30 -0400 Subject: [PATCH 7/7] cups: add myself as maintainer --- nixos/modules/services/printing/cupsd.nix | 3 +++ nixos/tests/printing.nix | 2 +- pkgs/misc/cups/default.nix | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/printing/cupsd.nix b/nixos/modules/services/printing/cupsd.nix index 48409b5c91d..42c1b9482cb 100644 --- a/nixos/modules/services/printing/cupsd.nix +++ b/nixos/modules/services/printing/cupsd.nix @@ -426,4 +426,7 @@ in security.pam.services.cups = {}; }; + + meta.maintainers = with lib.maintainers; [ matthewbauer ]; + } diff --git a/nixos/tests/printing.nix b/nixos/tests/printing.nix index 72ee641948f..74583ae5562 100644 --- a/nixos/tests/printing.nix +++ b/nixos/tests/printing.nix @@ -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 = { diff --git a/pkgs/misc/cups/default.nix b/pkgs/misc/cups/default.nix index 11873e6f2a0..789aabce043 100644 --- a/pkgs/misc/cups/default.nix +++ b/pkgs/misc/cups/default.nix @@ -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; }; }