diff --git a/nixos/modules/rename.nix b/nixos/modules/rename.nix
index 800e12956f2..6b33eeb6e4e 100644
--- a/nixos/modules/rename.nix
+++ b/nixos/modules/rename.nix
@@ -1,4 +1,4 @@
-{ lib, ... }:
+{ lib, pkgs, ... }:
with lib;
@@ -14,6 +14,10 @@ with lib;
(mkRenamedOptionModule [ "networking" "enableRT73Firmware" ] [ "networking" "enableRalinkFirmware" ])
(mkRenamedOptionModule [ "services" "cadvisor" "host" ] [ "services" "cadvisor" "listenAddress" ])
+ (mkChangedOptionModule [ "services" "printing" "gutenprint" ] [ "services" "printing" "drivers" ]
+ (config:
+ let enabled = getAttrFromPath [ "services" "printing" "gutenprint" ] config;
+ in if enabled then [ pkgs.gutenprint ] else [ ]))
(mkRenamedOptionModule [ "services" "elasticsearch" "host" ] [ "services" "elasticsearch" "listenAddress" ])
(mkRenamedOptionModule [ "services" "graphite" "api" "host" ] [ "services" "graphite" "api" "listenAddress" ])
(mkRenamedOptionModule [ "services" "graphite" "web" "host" ] [ "services" "graphite" "web" "listenAddress" ])
diff --git a/nixos/modules/services/printing/cupsd.nix b/nixos/modules/services/printing/cupsd.nix
index 855c8930384..4c7f58d1d8b 100644
--- a/nixos/modules/services/printing/cupsd.nix
+++ b/nixos/modules/services/printing/cupsd.nix
@@ -4,7 +4,7 @@ with lib;
let
- inherit (pkgs) cups cups-pk-helper cups-filters gutenprint;
+ inherit (pkgs) cups cups-pk-helper cups-filters;
cfg = config.services.printing;
@@ -35,7 +35,6 @@ let
name = "cups-progs";
paths =
[ cups.out additionalBackends cups-filters pkgs.ghostscript ]
- ++ optional cfg.gutenprint gutenprint
++ cfg.drivers;
pathsToLink = [ "/lib" "/share/cups" "/bin" ];
postBuild = cfg.bindirCmds;
@@ -97,12 +96,15 @@ let
(writeConf "client.conf" cfg.clientConf)
(writeConf "snmp.conf" cfg.snmpConf)
] ++ optional avahiEnabled browsedFile
- ++ optional cfg.gutenprint gutenprint
++ cfg.drivers;
pathsToLink = [ "/etc/cups" ];
ignoreCollisions = true;
};
+ filterGutenprint = pkgs: filter (pkg: pkg.meta.isGutenprint or false == true) pkgs;
+ containsGutenprint = pkgs: length (filterGutenprint pkgs) > 0;
+ getGutenprint = pkgs: head (filterGutenprint pkgs);
+
in
{
@@ -224,23 +226,17 @@ in
'';
};
- gutenprint = mkOption {
- type = types.bool;
- default = false;
- description = ''
- Whether to enable Gutenprint drivers for CUPS. This includes auto-updating
- Gutenprint PPD files.
- '';
- };
-
drivers = mkOption {
type = types.listOf types.path;
default = [];
- example = literalExample "[ pkgs.splix ]";
+ example = literalExample "[ pkgs.gutenprint pkgs.hplip pkgs.splix ]";
description = ''
- CUPS drivers to use. Drivers provided by CUPS, cups-filters, Ghostscript
- and Samba are added unconditionally. For adding Gutenprint, see
- gutenprint.
+ CUPS drivers to use. Drivers provided by CUPS, cups-filters,
+ Ghostscript and Samba are added unconditionally. If this list contains
+ Gutenprint (i.e. a derivation with
+ meta.isGutenprint = true) the PPD files in
+ /var/lib/cups/ppd will be updated automatically
+ to avoid errors due to incompatible versions.
'';
};
@@ -318,9 +314,9 @@ in
[ ! -e /var/lib/cups/path ] && \
ln -s ${bindir} /var/lib/cups/path
- ${optionalString cfg.gutenprint ''
+ ${optionalString (containsGutenprint cfg.drivers) ''
if [ -d /var/lib/cups/ppd ]; then
- ${gutenprint}/bin/cups-genppdupdate -p /var/lib/cups/ppd
+ ${getGutenprint cfg.drivers}/bin/cups-genppdupdate -p /var/lib/cups/ppd
fi
''}
'';
diff --git a/pkgs/misc/drivers/gutenprint/default.nix b/pkgs/misc/drivers/gutenprint/default.nix
index 0bd40721c4e..7917d1e3616 100644
--- a/pkgs/misc/drivers/gutenprint/default.nix
+++ b/pkgs/misc/drivers/gutenprint/default.nix
@@ -47,5 +47,6 @@ stdenv.mkDerivation rec {
homepage = https://sourceforge.net/projects/gimp-print/;
license = licenses.gpl2;
platforms = platforms.linux;
+ isGutenprint = true;
};
}