Merge branch 'master' into staging
[jackhill/guix/guix.git] / gnu / packages / electronics.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2017 Theodoros Foradis <theodoros@foradis.org>
3 ;;; Copyright © 2018–2021 Tobias Geerinckx-Rice <me@tobias.gr>
4 ;;; Copyright © 2019 Clément Lassieur <clement@lassieur.org>
5 ;;; Copyright © 2021 Efraim Flashner <efraim@flashner.co.il>
6 ;;; Copyright © 2021 Leo Famulari <leo@famulari.name>
7 ;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
8 ;;;
9 ;;; This file is part of GNU Guix.
10 ;;;
11 ;;; GNU Guix is free software; you can redistribute it and/or modify it
12 ;;; under the terms of the GNU General Public License as published by
13 ;;; the Free Software Foundation; either version 3 of the License, or (at
14 ;;; your option) any later version.
15 ;;;
16 ;;; GNU Guix is distributed in the hope that it will be useful, but
17 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;;; GNU General Public License for more details.
20 ;;;
21 ;;; You should have received a copy of the GNU General Public License
22 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
23
24 (define-module (gnu packages electronics)
25 #:use-module (guix download)
26 #:use-module (guix gexp)
27 #:use-module (guix git-download)
28 #:use-module ((guix licenses) #:prefix license:)
29 #:use-module (guix packages)
30 #:use-module (guix utils)
31 #:use-module (guix build-system gnu)
32 #:use-module (guix build-system cmake)
33 #:use-module (gnu packages)
34 #:use-module (gnu packages algebra)
35 #:use-module (gnu packages autotools)
36 #:use-module (gnu packages base)
37 #:use-module (gnu packages bash)
38 #:use-module (gnu packages boost)
39 #:use-module (gnu packages c)
40 #:use-module (gnu packages check)
41 #:use-module (gnu packages compression)
42 #:use-module (gnu packages documentation)
43 #:use-module (gnu packages embedded)
44 #:use-module (gnu packages fontutils)
45 #:use-module (gnu packages gawk)
46 #:use-module (gnu packages gl)
47 #:use-module (gnu packages glib)
48 #:use-module (gnu packages graphviz)
49 #:use-module (gnu packages gtk)
50 #:use-module (gnu packages libftdi)
51 #:use-module (gnu packages libusb)
52 #:use-module (gnu packages linux)
53 #:use-module (gnu packages m4)
54 #:use-module (gnu packages pkg-config)
55 #:use-module (gnu packages python)
56 #:use-module (gnu packages qt)
57 #:use-module (gnu packages sdl)
58 #:use-module (gnu packages sqlite)
59 #:use-module (gnu packages stb))
60
61 (define-public libserialport
62 (package
63 (name "libserialport")
64 (version "0.1.1")
65 (source (origin
66 (method url-fetch)
67 (uri (string-append
68 "http://sigrok.org/download/source/libserialport/libserialport-"
69 version ".tar.gz"))
70 (sha256
71 (base32
72 "17ajlwgvyyrap8z7f16zcs59pksvncwbmd3mzf98wj7zqgczjaja"))))
73 (build-system gnu-build-system)
74 (home-page "https://sigrok.org/wiki/Libserialport")
75 (synopsis "Library for using serial ports")
76 (description "Libserialport is a minimal shared library written in C that is intended
77 to take care of the OS-specific details when writing software that uses serial ports.")
78 (license license:lgpl3+)))
79
80 (define-public libsigrokdecode
81 (package
82 (name "libsigrokdecode")
83 (version "0.5.3")
84 (source (origin
85 (method url-fetch)
86 (uri (string-append
87 "http://sigrok.org/download/source/libsigrokdecode/libsigrokdecode-"
88 version ".tar.gz"))
89 (sha256
90 (base32
91 "1h1zi1kpsgf6j2z8j8hjpv1q7n49i3fhqjn8i178rka3cym18265"))
92 (patches
93 (search-patches "libsigrokdecode-python3.9-fix.patch"))))
94 (outputs '("out" "doc"))
95 (arguments
96 `(#:phases
97 (modify-phases %standard-phases
98 (replace 'bootstrap
99 (lambda _
100 (invoke "autoconf")
101 (invoke "aclocal")
102 (invoke "automake" "-ac")))
103 (add-after 'build 'build-doc
104 (lambda _
105 (invoke "doxygen")
106 #t))
107 (add-after 'install 'install-doc
108 (lambda* (#:key outputs #:allow-other-keys)
109 (copy-recursively "doxy/html-api"
110 (string-append (assoc-ref outputs "doc")
111 "/share/doc/libsigrokdecode"))
112 #t)))))
113 (native-inputs
114 (list check-0.14 doxygen graphviz pkg-config automake autoconf))
115 ;; libsigrokdecode.pc lists "python" in Requires.private, and "glib" in Requires.
116 (propagated-inputs
117 (list glib python))
118 (build-system gnu-build-system)
119 (home-page "https://www.sigrok.org/wiki/Libsigrokdecode")
120 (synopsis "Library providing (streaming) protocol decoding functionality")
121 (description "Libsigrokdecode is a shared library written in C, which provides
122 (streaming) protocol decoding functionality.")
123 (license license:gpl3+)))
124
125 (define-public sigrok-firmware-fx2lafw
126 (package
127 (name "sigrok-firmware-fx2lafw")
128 (version "0.1.7")
129 (source (origin
130 (method url-fetch)
131 (uri (string-append
132 "http://sigrok.org/download/source/sigrok-firmware-fx2lafw/"
133 "sigrok-firmware-fx2lafw-" version ".tar.gz"))
134 (sha256
135 (base32
136 "0fyfd82mvrcf55v5a3afq1mh1kfswk4c37qrbln6x92jm3b41x53"))))
137 (arguments
138 `(#:implicit-inputs? #f))
139 (native-inputs
140 `(("awk" ,gawk)
141 ("bash" ,bash)
142 ("coreutils" ,coreutils)
143 ("grep" ,grep)
144 ("gzip" ,gzip)
145 ("make" ,gnu-make)
146 ("sdcc" ,sdcc)
147 ("sed" ,sed)
148 ("tar" ,tar)))
149 (build-system gnu-build-system)
150 (home-page "https://www.sigrok.org/wiki/Fx2lafw")
151 (synopsis "Firmware for Cypress FX2 chips")
152 (description "Fx2lafw is free firmware for Cypress FX2 chips which makes them usable
153 as simple logic analyzer and/or oscilloscope hardware.")
154 (license license:gpl2+)))
155
156 (define-public libsigrok
157 (let ((commit "a7e919a3a6b7fd511acbe1a280536b76c70c28d2")
158 (revision "1"))
159 (package
160 (name "libsigrok")
161 (version (git-version "0.5.2" revision commit))
162 (source
163 (origin
164 (method git-fetch)
165 (uri (git-reference
166 (url "git://sigrok.org/libsigrok")
167 (commit commit)))
168 (sha256
169 (base32 "0km3fyv5s2byrm4zpbss2527ynhw4nb67imnbawwic2a6zh9jiyc"))
170 (file-name (git-file-name name version))))
171 (outputs '("out" "doc"))
172 (arguments
173 `(#:tests? #f ; tests need USB access
174 #:phases
175 (modify-phases %standard-phases
176 (add-before 'configure 'change-udev-group
177 (lambda _
178 (substitute* (find-files "contrib" "\\.rules$")
179 (("plugdev") "dialout"))))
180 (add-after 'build 'build-doc
181 (lambda _
182 (invoke "doxygen")))
183 (add-after 'install 'install-doc
184 (lambda* (#:key outputs #:allow-other-keys)
185 (copy-recursively "doxy/html-api"
186 (string-append (assoc-ref outputs "doc")
187 "/share/doc/libsigrok"))))
188 (add-after 'install-doc 'install-udev-rules
189 (lambda* (#:key outputs #:allow-other-keys)
190 (let* ((out (assoc-ref outputs "out"))
191 (rules (string-append out "/lib/udev/rules.d/")))
192 (for-each (lambda (file)
193 (install-file file rules))
194 (find-files "contrib" "\\.rules$")))))
195 (add-after 'install-udev-rules 'install-fw
196 (lambda* (#:key inputs outputs #:allow-other-keys)
197 (let* ((fx2lafw (assoc-ref inputs "sigrok-firmware-fx2lafw"))
198 (out (assoc-ref outputs "out"))
199 (dir-suffix "/share/sigrok-firmware/")
200 (input-dir (string-append fx2lafw dir-suffix))
201 (output-dir (string-append out dir-suffix)))
202 (for-each
203 (lambda (file)
204 (install-file file output-dir))
205 (find-files input-dir "."))))))))
206 (native-inputs
207 (list autoconf automake doxygen graphviz libtool
208 sigrok-firmware-fx2lafw pkg-config))
209 (inputs
210 (list python zlib))
211 ;; libsigrokcxx.pc lists "glibmm" in Requires libsigrok.pc lists
212 ;; "libserialport", "libusb", "libftdi" and "libzip" in Requires.private
213 ;; and "glib" in Requires
214 (propagated-inputs
215 (list glib
216 glibmm-2.64
217 libserialport
218 libusb
219 libftdi
220 libzip))
221 (build-system gnu-build-system)
222 (home-page "https://www.sigrok.org/wiki/Libsigrok")
223 (synopsis "Basic hardware access drivers for logic analyzers")
224 (description "@code{libsigrok} is a shared library written in C which
225 provides the basic hardware access drivers for logic analyzers and other
226 supported devices, as well as input/output file format support.")
227 (license license:gpl3+))))
228
229 (define-public sigrok-cli
230 (package
231 (name "sigrok-cli")
232 (version "0.7.2")
233 (source (origin
234 (method url-fetch)
235 (uri (string-append
236 "http://sigrok.org/download/source/sigrok-cli/sigrok-cli-"
237 version ".tar.gz"))
238 (sha256
239 (base32
240 "1f0a2k8qdcin0pqiqq5ni4khzsnv61l21v1dfdjzayw96qzl9l3i"))))
241 (native-inputs
242 (list pkg-config))
243 (inputs
244 (list glib libsigrok libsigrokdecode))
245 (build-system gnu-build-system)
246 (home-page "https://sigrok.org/wiki/Sigrok-cli")
247 (synopsis "Command-line frontend for sigrok")
248 (description "Sigrok-cli is a command-line frontend for sigrok.")
249 (license license:gpl3+)))
250
251 (define-public openboardview
252 (package
253 (name "openboardview")
254 (version "8.95.1")
255 (source (origin
256 (method git-fetch)
257 (uri (git-reference
258 (url "https://github.com/OpenBoardView/OpenBoardView")
259 (commit version)
260 (recursive? #t))) ;for the "src/imgui" submodule
261 (file-name (git-file-name name version))
262 (modules '((ice-9 ftw)
263 (srfi srfi-26)
264 (guix build utils)))
265 (snippet
266 '(with-directory-excursion "src"
267 ;; Keep the bundled ImGui for now, as in the current version
268 ;; (~1.79), it requires the glad loader generated at build
269 ;; time as an input.
270 (define keep (list "." ".." "imgui" "openboardview"))
271 (for-each (lambda (f)
272 (when (eq? 'directory (stat:type (lstat f)))
273 (delete-file-recursively f)))
274 (scandir "." (negate (cut member <> keep))))))
275 (patches
276 (search-patches "openboardview-use-system-utf8.patch"))
277 (sha256
278 (base32
279 "16mrs7bimwp8a8lb2wqhfisy6j0hl9574l4h9yb66v46aglvmd3h"))))
280 (build-system cmake-build-system)
281 (arguments
282 (list
283 #:tests? #f ;no test suite
284 #:imported-modules `((guix build glib-or-gtk-build-system)
285 ,@%cmake-build-system-modules)
286 #:modules '((guix build cmake-build-system)
287 (guix build utils)
288 ((guix build glib-or-gtk-build-system) #:prefix gtk:))
289 #:phases
290 #~(modify-phases %standard-phases
291 (add-after 'unpack 'remove-timestamps
292 (lambda _
293 ;; The __TIMESTAMP__ CPP macro does apparently not honor
294 ;; SOURCE_EPOCH_DATE. Patch it to use __DATE__ instead, which
295 ;; does (see:
296 ;; https://github.com/OpenBoardView/OpenBoardView/issues/229 and
297 ;; https://issues.guix.gnu.org/53647).
298 (substitute* '("src/openboardview/BoardView.cpp"
299 "src/openboardview/main_opengl.cpp")
300 (("__TIMESTAMP__")
301 "__DATE__"))))
302 (add-before 'configure 'configure-glad
303 (lambda* (#:key inputs #:allow-other-keys)
304 (substitute* "src/CMakeLists.txt"
305 (("add_subdirectory\\(glad\\)")
306 (string-append
307 ;; Configure Glad to use static Khronos XML specifications
308 ;; instead of attempting to fetch them from the Internet.
309 "option(GLAD_REPRODUCIBLE \"Reproducible build\" ON)\n"
310 ;; Use the CMake files from our glad package.
311 "add_subdirectory("
312 (search-input-directory inputs "share/glad") ;source_dir
313 " src/glad)\n"))))) ;binary dir
314 (add-before 'configure 'fix-utf8-include-directive
315 ;; Our utf8-h package makes the header available as "utf8.h"
316 ;; directly rather than "utf8/utf8.h".
317 (lambda _
318 (substitute* '("src/openboardview/FileFormats/BRDFile.cpp"
319 "src/openboardview/BoardView.cpp")
320 (("utf8/utf8.h") "utf8.h"))))
321 (add-before 'configure 'dynamically-load-gtk-via-absolute-path
322 ;; The GTK library is not linked thus not present in the RUNPATH of
323 ;; the produced binary; the absolute path of the libraries must to
324 ;; the dynamic loader otherwise they aren't found.
325 (lambda* (#:key inputs #:allow-other-keys)
326 (substitute* "src/openboardview/unix.cpp"
327 (("libgtk-3.so")
328 (search-input-file inputs "lib/libgtk-3.so")))))
329 ;; Add the two extra phases from `glib-or-gtk-build-system'.
330 (add-after 'install 'glib-or-gtk-compile-schemas
331 (assoc-ref gtk:%standard-phases 'glib-or-gtk-compile-schemas))
332 (add-after 'install 'glib-or-gtk-wrap
333 (assoc-ref gtk:%standard-phases 'glib-or-gtk-wrap)))))
334 (native-inputs
335 (list pkg-config
336 python
337 glad
338 stb-image
339 utf8-h))
340 (inputs
341 (list fontconfig
342 gtk+
343 sdl2
344 sqlite
345 zlib))
346 (home-page "https://openboardview.org/")
347 (synopsis "Viewer for BoardView files")
348 (description "OpenBoardView is a viewer for BoardView files, which present
349 the details of a printed circuit board (PCB). It comes with features
350 such as:
351 @itemize
352 @item Dynamic part outline rendering, including complex connectors
353 @item Annotations, for leaving notes about parts, nets, pins or location
354 @item Configurable colour themes
355 @item Configurable DPI to facilitate usage on 4K monitors
356 @item Configurable for running on slower systems
357 @item Reads FZ (with key), BRD, BRD2, BDV and BV* formats.
358 @end itemize")
359 (license license:expat)))
360
361 (define-public pulseview
362 (package
363 (name "pulseview")
364 (version "0.4.2")
365 (source (origin
366 (method url-fetch)
367 (uri (string-append
368 "https://sigrok.org/download/source/pulseview/pulseview-"
369 version ".tar.gz"))
370 (sha256
371 (base32
372 "1jxbpz1h3m1mgrxw74rnihj8vawgqdpf6c33cqqbyd8v7rxgfhph"))
373 (patches (search-patches "pulseview-qt515-compat.patch"
374 "pulseview-glib-2.68.patch"))))
375 (build-system cmake-build-system)
376 (arguments
377 `(#:tests? #f ;format_time_minutes_test is failing
378 #:phases
379 (modify-phases %standard-phases
380 (add-after 'install 'remove-empty-doc-directory
381 (lambda* (#:key outputs #:allow-other-keys)
382 (let ((out (assoc-ref outputs "out")))
383 (with-directory-excursion (string-append out "/share")
384 ;; Use RMDIR to never risk silently deleting files.
385 (rmdir "doc/pulseview")
386 (rmdir "doc"))))))))
387 (native-inputs
388 (list pkg-config qttools))
389 (inputs
390 (list boost
391 glib
392 glibmm
393 libsigrok
394 libsigrokdecode
395 qtbase-5
396 qtsvg))
397 (home-page "https://www.sigrok.org/wiki/PulseView")
398 (synopsis "Qt based logic analyzer, oscilloscope and MSO GUI for sigrok")
399 (description "PulseView is a Qt based logic analyzer, oscilloscope and MSO GUI
400 for sigrok.")
401 (license license:gpl3+)))
402
403 (define-public comedilib
404 (package
405 (name "comedilib")
406 (version "0.12.0")
407 (source (origin
408 (method url-fetch)
409 (uri (string-append "https://www.comedi.org/download/comedilib-"
410 version ".tar.gz"))
411 (sha256
412 (base32
413 "0wzh23iyix4xj211fsd8hwrdcjhg2w5jswk9kywb1gpd3h8afajj"))))
414 (build-system gnu-build-system)
415 (synopsis "Library for Comedi")
416 (description "Comedilib is a user-space library that provides a
417 developer-friendly interface to Comedi devices. Comedi is a collection of
418 drivers for a variety of common data acquisition plug-in boards. The drivers
419 are implemented as a core Linux kernel module providing common functionality and
420 individual low-level driver modules.")
421 (home-page "https://www.comedi.org/")
422 (license license:lgpl2.1)))
423
424 (define-public xoscope
425 (package
426 (name "xoscope")
427 (version "2.3")
428 (source (origin
429 (method url-fetch)
430 (uri (string-append "mirror://sourceforge/xoscope/xoscope/"
431 version "/xoscope-" version ".tar.gz"))
432 (sha256
433 (base32
434 "0a5ycfc1qdmibvagc82r2mhv2i99m6pndy5i6ixas3j2297g6pgq"))))
435 (build-system gnu-build-system)
436 (native-inputs
437 (list m4 pkg-config))
438 (inputs
439 (list alsa-lib comedilib fftw gtk+ gtkdatabox))
440 (synopsis "Digital oscilloscope")
441 (description "Xoscope is a digital oscilloscope that can acquire signals
442 from ALSA, ESD, and COMEDI sources. This package currently does not include
443 support for ESD sources.")
444 (home-page "http://xoscope.sourceforge.net/")
445 (license license:gpl2+)))