summary refs log tree commit diff
path: root/nixos/modules/rename.nix
diff options
context:
space:
mode:
authorMichael Weiss <dev.primeos@gmail.com>2017-08-20 13:20:45 +0200
committerNikolay Amiantov <ab@fmap.me>2017-08-29 05:25:12 +0400
commitea23f8bb079ef11c2d11859994d804c4e4940be5 (patch)
treeeeddbd21ce9a0e4966550a532f606bc4894a2dbd /nixos/modules/rename.nix
parentecea06ab2e771808817dd7e0d2287b3ad0709de2 (diff)
downloadnixlib-ea23f8bb079ef11c2d11859994d804c4e4940be5.tar
nixlib-ea23f8bb079ef11c2d11859994d804c4e4940be5.tar.gz
nixlib-ea23f8bb079ef11c2d11859994d804c4e4940be5.tar.bz2
nixlib-ea23f8bb079ef11c2d11859994d804c4e4940be5.tar.lz
nixlib-ea23f8bb079ef11c2d11859994d804c4e4940be5.tar.xz
nixlib-ea23f8bb079ef11c2d11859994d804c4e4940be5.tar.zst
nixlib-ea23f8bb079ef11c2d11859994d804c4e4940be5.zip
cups service: Automatically detect Gutenprint in drivers
Additional CUPS drivers can be added via "services.printing.drivers" but
Gutenprint was an exception. It was possible to add a Gutenprint
derivation to that list and it would work at first but unlike the other
drivers Gutenprint requires a script to be run after each update or any
attempt to print something would simply fail and an error would show up
in the jobs queue (http://localhost:631/jobs/):
"The PPD version (5.2.11) is not compatible with Gutenprint 5.2.13.
Please run
`/nix/store/7762kpyhfkcgmr3q81v1bbyy0bjhym80-gutenprint-5.2.13/sbin/cups-genppdupdate'
as administrator."
This is due to state in "/var/lib/cups/ppd" and one would need to run
"/nix/store/.../bin/cups-genppdupdate -p /var/lib/cups/ppd" manually.
The alternative was to enable the following option:
"services.printing.gutenprint" but this had two disadvantages:
1) It is an exception that one could be unaware of or that could
potentially cause some confusion.
2) One couldn't use a customized Gutenprint derivation in
"services.printing.drivers" but would instead have to overwrite
"pkgs.gutenprint".

This new approach simply detects a Gutenprint derivation in
"services.printing.gutenprint" by checking if the meta set of a
derivation contains "isGutenprint = true". Therefore no special
exception for Gutenprint would be required and it could easily be
applied to other drivers if they would require such a script to be run.
Diffstat (limited to 'nixos/modules/rename.nix')
-rw-r--r--nixos/modules/rename.nix6
1 files changed, 5 insertions, 1 deletions
diff --git a/nixos/modules/rename.nix b/nixos/modules/rename.nix
index 800e12956f24..6b33eeb6e4e7 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" ])