forgejo-lts: 7.0.10 -> 7.0.11
[NixPkgs.git] / pkgs / misc / cups / filters.nix
blobd5688d3bc3514c4b778a76c931c8adcb5a415358
1 { lib
2 , avahi
3 , bc
4 , coreutils
5 , cups
6 , dbus
7 , dejavu_fonts
8 , fetchurl
9 , fetchpatch
10 , fontconfig
11 , gawk
12 , ghostscript
13 , gnugrep
14 , gnused
15 , ijs
16 , libexif
17 , libjpeg
18 , liblouis
19 , libpng
20 , makeWrapper
21 , autoreconfHook
22 , mupdf
23 , perl
24 , pkg-config
25 , poppler
26 , poppler_utils
27 , qpdf
28 , stdenv
29 , which
30 , withAvahi ? true
33 let
34   binPath = lib.makeBinPath [ bc coreutils gawk gnused gnugrep which ];
37 stdenv.mkDerivation rec {
38   pname = "cups-filters";
39   version = "1.28.17";
41   src = fetchurl {
42     url = "https://github.com/OpenPrinting/cups-filters/releases/download/${version}/${pname}-${version}.tar.xz";
43     hash = "sha256-Jwo3UqlgNoqpnUMftdNPQDmyrJQ8V22EBhLR2Bhcm7k=";
44   };
46   patches = [
47     (fetchpatch {
48       name = "CVE-2023-24805.patch";
49       url = "https://github.com/OpenPrinting/cups-filters/commit/93e60d3df358c0ae6f3dba79e1c9684657683d89.patch";
50       hash = "sha256-KgWTYFr2uShL040azzE+KaNyBPy7Gs/hCnEgQmmPCys=";
51     })
52     (fetchpatch {
53       name = "CVE-2024-47076.patch";
54       url = "https://github.com/OpenPrinting/libcupsfilters/commit/95576ec3d20c109332d14672a807353cdc551018.patch";
55       hash = "sha256-MXWllrdWt8n7zqvumQNg34dBgWMwMTwf9lrD+ZZP8Wk=";
56     })
57     (fetchpatch {
58       name = "remove-cups-ldap-browse-protocols_CVE-2024-47176_CVE-2024-47850.patch";
59       url = "https://github.com/OpenPrinting/cups-filters/commit/6fd2bdfbdce76149af531ce9fca9062304238451.patch";
60       hash = "sha256-XS1ODy7i7ilgEjsKuEvOUiRN9pqsj+bOktKoshKcg8Q=";
61     })
62   ];
64   nativeBuildInputs = [ pkg-config makeWrapper autoreconfHook ];
66   buildInputs = [
67     cups
68     dbus
69     fontconfig
70     ghostscript
71     ijs
72     libexif
73     libjpeg
74     liblouis # braille embosser support
75     libpng
76     mupdf
77     perl
78     poppler
79     poppler_utils
80     qpdf
81   ] ++ lib.optionals withAvahi [ avahi ];
83   configureFlags = [
84     "--with-mutool-path=${mupdf}/bin/mutool"
85     "--with-pdftops=pdftops"
86     "--with-pdftops-path=${poppler_utils}/bin/pdftops"
87     "--with-gs-path=${ghostscript}/bin/gs"
88     "--with-pdftocairo-path=${poppler_utils}/bin/pdftocairo"
89     "--with-ippfind-path=${cups}/bin/ippfind"
90     "--enable-imagefilters"
91     "--with-rcdir=no"
92     "--with-shell=${stdenv.shell}"
93     "--with-test-font-path=${dejavu_fonts}/share/fonts/truetype/DejaVuSans.ttf"
94     "--localstatedir=/var"
95     "--sysconfdir=/etc"
96   ] ++ lib.optionals (!withAvahi) [ "--disable-avahi" ];
98   makeFlags = [ "CUPS_SERVERBIN=$(out)/lib/cups" "CUPS_DATADIR=$(out)/share/cups" "CUPS_SERVERROOT=$(out)/etc/cups" ];
100   # https://github.com/OpenPrinting/cups-filters/issues/512
101   env.NIX_CFLAGS_COMPILE = "-std=c++17";
103   postConfigure =
104     ''
105       # Ensure that bannertopdf can find the PDF templates in
106       # $out. (By default, it assumes that cups and cups-filters are
107       # installed in the same prefix.)
108       substituteInPlace config.h --replace ${cups.out}/share/cups/data $out/share/cups/data
110       # Ensure that gstoraster can find gs in $PATH.
111       substituteInPlace filter/gstoraster.c --replace execve execvpe
113       # Patch shebangs of generated build scripts
114       patchShebangs filter
115     '';
117   postInstall =
118     ''
119       for i in $out/lib/cups/filter/*; do
120         wrapProgram "$i" --prefix PATH ':' ${binPath}
121       done
122     '';
124   enableParallelBuilding = true;
125   doCheck = true;
127   meta = {
128     homepage = "http://www.linuxfoundation.org/collaborate/workgroups/openprinting/cups-filters";
129     description = "Backends, filters, and other software that was once part of the core CUPS distribution but is no longer maintained by Apple Inc";
130     license = lib.licenses.gpl2Plus;
131     platforms = lib.platforms.linux;
132   };