Subject: Re: bug#25101: [PATCH 1/2] gnu: Add hpaio-enabled sane-backends variant.

From: Andy Patterson <[email-masked]>
Date: Mon, 5 Dec 2016 17:38:27 -0500

On Mon, 05 Dec 2016 21:48:36 +0100
[email-masked] (Ludovic Courtès) wrote:

> > +(define-public sane-backends+hpaio  
> 
> Could you add a comment and a synopsis explaining what’s this is?
> 

Sure, is the following patch ok?

> > +  (package
> > +    (inherit sane-backends)
> > +    (name "sane-backends+hpaio")
> > +    (inputs
> > +     `(("hplip" ,(@ (gnu packages cups) hplip))
> > +       ,@(package-inputs sane-backends)))  
> 
> The closure size of this is 290 MiB whereas it’s 87 MiB for
> ‘sane-backends’.  I suppose that’s the reason to keep’em separated?
>

Yeah, and there's also the fact that hplip depends on sane-backends.
But this is the reason I didn't change sane-backends into a private
variable, and then make this the new sane-backends.

> Otherwise LGTM, thanks!
> Ludo’.

Thanks for your review.

--
Andy

From 05474fbe68591b136c912db8aa1400b24800c541 Mon Sep 17 00:00:00 2001
From: Andy Patterson <[email-masked]>
Date: Sat, 3 Dec 2016 22:29:44 -0500
Subject: [PATCH 1/2] gnu: Add hpaio-enabled sane-backends variant.

* gnu/packages/scanner.scm (sane-backends+hpaio): New variable.
---
 gnu/packages/scanner.scm | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/gnu/packages/scanner.scm b/gnu/packages/scanner.scm
index 76817b3..f74c4e1 100644
--- a/gnu/packages/scanner.scm
+++ b/gnu/packages/scanner.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2014 John Darrington <[email-masked]>
 ;;; Copyright © 2015 Andy Wingo <[email-masked]>
+;;; Copyright © 2016 Andy Patterson <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -20,6 +21,7 @@
 (define-module (gnu packages scanner)
   #:use-module (guix packages)
   #:use-module (guix download)
+  #:use-module (guix utils)
   #:use-module (guix build-system gnu)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages libusb)
@@ -73,3 +75,36 @@ proving access to any raster image scanner hardware (flatbed scanner,
 hand-held scanner, video- and still-cameras, frame-grabbers, etc.).  The
 package contains the library and drivers.")
     (license licence:gpl2+))) ; plus linking exception
+
+;; This variant links in the hpaio backend, provided by hplip, which adds
+;; support for HP scanners whose backends are not maintained by
+;; 'sane-backends'
+(define-public sane-backends+hpaio
+  (package
+    (inherit sane-backends)
+    (name "sane-backends+hpaio")
+    (inputs
+     `(("hplip" ,(@ (gnu packages cups) hplip))
+       ,@(package-inputs sane-backends)))
+    (arguments
+     (substitute-keyword-arguments (package-arguments sane-backends)
+       ((#:phases phases)
+        `(modify-phases ,phases
+           (add-after 'unpack 'add-backends
+             (lambda _
+               (substitute* "backend/dll.conf.in"
+                 (("hp5590" all) (format #f "~a~%~a" all "hpaio")))
+               #t))
+           (add-after 'install 'install-hpaio
+             (lambda* (#:key inputs outputs #:allow-other-keys)
+               (define hplip (string-append (assoc-ref inputs "hplip")
+                                            "/lib/sane"))
+               (define out (string-append (assoc-ref outputs "out")
+                                          "/lib/sane"))
+               (for-each
+                (lambda (file)
+                  (symlink file (string-append out "/" (basename file))))
+                (find-files hplip))
+               #t))))))
+    (synopsis
+     "Raster image scanner library and drivers, with full HP scanner support")))
-- 
2.10.2