1{
2 lib,
3 bc,
4 coreutils,
5 cups,
6 dbus,
7 dejavu_fonts,
8 fetchFromGitHub,
9 fontconfig,
10 gawk,
11 ghostscript,
12 gnugrep,
13 gnused,
14 ijs,
15 libcupsfilters,
16 libppd,
17 libexif,
18 libjpeg,
19 liblouis,
20 libpng,
21 makeWrapper,
22 autoreconfHook,
23 mupdf,
24 perl,
25 pkg-config,
26 poppler,
27 poppler-utils,
28 qpdf,
29 stdenv,
30 which,
31 withAvahi ? true,
32 glib,
33}:
34
35(
36 if !withAvahi then
37 lib.warn "the 'withAvahi' parameter to 'cups-filters' is deprecated, as the cups-browsed component (which does not make sense without avahi) has been split out of the cups-filters package (which no longer needs avahi)"
38 else
39 lib.id
40)
41
42 (
43 let
44 binPath = lib.makeBinPath [
45 bc
46 coreutils
47 gawk
48 gnused
49 gnugrep
50 which
51 ];
52
53 in
54 stdenv.mkDerivation rec {
55 pname = "cups-filters";
56 version = "2.0.1";
57
58 src = fetchFromGitHub {
59 owner = "OpenPrinting";
60 repo = "cups-filters";
61 rev = version;
62 hash = "sha256-bLOl64bdeZ10JLcQ7GbU+VffJu3Lzo0ves7O7GQIOWY=";
63 };
64
65 strictDeps = true;
66
67 nativeBuildInputs = [
68 autoreconfHook
69 cups
70 glib
71 makeWrapper
72 pkg-config
73 ];
74
75 buildInputs = [
76 cups
77 ghostscript
78 libcupsfilters
79 libppd
80 mupdf
81 ];
82
83 configureFlags = [
84 "--with-mutool-path=${mupdf}/bin/mutool"
85 "--with-gs-path=${ghostscript}/bin/gs"
86 "--with-ippfind-path=${cups}/bin/ippfind"
87 "--with-shell=${stdenv.shell}"
88 "--localstatedir=/var"
89 "--sysconfdir=/etc"
90 ];
91
92 makeFlags = [
93 "CUPS_SERVERBIN=$(out)/lib/cups"
94 "CUPS_DATADIR=$(out)/share/cups"
95 "CUPS_SERVERROOT=$(out)/etc/cups"
96 ];
97
98 # https://github.com/OpenPrinting/cups-filters/issues/512
99 env.NIX_CFLAGS_COMPILE = "-std=c++17";
100
101 postConfigure = ''
102 # Ensure that bannertopdf can find the PDF templates in
103 # $out. (By default, it assumes that cups and cups-filters are
104 # installed in the same prefix.)
105 substituteInPlace config.h --replace ${cups.out}/share/cups/data $out/share/cups/data
106
107 # Ensure that gstoraster can find gs in $PATH.
108 substituteInPlace filter/gstoraster.c --replace execve execvpe
109
110 # Patch shebangs of generated build scripts
111 patchShebangs filter
112 '';
113
114 postInstall = ''
115 for i in $out/lib/cups/filter/*; do
116 wrapProgram "$i" --prefix PATH ':' ${binPath}
117 done
118 '';
119
120 enableParallelBuilding = true;
121 doCheck = true;
122
123 meta = {
124 homepage = "http://www.linuxfoundation.org/collaborate/workgroups/openprinting/cups-filters";
125 description = "Backends, filters, and other software that was once part of the core CUPS distribution but is no longer maintained by Apple Inc";
126 license = lib.licenses.gpl2Plus;
127 platforms = lib.platforms.linux;
128 };
129 }
130 )