summary refs log tree commit diff
path: root/gnu/packages/cups.scm
diff options
context:
space:
mode:
authorMaxim Cournoyer <maxim.cournoyer@gmail.com>2023-02-17 22:54:55 -0500
committerMaxim Cournoyer <maxim.cournoyer@gmail.com>2023-04-14 23:37:06 -0400
commit298d0d381e8eecbf2e14a996d43efd4f2f316e36 (patch)
tree4a6f146b32ef8f20894203e619c73e2908279aeb /gnu/packages/cups.scm
parentda923bc12232ee0aacacd3f69ae9db0682903dd9 (diff)
downloadguix-298d0d381e8eecbf2e14a996d43efd4f2f316e36.tar.gz
gnu: hplip: Use gexps.
* gnu/packages/cups.scm (hplip) [arguments]: Use gexps.
* gnu/packages/cups.scm (hplip-minimal): Likewise.
Diffstat (limited to 'gnu/packages/cups.scm')
-rw-r--r--gnu/packages/cups.scm246
1 files changed, 119 insertions, 127 deletions
diff --git a/gnu/packages/cups.scm b/gnu/packages/cups.scm
index f08c7c8584..2bee800041 100644
--- a/gnu/packages/cups.scm
+++ b/gnu/packages/cups.scm
@@ -542,127 +542,119 @@ should only be used as part of the Guix cups-pk-helper service.")
     (outputs (list "out" "ppd"))
     (build-system gnu-build-system)
     (arguments
-     `(#:imported-modules ((guix build python-build-system)
+     (list
+      #:imported-modules `((guix build python-build-system)
                            ,@%gnu-build-system-modules)
-       #:modules ((guix build gnu-build-system)
+      #:modules '((guix build gnu-build-system)
                   (guix build utils)
                   ((guix build python-build-system) #:prefix python:))
-       #:configure-flags
-       `("--disable-imageProcessor-build"
-         "--disable-network-build"
-         ,(string-append "--prefix=" (assoc-ref %outputs "out"))
-         ,(string-append "--sysconfdir=" (assoc-ref %outputs "out") "/etc")
-         ,(string-append "LDFLAGS=-Wl,-rpath="
-                         (assoc-ref %outputs "out") "/lib")
-         ;; Disable until mime.types merging works (FIXME).
-         "--disable-fax-build"
-         "--enable-new-hpcups"
-         ;; TODO add foomatic drv install eventually.
-         ;; TODO --enable-policykit eventually.
-         ,(string-append "--with-cupsfilterdir="
-                         (assoc-ref %outputs "out") "/lib/cups/filter")
-         ,(string-append "--with-cupsbackenddir="
-                         (assoc-ref %outputs "out") "/lib/cups/backend")
-         ,(string-append "--with-hpppddir="
-                         (assoc-ref %outputs "ppd") "/share/ppd/HP")
-         ,(string-append "--with-icondir="
-                         (assoc-ref %outputs "out") "/share/applications")
-         ,(string-append "--with-systraydir="
-                         (assoc-ref %outputs "out") "/etc/xdg")
-         "--enable-qt5" "--disable-qt4")
-       #:phases
-       (modify-phases %standard-phases
-         (add-after 'unpack 'fix-hard-coded-file-names
-           (lambda* (#:key inputs outputs #:allow-other-keys)
-             (let ((out (assoc-ref outputs "out"))
-                   ;; FIXME: use merged ppds (I think actually only
-                   ;; drvs need to be merged).
-                   (cupsdir (assoc-ref inputs "cups-minimal")))
-               (substitute* (find-files "." "\\.py$")
-                 ;; Refer to the correct default configuration file name.
-                 (("/etc/hp/hplip.conf")
-                  (string-append out "/etc/hp/hplip.conf")))
-               (substitute* "base/g.py"
-                 (("'/usr/share;[^']*'")
-                  (string-append "'" cupsdir "/share'"))
-                 (("'/etc/hp/hplip.conf'")
-                  (string-append "'" out
-                                 "/etc/hp/hplip.conf" "'")))
-
-               (substitute* "Makefile.in"
-                 (("[[:blank:]]check-plugin\\.py[[:blank:]]") " ")
-                 ;; FIXME Use beginning-of-word in regexp.
-                 (("[[:blank:]]plugin\\.py[[:blank:]]") " ")
-                 (("/usr/include/libusb-1.0")
-                  (search-input-directory inputs "/include/libusb-1.0"))
-                 (("hplip_statedir =.*$")
-                  ;; Don't bail out while trying to create
-                  ;; /var/lib/hplip.  We can safely change its value
-                  ;; here because it's hard-coded in the code anyway.
-                  "hplip_statedir = $(prefix)\n")
-                 (("hplip_confdir = /etc/hp")
-                  ;; This is only used for installing the default config.
-                  (string-append "hplip_confdir = " out
-                                 "/etc/hp"))
-                 (("halpredir = /usr/share/hal/fdi/preprobe/10osvendor")
-                  ;; We don't use hal.
-                  (string-append "halpredir = " out
-                                 "/share/hal/fdi/preprobe/10osvendor"))
-                 (("rulesdir = /etc/udev/rules.d")
-                  ;; udev rules will be merged by base service.
-                  (string-append "rulesdir = " out
-                                 "/lib/udev/rules.d"))
-                 (("rulessystemdir = /usr/lib/systemd/system")
-                  ;; We don't use systemd.
-                  (string-append "rulessystemdir = " out
-                                 "/lib/systemd/system"))
-                 (("/etc/sane.d")
-                  (string-append out "/etc/sane.d"))))))
-         (add-before 'configure 'fix-build-with-python-3.8
-           (lambda* (#:key inputs #:allow-other-keys)
-             (let ((python (assoc-ref inputs "python")))
-               ;; XXX: The configure script looks for Python headers in the
-               ;; wrong places as of version 3.20.3.  Help it by adding the
-               ;; include directory on C_INCLUDE_PATH.
-               (when python
-                 (setenv "C_INCLUDE_PATH"
-                         (string-append python "/include/python"
-                                        (python:python-version python)
-                                        ":" (getenv "C_INCLUDE_PATH")))))))
-         (add-after 'install 'install-models-dat
-           (lambda* (#:key outputs #:allow-other-keys)
-             (let* ((out (assoc-ref outputs "out"))
-                    (models-dir (string-append out
-                                               "/share/hplip/data/models")))
-               (install-file "data/models/models.dat" models-dir))))
-         (add-after 'install 'wrap-binaries
-           ;; Scripts in /bin are all symlinks to .py files in /share/hplip.
-           ;; Symlinks are immune to the Python build system's 'WRAP phase,
-           ;; and the .py files can't be wrapped because they are reused as
-           ;; modules.  Replacing the symlinks in /bin with copies and
-           ;; wrapping them also doesn't work (“ModuleNotFoundError:
-           ;; No module named 'base'”).  Behold: a custom WRAP-PROGRAM.
-           (lambda* (#:key inputs outputs #:allow-other-keys)
-             (let* ((out (assoc-ref outputs "out"))
-                    (bin (string-append out "/bin"))
-                    (site (python:site-packages inputs outputs)))
-               (with-directory-excursion bin
-                 (for-each (lambda (file)
-                             (let ((target (readlink file)))
-                               (delete-file file)
-                               (with-output-to-file file
-                                 (lambda _
-                                   (format #t
-                                           "#!~a~@
+      #:configure-flags
+      #~(list "--disable-imageProcessor-build"
+              "--disable-network-build"
+              (string-append "--prefix=" #$output)
+              (string-append "--sysconfdir=" #$output "/etc")
+              (string-append "LDFLAGS=-Wl,-rpath=" #$output "/lib")
+              ;; Disable until mime.types merging works (FIXME).
+              "--disable-fax-build"
+              "--enable-new-hpcups"
+              ;; TODO add foomatic drv install eventually.
+              ;; TODO --enable-policykit eventually.
+              (string-append "--with-cupsfilterdir=" #$output
+                             "/lib/cups/filter")
+              (string-append "--with-cupsbackenddir=" #$output
+                             "/lib/cups/backend")
+              (string-append "--with-hpppddir=" #$output:ppd "/share/ppd/HP")
+              (string-append "--with-icondir=" #$output "/share/applications")
+              (string-append "--with-systraydir=" #$output "/etc/xdg")
+              "--enable-qt5"
+              "--disable-qt4")
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'unpack 'fix-hard-coded-file-names
+            (lambda* (#:key inputs outputs #:allow-other-keys)
+              (let ((out #$output)
+                    ;; FIXME: use merged ppds (I think actually only
+                    ;; drvs need to be merged).
+                    (cupsdir #$(this-package-input "cups-minimal")))
+                (substitute* (find-files "." "\\.py$")
+                  ;; Refer to the correct default configuration file name.
+                  (("/etc/hp/hplip.conf")
+                   (string-append out "/etc/hp/hplip.conf")))
+                (substitute* "base/g.py"
+                  (("'/usr/share;[^']*'")
+                   (string-append "'" cupsdir "/share'"))
+                  (("'/etc/hp/hplip.conf'")
+                   (string-append "'" out "/etc/hp/hplip.conf" "'")))
+
+                (substitute* "Makefile.in"
+                  (("[[:blank:]]check-plugin\\.py[[:blank:]]") " ")
+                  ;; FIXME Use beginning-of-word in regexp.
+                  (("[[:blank:]]plugin\\.py[[:blank:]]") " ")
+                  (("/usr/include/libusb-1.0")
+                   (search-input-directory inputs "/include/libusb-1.0"))
+                  (("hplip_statedir =.*$")
+                   ;; Don't bail out while trying to create
+                   ;; /var/lib/hplip.  We can safely change its value
+                   ;; here because it's hard-coded in the code anyway.
+                   "hplip_statedir = $(prefix)\n")
+                  (("hplip_confdir = /etc/hp")
+                   ;; This is only used for installing the default config.
+                   (string-append "hplip_confdir = " out "/etc/hp"))
+                  (("halpredir = /usr/share/hal/fdi/preprobe/10osvendor")
+                   ;; We don't use hal.
+                   (string-append "halpredir = " out
+                                  "/share/hal/fdi/preprobe/10osvendor"))
+                  (("rulesdir = /etc/udev/rules.d")
+                   ;; udev rules will be merged by base service.
+                   (string-append "rulesdir = " out "/lib/udev/rules.d"))
+                  (("rulessystemdir = /usr/lib/systemd/system")
+                   ;; We don't use systemd.
+                   (string-append "rulessystemdir = " out "/lib/systemd/system"))
+                  (("/etc/sane.d")
+                   (string-append out "/etc/sane.d"))))))
+          (add-before 'configure 'fix-build-with-python-3.8
+            (lambda* (#:key inputs #:allow-other-keys)
+              (let ((python (assoc-ref inputs "python")))
+                ;; XXX: The configure script looks for Python headers in the
+                ;; wrong places as of version 3.20.3.  Help it by adding the
+                ;; include directory on C_INCLUDE_PATH.
+                (when python
+                  (setenv "C_INCLUDE_PATH"
+                          (string-append python "/include/python"
+                                         (python:python-version python)
+                                         ":" (getenv "C_INCLUDE_PATH")))))))
+          (add-after 'install 'install-models-dat
+            (lambda* (#:key outputs #:allow-other-keys)
+              (install-file "data/models/models.dat"
+                            (string-append #$output "/share/hplip/data/models"))))
+          (add-after 'install 'wrap-binaries
+            ;; Scripts in /bin are all symlinks to .py files in /share/hplip.
+            ;; Symlinks are immune to the Python build system's 'WRAP phase,
+            ;; and the .py files can't be wrapped because they are reused as
+            ;; modules.  Replacing the symlinks in /bin with copies and
+            ;; wrapping them also doesn't work (“ModuleNotFoundError:
+            ;; No module named 'base'”).  Behold: a custom WRAP-PROGRAM.
+            (lambda* (#:key inputs outputs #:allow-other-keys)
+              (let* ((out (assoc-ref outputs "out"))
+                     (bin (string-append out "/bin"))
+                     (site (python:site-packages inputs outputs)))
+                (with-directory-excursion bin
+                  (for-each (lambda (file)
+                              (let ((target (readlink file)))
+                                (delete-file file)
+                                (with-output-to-file file
+                                  (lambda _
+                                    (format #t
+                                            "#!~a~@
                                            export GUIX_PYTHONPATH=\"~a:~a\"~@
                                            exec -a \"$0\" \"~a/~a\" \"$@\"~%"
-                                           (which "bash")
-                                           site
-                                           (getenv "GUIX_PYTHONPATH")
-                                           bin target)))
-                               (chmod file #o755)))
-                           (find-files "." (lambda (file stat)
-                                             (eq? 'symlink (stat:type stat))))))))))))
+                                            (which "bash")
+                                            site
+                                            (getenv "GUIX_PYTHONPATH")
+                                            bin target)))
+                                (chmod file #o755)))
+                            (find-files "." (lambda (file stat)
+                                              (eq? 'symlink (stat:type stat))))))))))))
     ;; Note that the error messages printed by the tools in the case of
     ;; missing dependencies are often downright misleading.
     ;; TODO: hp-toolbox still fails to start with:
@@ -694,17 +686,17 @@ should only be used as part of the Guix cups-pk-helper service.")
   (package/inherit hplip
     (name "hplip-minimal")
     (arguments
-      (substitute-keyword-arguments (package-arguments hplip)
-        ((#:configure-flags cf)
-         ;; Produce a "light build", meaning that only the printer (CUPS) and
-         ;; scanner (SANE) support gets built, without all the 'hp-*'
-         ;; command-line tools.
-         `(cons "--enable-lite-build"
-                (delete "--enable-qt5" ,cf)))
-        ((#:phases phases)
-         ;; The 'wrap-binaries' is not needed here since the 'hp-*' programs
-         ;; are not installed.
-         `(alist-delete 'wrap-binaries ,phases))))
+     (substitute-keyword-arguments (package-arguments hplip)
+       ((#:configure-flags cf)
+        ;; Produce a "light build", meaning that only the printer (CUPS) and
+        ;; scanner (SANE) support gets built, without all the 'hp-*'
+        ;; command-line tools.
+        #~(cons "--enable-lite-build"
+                (delete "--enable-qt5" #$cf)))
+       ((#:phases phases)
+        ;; The 'wrap-binaries' is not needed here since the 'hp-*' programs
+        ;; are not installed.
+        #~(alist-delete 'wrap-binaries #$phases))))
     (inputs (remove (match-lambda
                       ((label . _)
                        (string-prefix? "python" label)))