@@ -127,7 +127,7 @@ in
127127
128128 startWhenNeeded = mkOption {
129129 type = types.bool;
130− default = false;
130+ default = true;
131131 description = ''
132132 If set, CUPS is socket-activated; that is,
133133 instead of having it permanently running as a daemon,
@@ -296,11 +296,16 @@ in
296296 # gets loaded, and then cups cannot access the printers.
297297 boot.blacklistedKernelModules = [ "usblp" ];
298298
299+ # Some programs like print-manager rely on this value to get
300+ # printer test pages.
301+ environment.sessionVariables.CUPS_DATADIR = "${bindir}/share/cups";
302+
299303 systemd.packages = [ cups.out ];
300304
301305 systemd.sockets.cups = mkIf cfg.startWhenNeeded {
302306 wantedBy = [ "sockets.target" ];
303− listenStreams = map (x: replaceStrings ["localhost"] ["127.0.0.1"] (removePrefix "*:" x)) cfg.listenAddresses;
307+ listenStreams = [ "/run/cups/cups.sock" ]
308+ ++ map (x: replaceStrings ["localhost"] ["127.0.0.1"] (removePrefix "*:" x)) cfg.listenAddresses;
304309 };
305310
306311 systemd.services.cups =
@@ -362,10 +367,10 @@ in
362367 { description = "CUPS Remote Printer Discovery";
363368
364369 wantedBy = [ "multi-user.target" ];
365− wants = [ "cups.service" "avahi-daemon.service" ];
366− bindsTo = [ "cups.service" "avahi-daemon.service" ];
367− partOf = [ "cups.service" "avahi-daemon.service" ];
368− after = [ "cups.service" "avahi-daemon.service" ];
370+ wants = [ "avahi-daemon.service" ] ++ optional (!cfg.startWhenNeeded) "cups.service";
371+ bindsTo = [ "avahi-daemon.service" ] ++ optional (!cfg.startWhenNeeded) "cups.service";
372+ partOf = [ "avahi-daemon.service" ] ++ optional (!cfg.startWhenNeeded) "cups.service";
373+ after = [ "avahi-daemon.service" ] ++ optional (!cfg.startWhenNeeded) "cups.service";
369374
370375 path = [ cups ];
371376
@@ -421,4 +426,7 @@ in
421426 security.pam.services.cups = {};
422427
423428 };
429+
430+ meta.maintainers = with lib.maintainers; [ matthewbauer ];
431+
424432}