aboutsummaryrefslogtreecommitdiff
path: root/tw/packages/scanner.scm
blob: aa708263400a07f261bee8bb8b0c9113fbbc814f (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
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)))))