Subject: bug#38929: [bug#78732] [PATCH] gnu: simple-scan: enable scanning over network for eSCL/WSD scanners

From: Rostislav Svoboda <[email-masked]>
Date: Mon, 9 Jun 2025 21:38:10 +0200

Hello

> The LD_LIBRARY_PATH looks suspicious.

What exactly is suspicious?

>  Is there any way around it using other SANE tooling?

AFAIK there's no simpler runtime-only solution:
- You could use patchelf to prepend the store's lib/sane directory
onto the binary's RPATH, but that's as even even more fiddly as
setting LD_LIBRARY_PATH
- sane-config only spits out compile-time flags (-I..., -L...,
-lsane); it doesn't tell the loader where to find backends at runtime.

BTW, I've polished the patch. Please ignore the previous one - the
phase name was wrong ("wrap-flatpak" instead of "wrap-simple-scan").

Cheers
From f7a355581eb5f6be58e1d1369d7d65dbbc6e774e Mon Sep 17 00:00:00 2001
Message-ID: <f7a355581[email-masked]>
From: Rostislav Svoboda <[email-masked]>
Date: Mon, 9 Jun 2025 13:19:17 +0200
Subject: [PATCH] gnu: simple-scan: enable scanning over network for eSCL/WSD
 scanners

* gnu/packages/gnome.scm (simple-scan)[inputs]: Add sane-airscan.
<#:phases>: Wrap simple-scan to set
  - LD_LIBRARY_PATH to sane-airscan's lib/sane
  - SANE_CONFIG_DIR to sane-airscan's etc/sane.d

This change allows simple-scan to automatically detect and use eSCL or WSD
(AirScan) backends over the network.

Change-Id: Id1d95c77c3fc549b7baf91d31049541a687bce2d
---
 gnu/packages/gnome.scm | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/gnome.scm b/gnu/packages/gnome.scm
index 56236013a7..81a8987a7d 100644
--- a/gnu/packages/gnome.scm
+++ b/gnu/packages/gnome.scm
@@ -7330,7 +7330,19 @@ (define-public simple-scan
         (base32 "1aghnkvjdyj73kv55nd9gl5b1xjkpcxjn4j3a6z67r9g2j86avn1"))))
     (build-system meson-build-system)
     (arguments
-     '(#:glib-or-gtk? #t))
+     (list
+      #:glib-or-gtk? #t
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'install 'wrap-simple-scan
+            (lambda* (#:key inputs #:allow-other-keys)
+              (let ((simple-scan (string-append #$output "/bin/simple-scan"))
+                    (sane-airscan-inputs (assoc-ref inputs "sane-airscan")))
+                (wrap-program simple-scan
+                  `("LD_LIBRARY_PATH" =
+                    (,(string-append sane-airscan-inputs "/lib/sane")))
+                  `("SANE_CONFIG_DIR" prefix
+                    (,(string-append sane-airscan-inputs "/etc/sane.d"))))))))))
     (native-inputs
      (list gettext-minimal
            itstool
@@ -7347,6 +7359,7 @@ (define-public simple-scan
            gdk-pixbuf
            gusb
            libadwaita
+           sane-airscan
            sane-backends))
     (home-page "https://gitlab.gnome.org/GNOME/simple-scan")
     (synopsis "Document and image scanner")

base-commit: 03ce76718c41b32d174713c945d269d6fcdd8bf1
-- 
2.49.0