nixpkgs/pkgs/misc/drivers/gutenprint/default.nix
Michael Weiss ea23f8bb07 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.
2017-08-29 05:25:12 +04:00

53 lines
1.6 KiB
Nix

# this package was called gimp-print in the past
{ stdenv, lib, fetchurl, pkgconfig
, ijs, makeWrapper
, gimp2Support ? false, gimp
, cupsSupport ? true, cups, libusb, perl
}:
stdenv.mkDerivation rec {
name = "gutenprint-5.2.13";
src = fetchurl {
url = "mirror://sourceforge/gimp-print/${name}.tar.bz2";
sha256 = "0hi7s0y59306p4kp06sankfa57k2805khbknkvl9d036hdfp9afr";
};
nativeBuildInputs = [ makeWrapper pkgconfig ];
buildInputs =
[ ijs ]
++ lib.optionals gimp2Support [ gimp.gtk gimp ]
++ lib.optionals cupsSupport [ cups libusb perl ];
configureFlags = lib.optionals cupsSupport [
"--disable-static-genppd" # should be harmless on NixOS
];
# FIXME: hacky because we modify generated configure, but I haven't found a better way.
# makeFlags doesn't change this everywhere (e.g. in cups-genppdupdate).
preConfigure = lib.optionalString cupsSupport ''
sed -i \
-e "s,cups_conf_datadir=.*,cups_conf_datadir=\"$out/share/cups\",g" \
-e "s,cups_conf_serverbin=.*,cups_conf_serverbin=\"$out/lib/cups\",g" \
-e "s,cups_conf_serverroot=.*,cups_conf_serverroot=\"$out/etc/cups\",g" \
configure
'' + lib.optionalString gimp2Support ''
sed -i \
-e "s,gimp2_plug_indir=.*,gimp2_plug_indir=\"$out/lib/gimp/${gimp.majorVersion}\",g" \
configure
'';
enableParallelBuilding = true;
# Testing is very, very long.
# doCheck = true;
meta = with stdenv.lib; {
description = "Ghostscript and cups printer drivers";
homepage = https://sourceforge.net/projects/gimp-print/;
license = licenses.gpl2;
platforms = platforms.linux;
isGutenprint = true;
};
}