projects/guix·blob javascript-team · refs

1113 lines · 49.1 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2015, 2019, 2021 Ricardo Wurmus <[email protected]>
3;;; Copyright © 2015, 2016, 2017, 2019, 2021, 2023 Ludovic Courtès <[email protected]>
4;;; Copyright © 2015-2018, 2023 Efraim Flashner <[email protected]>
5;;; Copyright © 2016 Danny Milosavljevic <[email protected]>
6;;; Copyright © 2017 Leo Famulari <[email protected]>
7;;; Copyright © 2017 Mark H Weaver <[email protected]>
8;;; Copyright © 2017–2022 Tobias Geerinckx-Rice <[email protected]>
9;;; Copyright © 2020 Marius Bakke <[email protected]>
10;;; Copyright © 2021, 2023, 2024 Maxim Cournoyer <[email protected]>
11;;; Copyright © 2023 Zheng Junjie <[email protected]>
12;;; Copyright © 2025 Lukas Gradl <[email protected]>
13;;; Copyright © 2025 Antoine Côté <[email protected]>
14;;; Copyright © 2024 Janneke Nieuwenhuizen <[email protected]>
15;;; Copyright © 2025 John Kehayias <[email protected]>
16;;;
17;;; This file is part of GNU Guix.
18;;;
19;;; GNU Guix is free software; you can redistribute it and/or modify it
20;;; under the terms of the GNU General Public License as published by
21;;; the Free Software Foundation; either version 3 of the License, or (at
22;;; your option) any later version.
23;;;
24;;; GNU Guix is distributed in the hope that it will be useful, but
25;;; WITHOUT ANY WARRANTY; without even the implied warranty of
26;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27;;; GNU General Public License for more details.
28;;;
29;;; You should have received a copy of the GNU General Public License
30;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
31
32(define-module (gnu packages cups)
33 #:use-module (gnu packages)
34 #:use-module (gnu packages algebra)
35 #:use-module (gnu packages autotools)
36 #:use-module (gnu packages base)
37 #:use-module (gnu packages bash)
38 #:use-module (gnu packages compression)
39 #:use-module (gnu packages crypto)
40 #:use-module (gnu packages dns)
41 #:use-module (gnu packages fonts) ; font-dejavu
42 #:use-module (gnu packages fontutils)
43 #:use-module (gnu packages ghostscript)
44 #:use-module (gnu packages glib)
45 #:use-module (gnu packages groff)
46 #:use-module (gnu packages image)
47 #:use-module (gnu packages libusb)
48 #:use-module (gnu packages linux)
49 #:use-module (gnu packages networking)
50 #:use-module (gnu packages pdf)
51 #:use-module (gnu packages perl)
52 #:use-module (gnu packages photo)
53 #:use-module (gnu packages pkg-config)
54 #:use-module (gnu packages polkit)
55 #:use-module (gnu packages pretty-print)
56 #:use-module (gnu packages python)
57 #:use-module (gnu packages python-build)
58 #:use-module (gnu packages python-xyz)
59 #:use-module (gnu packages qt)
60 #:use-module (gnu packages scanner)
61 #:use-module (gnu packages tls)
62 #:use-module (guix build-system cmake)
63 #:use-module (guix build-system gnu)
64 #:use-module (guix build-system meson)
65 #:use-module (guix build-system pyproject)
66 #:use-module (guix download)
67 #:use-module (guix git-download)
68 #:use-module (guix gexp)
69 #:use-module ((guix licenses) #:prefix license:)
70 #:use-module (guix packages)
71 #:use-module (guix utils)
72 #:use-module (srfi srfi-1)
73 #:use-module (ice-9 match))
74
75(define-public brlaser
76 (package
77 (name "brlaser")
78 (version "6.2.7")
79 (source
80 (origin
81 (method git-fetch)
82 (uri (git-reference
83 (url "https://github.com/Owl-Maintain/brlaser")
84 (commit (string-append "v" version))))
85 (file-name (git-file-name name version))
86 (sha256
87 (base32 "0giibsva4f2sfn6cchqfnv74d047n5dmp97yxqdks1zad0pf7r3b"))))
88 (build-system cmake-build-system)
89 (arguments
90 (list
91 #:configure-flags
92 #~(list (string-append "-DCUPS_DATA_DIR="
93 #$output "/share/cups")
94 (string-append "-DCUPS_SERVER_BIN="
95 #$output "/lib/cups"))))
96 (inputs (list ghostscript cups zlib))
97 (home-page "https://github.com/Owl-Maintain/brlaser")
98 (synopsis "Brother laser printer driver")
99 (description "Brlaser is a CUPS driver for Brother laser printers. This
100driver is known to work with these printers:
101
102@enumerate
103@item Brother DCP-1510 series
104@item Brother DCP-1600 series
105@item Brother DCP-1610W series
106@item Brother DCP-7010
107@item Brother DCP-7020
108@item Brother DCP-7030
109@item Brother DCP-7040
110@item Brother DCP-7055
111@item Brother DCP-7055W
112@item Brother DCP-7060D
113@item Brother DCP-7065DN
114@item Brother DCP-7070DW
115@item Brother DCP-7080
116@item Brother DCP-7080D
117@item Brother DCP-8065DN
118@item Brother DCP-B7500D series
119@item Brother DCP-L2500D series
120@item Brother DCP-L2510D series
121@item Brother DCP-L2520D series
122@item Brother DCP-L2520DW series
123@item Brother DCP-L2537DW
124@item Brother DCP-L2540DW series
125@item Brother DCP-L2550DW series
126@item Brother DCP-L2560DW series
127@item Brother FAX-2820
128@item Brother FAX-2840
129@item Brother HL-1110 series
130@item Brother HL-1200 series
131@item Brother HL-2030 series
132@item Brother HL-2130 series
133@item Brother HL-2140 series
134@item Brother HL-2220 series
135@item Brother HL-2230 series
136@item Brother HL-2240 series
137@item Brother HL-2240D series
138@item Brother HL-2250DN series
139@item Brother HL-2260
140@item Brother HL-2260D
141@item Brother HL-2270DW series
142@item Brother HL-2280DW
143@item Brother HL-5030 series
144@item Brother HL-5040 series
145@item Brother HL-5140 series
146@item Brother HL-5370DW series
147@item Brother HL-5450DN series
148@item Brother HL-L2300D series
149@item Brother HL-L2305 series
150@item Brother HL-L2310D series
151@item Brother HL-L2320D series
152@item Brother HL-L2335D series
153@item Brother HL-L2340D series
154@item Brother HL-L2350DW series
155@item Brother HL-L2360D series
156@item Brother HL-L2370DN series
157@item Brother HL-L2375DW series
158@item Brother HL-L2380DW series
159@item Brother HL-L2390DW
160@item Brother HL-L2400DW
161@item Brother HL-L2402D
162@item Brother HL-L2405W
163@item Brother HL-L5000D series
164@item Brother MFC-1810 series
165@item Brother MFC-1910W series
166@item Brother MFC-7240
167@item Brother MFC-7320
168@item Brother MFC-7340
169@item Brother MFC-7360N
170@item Brother MFC-7365DN
171@item Brother MFC-7420
172@item Brother MFC-7440N
173@item Brother MFC-7460DN
174@item Brother MFC-7860DW
175@item Brother MFC-8440
176@item Brother MFC-8710DW
177@item Brother MFC-8860DN
178@item Brother MFC-9160
179@item Brother MFC-L2690DW
180@item Brother MFC-L2700DN series
181@item Brother MFC-L2700DW series
182@item Brother MFC-L2710DN series
183@item Brother MFC-L2710DW series
184@item Brother MFC-L2750DW series
185@item Fuji Xerox DocuPrint P265 dw
186@item Lenovo LJ2650DN
187@end enumerate")
188 (license license:gpl2+)))
189
190(define-public cups-filters
191 (package
192 (name "cups-filters")
193 (version "1.28.16")
194 (source
195 (origin
196 (method url-fetch)
197 (uri
198 (string-append "https://openprinting.org/download/cups-filters/"
199 "cups-filters-" version ".tar.xz"))
200 (sha256
201 (base32 "1h4s35xkbxhxpid39yaiy0gmaj3lck8lhzfdfl3h58hxfpx0nh1s"))
202 (modules '((guix build utils)))
203 (snippet
204 ;; Install backends, banners and filters to cups-filters output
205 ;; directory, not the cups server directory.
206 #~(begin
207 (substitute* "Makefile.in"
208 (("CUPS_DATADIR = @CUPS_DATADIR@")
209 "CUPS_DATADIR = $(PREFIX)/share/cups")
210 (("pkgcupsserverrootdir = \\$\\(CUPS_SERVERROOT\\)")
211 "pkgcupsserverrootdir = $(PREFIX)")
212 ;; Choose standard directories notably so that binaries are
213 ;; stripped.
214 (("^pkg(.*)dir = \\$\\(CUPS_SERVERBIN\\)/(.*)" _ type suffix)
215 (format #f "pkg~adir = $(PREFIX)/lib/cups/~a" type suffix)))
216 ;; Find bannertopdf data such as the print test page in our
217 ;; output directory, not CUPS's prefix.
218 (substitute* "configure"
219 (("\\{CUPS_DATADIR\\}/data")
220 "{prefix}/share/cups/data"))))))
221 (build-system gnu-build-system)
222 (arguments
223 (list #:make-flags
224 #~(list (string-append "PREFIX=" #$output))
225 #:configure-flags
226 #~(list "--disable-mutool" ; needs yet another PDF library (mupdf)
227
228 ;; Look for the "domain socket of CUPS" in /var/run/cups.
229 "--localstatedir=/var"
230
231 ;; Free software for the win.
232 "--with-acroread-path=evince"
233
234 (string-append "--with-test-font-path="
235 #$(this-package-input "font-dejavu")
236 "/share/fonts/truetype/DejaVuSans.ttf")
237 (string-append "--with-gs-path="
238 #$(this-package-input "ghostscript-with-cups")
239 "/bin/gsc")
240 (string-append "--with-shell="
241 (assoc-ref %build-inputs "bash")
242 "/bin/bash")
243 (string-append "--with-rcdir="
244 #$output "/etc/rc.d")
245 ;; QPDF headers include C++17 libraries such as
246 ;; std::string_view.
247 "CFLAGS=-std=gnu17"
248 "CXXFLAGS=-std=gnu++17")
249 #:phases
250 #~(modify-phases %standard-phases
251 (add-after 'unpack 'patch-foomatic-hardcoded-file-names
252 (lambda _
253 ;; Foomatic has hard-coded file names we need to fix.
254 (substitute* "filter/foomatic-rip/foomaticrip.c"
255 (("/usr/local(/lib/cups/filter)" _ file)
256 (string-append #$output file)))))
257 (add-after 'install 'wrap-filters
258 (lambda _
259 ;; Some filters expect to find things in $PATH. We cannot
260 ;; just hard-code all absolute file names in the source
261 ;; because foomatic-rip, for example, has tests like
262 ;; 'startswith(cmd, "gs")'.
263 (for-each
264 (lambda (file)
265 (wrap-program file
266 `("PATH" ":" prefix
267 (,(string-append
268 #$(this-package-input "coreutils") "/bin:"
269 #$(this-package-input "ghostscript-with-cups")
270 "/bin:"
271 #$(this-package-input "grep") "/bin:"
272 #$(this-package-input "sed") "/bin")))))
273 (find-files (string-append #$output
274 "/lib/cups/filter"))))))))
275 (native-inputs
276 (append (if (%current-target-system)
277 (list cups-minimal)
278 '())
279 (list `(,glib "bin") ; for gdbus-codegen
280 pkg-config)))
281 (inputs
282 (list avahi
283 bash-minimal
284 coreutils
285 cups-minimal
286 dbus
287 font-dejavu ;also needed by test suite
288 fontconfig
289 freetype
290 ghostscript/cups
291 glib
292 grep
293 ijs
294 lcms
295 libexif
296 libjpeg-turbo
297 libpng
298 libtiff
299 poppler
300 qpdf
301 sed))
302 (home-page "https://wiki.linuxfoundation.org/openprinting/cups-filters")
303 (synopsis "OpenPrinting CUPS filters and backends")
304 (description
305 "Contains backends, filters, and other software that was once part of the
306core CUPS distribution but is no longer maintained by Apple Inc. In addition
307it contains additional filters developed independently of Apple, especially
308filters for the PDF-centric printing workflow introduced by OpenPrinting.")
309 ;; Different filters and backends have different licenses; see COPYING for
310 ;; details
311 (license (list license:gpl2
312 license:gpl2+
313 license:gpl3
314 license:gpl3+
315 license:lgpl2.0+
316 license:expat))))
317
318;; CUPS on non-MacOS systems requires cups-filters. Since cups-filters also
319;; depends on CUPS libraries and binaries, cups-minimal has been added to
320;; satisfy this dependency.
321(define-public cups-minimal
322 (package
323 (name "cups-minimal")
324 (version "2.4.14")
325 (source
326 (origin
327 (method git-fetch)
328 (uri (git-reference
329 (url "https://github.com/OpenPrinting/cups")
330 (commit (string-append "v" version))))
331 ;; Avoid NAME confusion: these are the complete CUPS sources.
332 (file-name (git-file-name "cups" version))
333 (sha256
334 (base32 "1dk5salizxy1qm19gw93ffdd34hsn1cd4s57nwl7nfhwwirkiri2"))
335 (patches (search-patches "cups-relax-root-ownership-check.patch"))))
336 (build-system gnu-build-system)
337 (arguments
338 (list #:configure-flags
339 ;; This package isn't maximally minimal: "--with-components=libcups"
340 ;; breaks cups-filters. Disable some other unnecessary features.
341 #~(list "--without-icondir"
342 "--without-languages"
343 "--without-menudir")
344 ;; Seven tests fail, mostly because of files that are provided by the
345 ;; cups-filters package.
346 #:tests? #f
347 #:phases
348 #~(modify-phases %standard-phases
349 (add-after 'unpack 'update-config-scripts
350 (lambda* (#:key native-inputs inputs #:allow-other-keys)
351 (for-each (lambda (file)
352 (install-file
353 (search-input-file
354 (or native-inputs inputs)
355 (string-append "/bin/" file)) "."))
356 '("config.guess" "config.sub"))))
357 (add-after 'unpack 'never-cupsAdminGetServerSettings
358 ;; Rather than just ask the daemon, this part of CUPS assumes
359 ;; that (1) it has access to a cupsd.conf under CUPS_SERVERROOT
360 ;; and (2) the file's contents apply to the running daemon.
361 ;; (1) is false at least on Guix Systems resulting in extremely
362 ;; long delays when loading the Web interface's /admin page.
363 ;; (2) is never valid: it ignores, e.g., -c FILE. Upstream
364 ;; considers this code on ‘life support’ so just neuter it.
365 (lambda _
366 (substitute* "cgi-bin/admin.c"
367 (("!cupsAdminGetServerSettings" match)
368 (string-append "0 && " match)))))
369 (add-after 'unpack 'remove-Web-UI-server-settings
370 ;; The /admin page's server configuration form is questionable
371 ;; for the same reason as cupsAdminGetServerSettings, and won't
372 ;; work at all on Guix Systems. Remove it entirely.
373 (lambda _
374 ;; SUBSTITUTE* & patches both have (dis)advantages. This is
375 ;; shorter & should ensure that no translation is forgotten.
376 (substitute* (find-files "templates" "^admin\\.tmpl$")
377 ((" class=\"halves\"") "")
378 (("<FORM.* ACTION=\"/jobs.*</FORM>" match)
379 (string-append match "</P>{BROKEN? "))
380 (("</FORM>}" match)
381 (string-append match "}")))))
382 (add-before 'configure 'patch-makedefs
383 (lambda _
384 (substitute* "Makedefs.in"
385 (("INITDIR.*=.*@INITDIR@") "INITDIR = @prefix@/@INITDIR@")
386 (("/bin/sh") (which "sh")))))
387 (add-before 'check 'skip-failing-tests
388 (lambda _
389 (substitute* "test/run-stp-tests.sh"
390 ;; The number of error/warning lines differs, probably due
391 ;; to a missing font. Substitute the last observed count.
392 (("(\\$count != )33" _ prefix)
393 (string-append prefix "39"))))))))
394 (native-inputs (cons* config pkg-config
395 (if (%current-target-system)
396 (list this-package)
397 '())))
398 (inputs (list zlib gnutls libxcrypt))
399 (home-page "https://openprinting.github.io/cups")
400 (synopsis "The Common Unix Printing System")
401 (description
402 "CUPS is a printing system that uses @acronym{IPP, the Internet Printing
403Protocol} to talk to printers and network clients. It also provides the old
404@command{lp} and @command{lpr} commands, a Web interface, and a C programming
405interface to manage printers and print jobs.
406
407CUPS can print to both local (USB, serial, even parallel) and networked
408printers. Almost any modern printer supports IPP@tie{}Everywhere, sometimes
409sold as AirPrint, and is supported out of the box. Older printers can be
410supported through legacy PPD-based printer drivers called ``printer
411applications''. These must be installed separately.")
412 ;; CUPS is Apache 2.0 with exceptions, see the NOTICE file.
413 (license license:asl2.0)))
414
415(define-public cups
416 (package/inherit cups-minimal
417 (name "cups")
418 (arguments
419 (substitute-keyword-arguments
420 (strip-keyword-arguments
421 '(#:tests?)
422 (package-arguments cups-minimal))
423 ((#:configure-flags flags #~'())
424 #~(append #$flags
425 (list "--with-languages=all"))) ; no ‘=all’ means none(!)
426 ((#:phases phases #~%standard-phases)
427 #~(modify-phases #$phases
428 (add-before 'check 'patch-tests
429 (lambda* (#:key outputs #:allow-other-keys)
430 (let ((filters #$(this-package-input "cups-filters"))
431 (catpath (string-append
432 #$(this-package-input "coreutils") "/bin/"))
433 (testdir (string-append (getcwd) "/tmp/")))
434 (mkdir testdir)
435 (substitute* "test/run-stp-tests.sh"
436 ((" *BASE=/tmp/") (string-append "BASE=" testdir))
437
438 ;; Allow installation of filters from the output directory
439 ;; and from cups-filters.
440 (("for dir in /usr/libexec/cups/filter /usr/lib/cups/filter")
441 (string-append
442 "for dir in "
443 (assoc-ref outputs "out") "/lib/cups/filter "
444 filters "/lib/cups/filter"))
445
446 ;; Check for charsets in the default cups-filters output.
447 (("/usr/share/cups/charsets")
448 (string-append filters "/share/cups/charsets"))
449
450 ;; Install additional required filters.
451 (("instfilter texttopdf texttopdf pdf")
452 (string-append
453 "instfilter texttopdf texttopdf pdf;"
454 "instfilter imagetoraster imagetoraster raster;"
455 "instfilter gstoraster gstoraster raster;"
456 "instfilter urftopdf urftopdf pdf;"
457 "instfilter rastertopdf rastertopdf pdf;"
458 "instfilter pstopdf pstopdf pdf"))
459
460 ;; Specify the location of the lpstat binary.
461 (("description=\"`lpstat -l")
462 "description=\"`../systemv/lpstat -l")
463
464 ;; Patch the shebangs of embedded scripts.
465 (("#!/bin/sh") (string-append "#!" (which "sh")))
466
467 ;; Also link MIME definitions from cups-filters
468 ;; to enable the additional filters for the test suite.
469 (("ln -s \\$root/conf/mime\\.types")
470 (string-append
471 "ln -s " filters
472 "/share/cups/mime/cupsfilters.types $BASE/share/mime; "
473 "ln -s $root/conf/mime.types"))
474 (("ln -s \\$root/conf/mime\\.convs")
475 (string-append
476 "ln -s " filters
477 "/share/cups/mime/cupsfilters.convs $BASE/share/mime; "
478 "ln -s $root/conf/mime.convs")))
479
480 ;; Fix the search path for the "cat" command.
481 (substitute* "cups/testfile.c"
482 (("cupsFileFind\\(\"cat\", \"/bin\"")
483 (string-append "cupsFileFind(\"cat\", \"" catpath "\""))
484 (("cupsFileFind\\(\"cat\", \"/bin:/usr/bin\"")
485 (string-append "cupsFileFind(\"cat\", \"" catpath "\""))))))
486 (add-after 'install 'install-cups-filters-symlinks
487 (lambda* (#:key inputs outputs #:allow-other-keys)
488 (let ((out (assoc-ref outputs "out"))
489 (cups-filters #$(this-package-input "cups-filters")))
490 ;; Charsets.
491 (symlink
492 (string-append cups-filters "/share/cups/charsets")
493 (string-append out "/share/charsets"))
494
495 ;; MIME types, driver files, and PPDs.
496 (for-each
497 (lambda (f)
498 (symlink (string-append cups-filters f)
499 (string-append out f)))
500 '("/share/cups/mime/cupsfilters.types"
501 "/share/cups/mime/cupsfilters.convs"
502 "/share/cups/drv/cupsfilters.drv"
503 "/share/ppd"))
504
505 ;; Filters.
506 (for-each
507 (lambda (f)
508 (symlink f
509 (string-append out "/lib/cups/filter"
510 (basename f))))
511 (find-files (string-append cups-filters "/lib/cups/filter")))
512
513 ;; Backends.
514 (for-each
515 (lambda (f)
516 (symlink (string-append cups-filters f)
517 (string-append out "/lib/cups/backend/"
518 (basename f))))
519 '("/lib/cups/backend/parallel"
520 "/lib/cups/backend/serial"))
521
522 ;; Banners.
523 (let ((banners "/share/cups/banners"))
524 (delete-file-recursively (string-append out banners))
525 (symlink (string-append cups-filters banners)
526 (string-append out banners)))
527
528 ;; Assorted data.
529 (let ((data "/share/cups/data"))
530 (delete-file-recursively (string-append out data))
531 (symlink (string-append cups-filters data)
532 (string-append out data))))))))))
533 (inputs
534 (list avahi
535 coreutils
536 cups-filters
537 gnutls
538 linux-pam
539 zlib))))
540
541(define-public cups-pk-helper
542 (package
543 (name "cups-pk-helper")
544 (version "0.2.7")
545 (source (origin
546 (method url-fetch)
547 (uri (string-append "https://freedesktop.org/software/"
548 name "/releases/" name "-" version ".tar.xz"))
549 (sha256
550 (base32
551 "0cg8wbxpkz9bkpasz973cdazi02svqpbw9mafvpgrscg8kdhs1v6"))))
552 (build-system meson-build-system)
553 (arguments
554 ;; XXX The tests require a running D-Bus and CUPS daemon, of course.
555 (list #:tests? #f
556 #:phases
557 #~(modify-phases %standard-phases
558 (add-after 'install 'install-compatibility-symlink
559 ;; XXX Upstream (and, presumably, the world) has moved to
560 ;; /share/dbus-1 over /etc/dbus-1, but Guix System's
561 ;; dbus-configuration-directory has yet to catch up.
562 ;; TODO It should be properly fixed and this phase removed.
563 (lambda* (#:key outputs #:allow-other-keys)
564 (with-directory-excursion (assoc-ref outputs "out")
565 (mkdir-p "etc")
566 (symlink "../share/dbus-1" "etc/dbus-1")))))))
567 (native-inputs
568 (list intltool pkg-config `(,glib "bin")))
569 (inputs
570 (list glib polkit cups-minimal))
571 (home-page "https://www.freedesktop.org/wiki/Software/cups-pk-helper/")
572 (synopsis "PolicyKit helper to configure CUPS with fine-grained privileges")
573 (description
574 "This package provides the org.opensuse.CupsPkHelper.Mechanism DBus
575system service which uses @file{cups-pk-helper-mechanism}. This package
576should only be used as part of the Guix cups-pk-helper service.")
577 (license license:gpl2+)))
578
579(define-public hplip
580 (package
581 (name "hplip")
582 (version "3.24.4")
583 (source (origin
584 (method url-fetch)
585 (uri (string-append "mirror://sourceforge/hplip/hplip/" version
586 "/hplip-" version ".tar.gz"))
587 (sha256
588 (base32
589 "1yzil1fn9ib2hxmqh9in0apmmznvln0xahlxvyny59ck321l6xjx"))
590 (patches (search-patches "hplip-usb-timeout.patch"))
591 (modules '((guix build utils)))
592 (snippet
593 '(begin
594 ;; Delete non-free blobs: .so files, pre-compiled
595 ;; 'locatedriver' executable, etc.
596 (for-each delete-file
597 (find-files "."
598 (lambda (file stat)
599 (elf-file? file))))
600
601 ;; Now remove some broken references to them.
602 (delete-file "prnt/hpcups/ImageProcessor.h")
603 (substitute* "Makefile.in"
604 ((" -lImageProcessor ") " ")
605 ;; Turn shell commands inside an if…fi into harmless no-ops.
606 (("^(\\@HPLIP_BUILD_TRUE\\@[[:blank:]]*).*libImageProcessor.*"
607 _ prefix)
608 (string-append prefix ": ; \\\n"))
609 ;; Remove the lines adding file targets altogether.
610 (("^\\@FULL_BUILD_TRUE\\@.*libImageProcessor.*")
611 ""))
612
613 ;; Install binaries under libexec/hplip instead of
614 ;; share/hplip; that'll at least ensure they get stripped.
615 ;; It's not even clear that they're of any use though...
616 (substitute* "Makefile.in"
617 (("^dat2drvdir =.*")
618 "dat2drvdir = $(pkglibexecdir)\n")
619 (("^locatedriverdir =.*")
620 "locatedriverdir = $(pkglibexecdir)\n"))))))
621 (outputs (list "out" "ppd"))
622 (build-system gnu-build-system)
623 (arguments
624 (list
625 #:imported-modules %pyproject-build-system-modules
626 #:modules '((guix build gnu-build-system)
627 (guix build utils)
628 ((guix build pyproject-build-system) #:prefix py:))
629 #:configure-flags
630 #~(list "--disable-imageProcessor-build"
631 (string-append "--prefix=" #$output)
632 (string-append "--sysconfdir=" #$output "/etc")
633 (string-append "LDFLAGS=-Wl,-rpath=" #$output "/lib")
634 ;; Disable until mime.types merging works (FIXME).
635 "--disable-fax-build"
636 "--enable-new-hpcups"
637 ;; TODO add foomatic drv install eventually.
638 ;; TODO --enable-policykit eventually.
639 (string-append "--with-cupsfilterdir=" #$output
640 "/lib/cups/filter")
641 (string-append "--with-cupsbackenddir=" #$output
642 "/lib/cups/backend")
643 (string-append "--with-hpppddir=" #$output:ppd "/share/ppd/HP")
644 (string-append "--with-icondir=" #$output "/share/applications")
645 (string-append "--with-systraydir=" #$output "/etc/xdg")
646 "--enable-qt5"
647 "--disable-qt4")
648 #:phases
649 #~(modify-phases %standard-phases
650 (add-after 'unpack 'set-gcc-14-cflags
651 ;; We set CFLAGS here because adding setting it in
652 ;; #:configure-flags or #:make-flags does not work.
653 (lambda _
654 (substitute* "Makefile.in"
655 (("CFLAGS = @CFLAGS@" all)
656 (string-append all
657 " -Wno-error=attributes"
658 " -Wno-error=implicit-function-declaration"
659 " -Wno-error=implicit-int"
660 " -Wno-error=incompatible-pointer-types"
661 " -Wno-error=int-conversion"
662 " -Wno-error=return-mismatch")))))
663 (add-after 'unpack 'fix-hard-coded-file-names
664 (lambda* (#:key inputs outputs #:allow-other-keys)
665 (let ((out #$output)
666 ;; FIXME: use merged ppds (I think actually only
667 ;; drvs need to be merged).
668 (cupsdir #$(this-package-input "cups-minimal")))
669 (substitute* (find-files "." "\\.py$")
670 ;; Refer to the correct default configuration file name.
671 (("/etc/hp/hplip.conf")
672 (string-append out "/etc/hp/hplip.conf")))
673 (substitute* "base/g.py"
674 (("'/usr/share;[^']*'")
675 (string-append "'" cupsdir "/share'"))
676 (("'/etc/hp/hplip.conf'")
677 (string-append "'" out "/etc/hp/hplip.conf" "'")))
678
679 (substitute* "Makefile.in"
680 (("[[:blank:]]check-plugin\\.py[[:blank:]]") " ")
681 ;; FIXME Use beginning-of-word in regexp.
682 (("[[:blank:]]plugin\\.py[[:blank:]]") " ")
683 (("/usr/include/libusb-1.0")
684 (search-input-directory inputs "/include/libusb-1.0"))
685 (("hplip_statedir =.*$")
686 ;; Don't bail out while trying to create
687 ;; /var/lib/hplip. We can safely change its value
688 ;; here because it's hard-coded in the code anyway.
689 "hplip_statedir = $(prefix)\n")
690 (("hplip_confdir = /etc/hp")
691 ;; This is only used for installing the default config.
692 (string-append "hplip_confdir = " out "/etc/hp"))
693 (("halpredir = /usr/share/hal/fdi/preprobe/10osvendor")
694 ;; We don't use hal.
695 (string-append "halpredir = " out
696 "/share/hal/fdi/preprobe/10osvendor"))
697 (("rulesdir = /etc/udev/rules.d")
698 ;; udev rules will be merged by base service.
699 (string-append "rulesdir = " out "/lib/udev/rules.d"))
700 (("rulessystemdir = /usr/lib/systemd/system")
701 ;; We don't use systemd.
702 (string-append "rulessystemdir = " out "/lib/systemd/system"))
703 (("/etc/sane.d")
704 (string-append out "/etc/sane.d"))))))
705 (add-after 'install 'move-sane-config-to-dll.d
706 (lambda _
707 ;; move dll.conf to dll.d - the directory intended for 3rd-party
708 ;; backend configurations.
709 (let ((dll.d (string-append #$output "/etc/sane.d/dll.d"))
710 (dll.conf (string-append #$output "/etc/sane.d/dll.conf")))
711 (mkdir-p dll.d)
712 (rename-file dll.conf (string-append dll.d "/hpaio")))))
713 (add-after 'install 'install-models-dat
714 (lambda* (#:key outputs #:allow-other-keys)
715 (install-file "data/models/models.dat"
716 (string-append #$output "/share/hplip/data/models"))))
717 (add-after 'install 'wrap-binaries
718 ;; Scripts in /bin are all symlinks to .py files in /share/hplip.
719 ;; Symlinks are immune to the Python build system's 'WRAP phase,
720 ;; and the .py files can't be wrapped because they are reused as
721 ;; modules. Replacing the symlinks in /bin with copies and
722 ;; wrapping them also doesn't work (“ModuleNotFoundError:
723 ;; No module named 'base'”). Behold: a custom WRAP-PROGRAM.
724 (lambda* (#:key inputs outputs #:allow-other-keys)
725 (let* ((bin (string-append #$output "/bin"))
726 (site (py:site-packages inputs outputs)))
727 (with-directory-excursion bin
728 (for-each
729 (lambda (file)
730 (let ((target (readlink file)))
731 (delete-file file)
732 (with-output-to-file file
733 (lambda _
734 (format #t
735 "#!~a~@
736 export GUIX_PYTHONPATH=\"~a:~a\"~@
737 exec -a \"$0\" \"~a/~a\" \"$@\"~%"
738 (which "bash")
739 site
740 (getenv "GUIX_PYTHONPATH")
741 bin target)))
742 (chmod file #o755)))
743 (find-files "." (lambda (file stat)
744 (eq? 'symlink (stat:type stat))))))))))))
745 ;; Note that the error messages printed by the tools in the case of
746 ;; missing dependencies are often downright misleading.
747 ;; TODO: hp-toolbox still fails to start with:
748 ;; from dbus.mainloop.pyqt5 import DBusQtMainLoop
749 ;; ModuleNotFoundError: No module named 'dbus.mainloop.pyqt5'
750 (native-inputs (list perl pkg-config))
751 (inputs
752 (list cups-minimal
753 dbus
754 libjpeg-turbo
755 libusb
756 python
757 python-dbus-1.2
758 python-pygobject
759 python-pyqt
760 python-wrapper
761 sane
762 net-snmp
763 openssl
764 avahi
765 zlib))
766 (home-page "https://developers.hp.com/hp-linux-imaging-and-printing")
767 (synopsis "HP printer drivers")
768 (description
769 "Hewlett-Packard printer drivers and PostScript Printer Descriptions
770(@dfn{PPD}s).")
771 ;; The 'COPYING' file lists directories where each of these 3 licenses
772 ;; applies.
773 (license (list license:gpl2+ license:bsd-3 license:expat))))
774
775(define-public hplip-minimal
776 (package/inherit hplip
777 (name "hplip-minimal")
778 (arguments
779 (substitute-keyword-arguments arguments
780 ((#:configure-flags cf)
781 ;; Produce a "light build", meaning that only the printer (CUPS) and
782 ;; scanner (SANE) support gets built, without all the 'hp-*'
783 ;; command-line tools.
784 #~(cons* "--enable-lite-build"
785 "--disable-network-build"
786 ;; The flag "--enable-lite-build" is incompatible with
787 ;; "--enable-network-build" inherited from hplip, so we need
788 ;; to override it with "--disable-network-build".
789 (delete "--enable-qt5" #$cf)))
790 ((#:phases phases)
791 ;; The 'wrap-binaries' is not needed here since the 'hp-*' programs
792 ;; are not installed.
793 #~(alist-delete 'wrap-binaries #$phases))))
794 (inputs
795 (list cups-minimal
796 dbus
797 libjpeg-turbo
798 libusb
799 sane
800 zlib))
801 (synopsis "GUI-less version of hplip")))
802
803(define-public foomatic-filters
804 (package
805 (name "foomatic-filters")
806 (version "4.0.17")
807 (source (origin
808 (method url-fetch)
809 (uri (string-append
810 "http://www.openprinting.org/download/foomatic/"
811 "foomatic-filters-" version ".tar.gz"))
812 (sha256
813 (base32
814 "1qrkgbm5jay2r7sh9qbyf0aiyrsl1mdc844hxf7fhw95a0zfbqm2"))
815 (patches
816 (search-patches "foomatic-filters-CVE-2015-8327.patch"
817 "foomatic-filters-CVE-2015-8560.patch"))))
818 (build-system gnu-build-system)
819 (home-page "https://openprinting.github.io/projects/02-foomatic/")
820 (native-inputs
821 (list perl pkg-config))
822 (inputs
823 (list dbus a2ps))
824 (arguments
825 '( ;; Specify the installation directories.
826 #:configure-flags (list (string-append "ac_cv_path_CUPS_BACKENDS="
827 (assoc-ref %outputs "out")
828 "/lib/cups/backend")
829 (string-append "ac_cv_path_CUPS_FILTERS="
830 (assoc-ref %outputs "out")
831 "/lib/cups/filter")
832 (string-append "ac_cv_path_PPR_INTERFACES="
833 (assoc-ref %outputs "out")
834 "/lib/ppr/interfaces")
835 (string-append "ac_cv_path_PPR_LIB="
836 (assoc-ref %outputs "out")
837 "/lib/ppr/lib")
838 "CFLAGS=-fcommon"
839 ;; For some reason these are misdiagnosed.
840 "ac_cv_func_malloc_0_nonnull=yes"
841 "ac_cv_func_realloc_0_nonnull=yes")
842 #:test-target "tests"))
843 (synopsis "Convert PostScript to the printer's native format")
844 (description
845 "This package contains filter scripts used by the printer spoolers to
846convert the incoming PostScript data into the printer's native format using a
847printer/driver specific, but spooler-independent PPD file.")
848 (license license:gpl2+)))
849
850(define-public foo2zjs
851 (package
852 (name "foo2zjs")
853 (version "20200610.1")
854 (source
855 (origin
856 (method url-fetch)
857 ;; The upstream tarball is unversioned: use a stable snapshot.
858 (uri (string-append "https://web.archive.org/web/20210224094943if_/"
859 "http://foo2zjs.rkkda.com/foo2zjs.tar.gz"))
860 (sha256
861 (base32 "03ncif50n7ck7drggqxbc7w0kgzdb90ha0dbvqk98ky8lw3k76xd"))))
862 (build-system gnu-build-system)
863 (arguments
864 '(#:phases (modify-phases %standard-phases
865 (replace 'configure
866 (lambda* (#:key outputs #:allow-other-keys)
867 (substitute* (find-files "." "^Makefile$")
868 ;; Set the installation directory.
869 (("^PREFIX[[:blank:]]*=.*$")
870 (string-append "PREFIX = "
871 (assoc-ref outputs "out")
872 "\n"))
873 (("^UDEVBIN[[:blank:]]*=.*$")
874 "UDEVBIN = $(PREFIX)/bin\n")
875 ;; Don't try to chown/chgrp the installed files.
876 (("-oroot")
877 "")
878 (("-glp")
879 "")
880 ;; Placate the dependency checks.
881 (("/usr/include/stdio.h")
882 "/etc/passwd")
883 (("/usr/")
884 "$(PREFIX)/")
885 ;; Ensure fixed timestamps in man pages.
886 (("^MODTIME[[:blank:]]*=.*$")
887 "MODTIME = echo Thu Jan 01 01:00:00 1970\n"))
888 #t))
889 (add-before 'install 'make-install-dirs
890 (lambda* (#:key outputs #:allow-other-keys)
891 ;; Make missing install dirs
892 (let ((out (assoc-ref outputs "out"))
893 (dirs '("/share/cups/model"
894 "/share/foomatic/db/source/opt"
895 "/share/foomatic/db/source/printer"
896 "/share/foomatic/db/source/driver"
897 "/lib/cups/filter")))
898 (for-each (lambda (dir)
899 (mkdir-p (string-append out dir)))
900 dirs))))
901 (add-after 'install 'wrap-wrappers
902 (lambda* (#:key inputs outputs #:allow-other-keys)
903 (let ((out (assoc-ref outputs "out"))
904 (ghostscript (assoc-ref inputs "ghostscript"))
905 (coreutils (assoc-ref inputs "coreutils"))
906 (sed (assoc-ref inputs "sed")))
907 (for-each (lambda (file)
908 (wrap-program file
909 `("PATH" ":" prefix
910 (,(string-append ghostscript "/bin:"
911 coreutils "/bin:"
912 sed "/bin")))))
913 (find-files (string-append
914 out "/bin") "wrapper$")))))
915 (add-after 'install 'install-cups-filters-symlinks
916 (lambda* (#:key inputs outputs #:allow-other-keys)
917 (let ((out (assoc-ref outputs "out")))
918 (for-each
919 (lambda (file)
920 (symlink file
921 (string-append out "/lib/cups/filter/"
922 (basename file))))
923 (find-files (string-append out "/bin"))))))
924 (add-after 'install 'remove-pdf
925 (lambda* (#:key outputs #:allow-other-keys)
926 ;; Remove 'manual.pdf' which is (1) useless (it's a
927 ;; concatenation of man pages), and (2) not
928 ;; bit-reproducible due to <https://bugs.gnu.org/27593>.
929 (let ((out (assoc-ref outputs "out")))
930 (for-each delete-file
931 (find-files out "^manual\\.pdf$"))
932 #t))))
933 #:parallel-build? #f ;broken makefile
934 #:tests? #f ;no tests
935 #:make-flags '("CC=gcc")))
936 (inputs
937 (list bash-minimal
938 coreutils
939 sed
940 ghostscript
941 foomatic-filters)) ;for 'foomatic-rip'
942 (native-inputs
943 (list bc groff))
944 ;; The domain has expired and no one has meaningfully taken up the torch.
945 (home-page (string-append "https://web.archive.org/web/20210129024712/"
946 "http://foo2zjs.rkkda.com/"))
947 (synopsis "Printer driver for ZjStream-based printers")
948 (description
949 "foo2zjs is a printer driver for printers that use the Zenographics
950ZjStream wire protocol for their print data, often erroneously referred to as
951winprinters or GDI printers.
952
953It supports Minolta/QMS@tie{}Magicolor, Minolta@tie{}Color@tie{}PageWorks/Pro,
954HP@tie{}LaserJet, and possibly other printers. See @file{README} for details.")
955 (license (list license:expat ; icc2ps/*.[ch]
956 license:gpl2+)))) ; everything else
957
958(define-public epson-inkjet-printer-escpr
959 (package
960 (name "epson-inkjet-printer-escpr")
961 (version "1.7.24")
962 ;; XXX: This currently works. But it will break as soon as a newer version
963 ;; is available since the URLs for older versions are not preserved. Since
964 ;; 1.8.0, source tarballs have been discontinued and only a ‘source RPM’ is
965 ;; available.
966 (source
967 (origin
968 (method url-fetch)
969 (uri (string-append "https://download3.ebz.epson.net/dsc/f/03/00/14/31/"
970 "90/d2f5b28fcfaa0a1d1753eac5703aa5d88004ce06/"
971 "epson-inkjet-printer-escpr-1.7.24-1lsb3.2.tar.gz"))
972 (sha256
973 (base32 "0bwff3p6d0xgghf3bicylbxkv9vxz3gjjbr0iafyxz23kalzz9qj"))))
974 (build-system gnu-build-system)
975 (arguments
976 (list #:modules
977 `((srfi srfi-26)
978 ,@%default-gnu-modules)
979 #:configure-flags
980 #~(list "CFLAGS=-g -O2 -Wno-error=implicit-function-declaration"
981 "--disable-static"
982 (string-append "--prefix=" #$output)
983 (string-append "--with-cupsfilterdir=" #$output "/lib/cups/filter")
984 (string-append "--with-cupsppddir=" #$output "/share/cups/model"))
985 #:phases
986 #~(modify-phases %standard-phases
987 (add-after 'unpack 'patch-autotools-version-requirement
988 (lambda _
989 (substitute* "aclocal.m4"
990 (("1\\.15")
991 #$(package-version automake)))
992 (substitute* "configure"
993 (("^(ACLOCAL=).*" _ match)
994 (string-append match "aclocal"))
995 (("^(AUTOMAKE=).*" _ match)
996 (string-append match "automake")))))
997 (add-after 'install 'compress-PPDs
998 (lambda _
999 (with-directory-excursion #$output
1000 (for-each (cut invoke "gzip" "-9" <>)
1001 (find-files "share/cups" "\\.ppd$"))))))))
1002 (native-inputs
1003 (list autoconf automake))
1004 (inputs
1005 (list cups-minimal))
1006 (synopsis "ESC/P-R printer driver")
1007 (description
1008 "This package provides a filter for @acronym{CUPS, the Common UNIX Printing
1009System} that offers high-quality printing with Seiko@tie{}Epson color ink jet
1010printers. It can be used only with printers that support the Epson@tie{}ESC/P-R
1011language.")
1012 (home-page "https://download.ebz.epson.net/dsc/search/01/search/?OSC=LX")
1013 (license license:gpl2+)))
1014
1015(define-public splix
1016 ;; Last released in 2009 <https://sourceforge.net/projects/splix/files/>.
1017 ;; Last SVN commit was 2013 <https://svn.code.sf.net/p/splix/code/splix/>.
1018 ;; Use a more maintained fork with several bug fixes and support for newer
1019 ;; printer models.
1020 (let ((commit "76268c4dd7dbc8218ea7426401104c3b40cc707a")
1021 (revision "315"))
1022 (package
1023 (name "splix")
1024 (version (git-version "2.0.0" revision commit))
1025 (source
1026 (origin
1027 (method git-fetch)
1028 (uri (git-reference
1029 (url "https://gitlab.com/ScumCoder/splix")
1030 (commit commit)))
1031 (file-name (git-file-name name version))
1032 (sha256
1033 (base32 "1mxsvllwwr1v8sgrax0b7gkajjhnm0l06s67spmaxz47lyll1qab"))))
1034 (build-system gnu-build-system)
1035 ;; PPDs have been obsolete since CUPS 1.2 and make up 90% of total size.
1036 (outputs (list "out" "ppd"))
1037 (arguments
1038 `(#:modules
1039 ((srfi srfi-26)
1040 ,@%default-gnu-modules)
1041 #:make-flags
1042 (list (string-append "CUPSDRV="
1043 (assoc-ref %outputs "out") "/share/cups/drv")
1044 (string-append "CUPSFILTER="
1045 (assoc-ref %outputs "out") "/lib/cups/filter")
1046 (string-append "CUPSPPD="
1047 (assoc-ref %outputs "ppd") "/share/cups/model")
1048 "CACHESIZE=100" ; pages in RAM, ±300 KiB each
1049 "THREADS=4") ; compress and print faster
1050 #:phases
1051 (modify-phases %standard-phases
1052 (add-after 'unpack 'enter-subdirectory
1053 ;; The git repository replicates the top-level SVN layout.
1054 (lambda _
1055 (chdir "splix")
1056 #t))
1057 (delete 'configure) ; no configure script
1058 (add-before 'build 'build-.drv-files
1059 (lambda* (#:key make-flags #:allow-other-keys)
1060 (apply invoke "make" "drv" make-flags)))
1061 (add-after 'install 'install-.drv-files
1062 (lambda* (#:key make-flags #:allow-other-keys)
1063 (apply invoke "make" "install" "DRV_ONLY=1" make-flags)))
1064 (add-after 'install 'compress-PPDs
1065 (lambda* (#:key outputs #:allow-other-keys)
1066 (let ((ppd (assoc-ref outputs "ppd")))
1067 (for-each (cut invoke "gzip" "-9" <>)
1068 (find-files ppd "\\.ppd$"))))))
1069 #:tests? #f)) ; no test suite
1070 (inputs
1071 `(("cups" ,cups-minimal)
1072 ("jbigkit" ,jbigkit)
1073 ("zlib" ,zlib)))
1074 (synopsis "QPDL (SPL2) printer driver")
1075 (description
1076 "SpliX is a set of CUPS drivers for printers that speak @acronym{QPDL,
1077Quick Page Description Language}, also called @acronym{SPL2, Samsung Printer
1078Language version 2}. These include many laser printers sold by Samsung,
1079Xerox, Lexmark, Toshiba, and Dell.
1080
1081Colour printers need colour profile files to get better results. These
1082@file{cms} files are provided by the printer's manufacturer and must be
1083obtained and installed separately.")
1084 (home-page "http://splix.ap2c.org/")
1085 (license license:gpl2))))
1086
1087(define-public python-pycups
1088 (package
1089 (name "python-pycups")
1090 (version "2.0.4")
1091 (source
1092 (origin
1093 (method git-fetch)
1094 (uri (git-reference
1095 (url "https://github.com/zdohnal/pycups")
1096 (commit (string-append "v" version))))
1097 (file-name (git-file-name name version))
1098 (sha256
1099 (base32 "1fx2b04wr9mv87lxk8jpglkyaqwj7bhlj6hnai0dji3jm503dqlb"))))
1100 (build-system pyproject-build-system)
1101 (arguments
1102 (list
1103 ;; XXX: Tests require CUPS to be running, a cups configuration, and
1104 ;; access to associated printers.
1105 #:tests? #f))
1106 (inputs (list cups))
1107 (native-inputs (list python-setuptools python-wheel))
1108 (home-page "https://github.com/zdohnal/pycups")
1109 (synopsis "Python bindings for libcups")
1110 (description
1111 "This package provides Python bindings for libcups, wrapping the CUPS
1112API.")
1113 (license license:gpl2+)))