summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tw/home/lap.scm3
-rw-r--r--tw/packages/scanner.scm122
-rw-r--r--tw/system/lap.scm18
3 files changed, 138 insertions, 5 deletions
diff --git a/tw/home/lap.scm b/tw/home/lap.scm
index 7a6af2d4..e5149e5d 100644
--- a/tw/home/lap.scm
+++ b/tw/home/lap.scm
@@ -38,6 +38,7 @@
#:use-module ((nongnu packages steam-client)
#:select (steam))
#:use-module (tw home)
+ #:use-module (tw packages scanner)
#:use-module (tw services restic)
#:use-module (tw theme))
@@ -97,7 +98,7 @@
adb fastboot beets cmus
;; Graphical applications
- blueman electrum nheko signal-desktop simple-scan transmission-remote-gtk
+ blueman electrum nheko signal-desktop simple-scan/airscan transmission-remote-gtk
;; Games
steam ; see also: steam-nvidia
diff --git a/tw/packages/scanner.scm b/tw/packages/scanner.scm
new file mode 100644
index 00000000..aa708263
--- /dev/null
+++ b/tw/packages/scanner.scm
@@ -0,0 +1,122 @@
+(define-module (tw packages scanner)
+ #:use-module (gnu packages avahi)
+ #:use-module (gnu packages compression)
+ #:use-module (gnu packages gnome)
+ #:use-module (gnu packages golang)
+ #:use-module (gnu packages libusb)
+ #:use-module (gnu packages pkg-config)
+ #:use-module (gnu packages scanner)
+ #:use-module (guix build-system gnu)
+ #:use-module (guix build-system go)
+ #:use-module (guix git-download)
+ #:use-module (guix packages)
+ #:use-module ((guix utils) #:select (substitute-keyword-arguments))
+ #:use-module ((guix licenses) #:prefix license:))
+
+(define-public go-github-com-openprinting-goipp
+ (package
+ (name "go-github-com-openprinting-goipp")
+ (version "1.0.0")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/OpenPrinting/goipp")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "128bhqayglplcivvcvvdb2cclsfwmqdckaysij7j1k0r0b8sr2xw"))))
+ (build-system go-build-system)
+ (arguments
+ '(#:import-path "github.com/OpenPrinting/goipp"))
+ (home-page "https://github.com/OpenPrinting/goipp")
+ (synopsis "IPP core protocol implementation in pure Go")
+ (description "Implements the IPP core protocol, as defined by
+@url{https://rfc-editor.org/rfc/rfc8010.html,RFC 8010}.")
+ (license license:bsd-2)))
+
+(define-public ipp-usb
+ (package
+ (name "ipp-usb")
+ (version "0.9.23")
+ (home-page "https://github.com/OpenPrinting/ipp-usb")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference (url home-page) (commit version)))
+ (file-name (git-file-name name version))
+ (sha256 (base32 "16nq0z24ifx3n85sa483rkshsc132mxd4v5kj3vs0kd4m9cd1cxi"))))
+ (build-system go-build-system) ; written in Go, but controlled by Makefile
+ (arguments `(#:install-source? #f ; binary-only package
+ #:import-path "github.com/OpenPrinting/ipp-usb"
+ #:phases
+ (modify-phases %standard-phases
+ (replace 'build
+ (lambda* (#:key unpack-path import-path #:allow-other-keys)
+ (with-directory-excursion (string-append "src/" (if (string-null? unpack-path)
+ import-path
+ unpack-path))
+ (invoke "make"))))
+ (replace 'install
+ (lambda* (#:key outputs unpack-path import-path #:allow-other-keys)
+ (with-directory-excursion (string-append "src/" (if (string-null? unpack-path)
+ import-path
+ unpack-path))
+ (invoke "make" (string-append "PREFIX=" (assoc-ref outputs "out")) "install"))))
+ (add-after 'install 'guix-directories
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let ((out (assoc-ref outputs "out")))
+ (rename-file (string-append out "/sbin")
+ (string-append out "/bin"))
+ (rename-file (string-append out "/usr/share")
+ (string-append out "/share"))
+ (rmdir (string-append out "/usr"))
+ ;; The .service file isn't useful in Guix.
+ (delete-file-recursively (string-append out "/lib/systemd"))
+ ;; The udev .rules file refers to the systemd .service file only.
+ (delete-file-recursively (string-append out "/lib/udev"))
+ (rmdir (string-append out "/lib"))))))))
+ (inputs (list avahi libusb)) ; avahi for libavahi-client and libavahi-common
+ (native-inputs (list go pkg-config go-github-com-openprinting-goipp gzip))
+ (synopsis "HTTP reverse proxy, backed by IPP-over-USB connection to device")
+ (description "IPP-over-USB allows using the IPP protocol, normally
+designed for network printers, to be used with USB printers as well.
+
+The idea behind this standard is simple: It allows to send HTTP requests to
+the device via a USB connection, so enabling IPP, eSCL (AirScan) and web
+console on devices without Ethernet or WiFi connections.")
+ (license license:bsd-2)))
+
+(define-public sane-backends/airscan
+ (package/inherit sane-backends
+ (name "sane-airscan-backends")
+ (inputs
+ (let ((inputs (list-copy (package-inputs sane-backends))))
+ (assq-remove! inputs "hplip")
+ `(("sane-airscan" ,sane-airscan) ,@inputs)))
+ (arguments
+ (substitute-keyword-arguments (package-arguments sane-backends)
+ ((#:phases phases)
+ `(modify-phases ,phases
+ (delete 'add-backends) ; for hplip
+ (delete 'install-hpaio) ; for hplip
+ (add-after 'install 'install-airscan
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (let ((out (assoc-ref outputs "out"))
+ (airscan (assoc-ref inputs "sane-airscan")))
+ (for-each (lambda (file)
+ (symlink file (string-append out "/lib/sane/" (basename file))))
+ (find-files (string-append airscan "/lib/sane")))
+ (symlink (string-append airscan "/etc/sane.d/airscan.conf")
+ (string-append out "/etc/sane.d/airscan.conf"))
+ (symlink (string-append airscan "/etc/sane.d/dll.d/airscan")
+ (string-append out "/etc/sane.d/dll.d/airscan")))))))))
+ (description "SANE stands for \"Scanner Access Now Easy\" and is an API
+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, including the sane-airscan driver,
+but not the hpaio backend provided by hplip.")))
+
+(define-public simple-scan/airscan
+ (package/inherit simple-scan
+ (inputs (modify-inputs (package-inputs simple-scan)
+ (replace "sane-backends" sane-backends/airscan)))))
diff --git a/tw/system/lap.scm b/tw/system/lap.scm
index eb4b7006..d840ac1f 100644
--- a/tw/system/lap.scm
+++ b/tw/system/lap.scm
@@ -14,10 +14,10 @@
#:use-module ((guix utils) #:select (substitute-keyword-arguments))
#:use-module ((nongnu packages linux)
#:prefix nongnu:) ; don't interfere with (gnu packages linux)
- #:use-module (nongnu packages scanner)
#:use-module (nongnu system linux-initrd)
#:use-module (nonguix licenses)
#:use-module (tw channels)
+ #:use-module (tw packages scanner)
#:use-module (tw services wireguard)
#:use-module (tw system))
@@ -245,9 +245,6 @@ support extra features (acr, pmu, gr).")
cups docker mit-krb5
;; File systems
dosfstools mtools ntfs-3g
- ;; Printing and scanning
- ;; SANE doesn't detect my scanner without brscan4's etc/sane.d/dll.conf.
- brscan4
;; Desktop and drivers
;; FIXME: lightdm depends on python-2, but the build throws an
;; error that python2 is not supported.
@@ -385,6 +382,16 @@ support extra features (acr, pmu, gr).")
(call-with-output-file "/sys/class/backlight/intel_backlight/brightness"
(cut display max-brightness <>))))))))))
+ (simple-service 'scanning-services shepherd-root-service-type
+ (list
+ (shepherd-service
+ (documentation "Expose USB scanners over IPP.")
+ (provision '(ipp-usb))
+ (requirement '(networking)) ; only on localhost, though
+ (start #~(make-forkexec-constructor
+ (list #$(file-append ipp-usb "/bin/ipp-usb") "standalone")))
+ (stop #~(make-kill-destructor)))))
+
(extra-special-file "/etc/guix/machines.scm"
(scheme-file "machines.scm"
#~(let ((lud (build-machine
@@ -417,6 +424,9 @@ support extra features (acr, pmu, gr).")
(list lud))))))
(modify-services (append %system-channel-services %desktop-services)
+ ;; Let sane find the airscan backend. ipp-usb needs to be running separately.
+ (sane-service-type _ => sane-backends/airscan)
+
(gdm-service-type
config =>
(gdm-configuration