projects/guix·blob python-team · refs

2530 lines · 108.3 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2014-2016, 2024 Ludovic Courtès <[email protected]>
3;;; Copyright © 2016 Eric Bavier <[email protected]>
4;;; Copyright © 2017 David Craven <[email protected]>
5;;; Copyright © 2017, 2018, 2022-2025 Efraim Flashner <[email protected]>
6;;; Copyright © 2018, 2020, 2021, 2022 Tobias Geerinckx-Rice <[email protected]>
7;;; Copyright © 2018, 2019 Vagrant Cascadian <[email protected]>
8;;; Copyright © 2019 Mathieu Othacehe <[email protected]>
9;;; Copyright © 2020 Jakub Kądziołka <[email protected]>
10;;; Copyright © 2020, 2021, 2022 Marius Bakke <[email protected]>
11;;; Copyright © 2021 Petr Hodina <[email protected]>
12;;; Copyright © 2021-2023, 2025-2026 Maxim Cournoyer <[email protected]>
13;;; Copyright © 2023 Hilton Chain <[email protected]>
14;;; Copyright © 2023 Foundation Devices, Inc. <[email protected]>
15;;; Copyright © 2023, 2024 Zheng Junjie <[email protected]>
16;;; Copyright © 2024 Ricardo Wurmus <[email protected]>
17;;; Copyright © 2025 Simen Endsjø <[email protected]>
18;;; Copyright © 2025 Murilo <[email protected]>
19;;;
20;;; This file is part of GNU Guix.
21;;;
22;;; GNU Guix is free software; you can redistribute it and/or modify it
23;;; under the terms of the GNU General Public License as published by
24;;; the Free Software Foundation; either version 3 of the License, or (at
25;;; your option) any later version.
26;;;
27;;; GNU Guix is distributed in the hope that it will be useful, but
28;;; WITHOUT ANY WARRANTY; without even the implied warranty of
29;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30;;; GNU General Public License for more details.
31;;;
32;;; You should have received a copy of the GNU General Public License
33;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
34
35(define-module (gnu packages firmware)
36 #:use-module ((guix licenses) #:prefix license:)
37 #:use-module (guix memoization)
38 #:use-module (guix deprecation)
39 #:use-module (guix packages)
40 #:use-module (guix platform)
41 #:use-module (guix download)
42 #:use-module (guix gexp)
43 #:use-module (guix utils)
44 #:use-module (guix git-download)
45 #:use-module (guix build-system cargo)
46 #:use-module (guix build-system copy)
47 #:use-module (guix build-system cmake)
48 #:use-module (guix build-system gnu)
49 #:use-module (guix build-system meson)
50 #:use-module (guix build-system pyproject)
51 #:use-module (guix build-system trivial)
52 #:use-module (gnu packages)
53 #:use-module (gnu packages admin)
54 #:use-module (gnu packages autotools)
55 #:use-module (gnu packages avr)
56 #:use-module (gnu packages avr-xyz)
57 #:use-module (gnu packages assembly)
58 #:use-module (gnu packages backup)
59 #:use-module (gnu packages base)
60 #:use-module (gnu packages bash)
61 #:use-module (gnu packages bison)
62 #:use-module (gnu packages check)
63 #:use-module (gnu packages cmake)
64 #:use-module (gnu packages compression)
65 #:use-module (gnu packages cross-base)
66 #:use-module (gnu packages curl)
67 #:use-module (gnu packages efi)
68 #:use-module (gnu packages elf)
69 #:use-module (gnu packages embedded)
70 #:use-module (gnu packages flashing-tools)
71 #:use-module (gnu packages compiler-tools)
72 #:use-module (gnu packages fontutils)
73 #:use-module (gnu packages freedesktop)
74 #:use-module (gnu packages gawk)
75 #:use-module (gnu packages gcc)
76 #:use-module (gnu packages gettext)
77 #:use-module (gnu packages glib)
78 #:use-module (gnu packages gnome)
79 #:use-module (gnu packages gtk)
80 #:use-module (gnu packages hardware)
81 #:use-module (gnu packages libusb)
82 #:use-module (gnu packages linux)
83 #:use-module (gnu packages man)
84 #:use-module (gnu packages mingw)
85 #:use-module (gnu packages package-management)
86 #:use-module (gnu packages perl)
87 #:use-module (gnu packages pkg-config)
88 #:use-module (gnu packages polkit)
89 #:use-module (gnu packages protobuf)
90 #:use-module (gnu packages python)
91 #:use-module (gnu packages python-build)
92 #:use-module (gnu packages python-xyz)
93 #:use-module (gnu packages shells)
94 #:use-module (gnu packages sqlite)
95 #:use-module (gnu packages tls)
96 #:use-module (gnu packages version-control)
97 #:use-module (gnu packages xml)
98 #:use-module (ice-9 format)
99 #:use-module (ice-9 match)
100 #:autoload (ice-9 pretty-print) (pretty-print)
101 #:use-module (ice-9 regex)
102 #:autoload (ice-9 textual-ports) (get-string-all)
103 #:use-module (srfi srfi-26)
104
105 #:export (make-ergodox-firmware
106 make-qmk-firmware))
107
108(define-public ath9k-htc-ar7010-firmware
109 (package
110 (name "ath9k-htc-ar7010-firmware")
111 (version "1.4.0")
112 (source (origin
113 (method git-fetch)
114 (uri (git-reference
115 (url "https://github.com/qca/open-ath9k-htc-firmware")
116 (commit version)))
117 (modules '((guix build utils)))
118 (snippet
119 ;; Delete binary blobs.
120 #~(for-each delete-file (find-files "." "\\.(a|o)$")))
121 (sha256
122 (base32
123 "16jbj8avg5jkgvq5lxm0hdxxn4c3zn7fx8b4nxllvr024apk9w23"))
124 (file-name (git-file-name "open-ath9k-htc-firmware" version))
125 (patches (search-patches "ath9k-htc-firmware-gcc-compat.patch"))))
126 (build-system cmake-build-system)
127 (arguments
128 (list #:target "xtensa-ath9k-elf"
129 #:tests? #f
130 #:configure-flags
131 #~'("-DCMAKE_C_FLAGS=-Wno-error=implicit-function-declaration"
132 "-DTARGET_MAGPIE=ON")
133 #:phases
134 #~(modify-phases %standard-phases
135 (add-before 'configure 'change-directory
136 (lambda _
137 (chdir "target_firmware")))
138 (replace 'install
139 (lambda _
140 (let ((fw-dir (string-append #$output "/lib/firmware")))
141 (for-each (lambda (file)
142 (install-file file fw-dir))
143 (find-files "." "\\.fw$"))))))))
144 (native-inputs (list perl))
145 (home-page "https://wireless.wiki.kernel.org/en/users/Drivers/ath9k_htc")
146 (synopsis "Firmware for the Atheros AR7010 USB 802.11n NICs")
147 (description
148 "This is the firmware for the Qualcomm Atheros AR7010 802.11n USB NICs
149(aka Wi-Fi USB dongle). It is used by the ath9k driver of Linux-libre.")
150 (license (license:non-copyleft "http://directory.fsf.org/wiki/License:ClearBSD"))))
151
152(define-public ath9k-htc-ar9271-firmware
153 (package
154 (inherit ath9k-htc-ar7010-firmware)
155 (name "ath9k-htc-ar9271-firmware")
156 (arguments
157 (substitute-keyword-arguments
158 (package-arguments ath9k-htc-ar7010-firmware)
159 ((#:configure-flags flags)
160 #~'("-DCMAKE_C_FLAGS=-Wno-error=implicit-function-declaration"
161 "-DTARGET_K2=ON"))))
162 (synopsis "Firmware for the Atheros AR9271 USB 802.11n NICs")
163 (description
164 "This is the firmware for the Qualcomm Atheros AR9271 802.11n USB NICs
165(aka Wi-Fi USB dongle). It is used by the ath9k driver of Linux-libre.")))
166
167(define-public b43-tools
168 (let ((commit "27892ef741e7f1d08cb939744f8b8f5dac7b04ae")
169 (revision "1"))
170 (package
171 (name "b43-tools")
172 (version (git-version "0.0.0" revision commit))
173 (source
174 (origin
175 (method git-fetch)
176 (uri (git-reference
177 (url "http://git.bues.ch/git/b43-tools.git")
178 (commit commit)))
179 (file-name (git-file-name name version))
180 (sha256
181 (base32
182 "1wgmj4d65izbhprwb5bcwimc2ryv19b9066lqzy4sa5m6wncm9cn"))))
183 (build-system gnu-build-system)
184 (native-inputs
185 (list flex bison))
186 (arguments
187 `(#:modules ((srfi srfi-1)
188 (guix build gnu-build-system)
189 (guix build utils))
190 #:tests? #f ; no tests
191 #:make-flags `(,(string-append "PREFIX=" (assoc-ref %outputs "out"))
192 ,(string-append "CC=" ,(cc-for-target)))
193 #:phases
194 (let ((subdirs '("assembler" "disassembler")))
195 (modify-phases %standard-phases
196 (delete 'configure) ; no configure script
197 (add-before 'build 'patch-/bin/true
198 (lambda _
199 (substitute* (find-files "." "Makefile")
200 (("/bin/true") ":"))))
201 (replace 'build
202 (lambda* (#:key (make-flags '()) #:allow-other-keys)
203 (for-each (lambda (dir)
204 (apply invoke "make" "-C" dir make-flags))
205 subdirs)))
206 (replace 'install
207 (lambda* (#:key outputs (make-flags '()) #:allow-other-keys)
208 (let ((out (assoc-ref outputs "out")))
209 (mkdir-p (string-append out "/bin"))
210 (for-each (lambda (dir)
211 (apply invoke "make" "-C" dir "install" make-flags))
212 subdirs))))))))
213 (home-page
214 "https://bues.ch/cms/hacking/misc.html#linux_b43_driver_firmware_tools")
215 (synopsis "Collection of tools for the b43 wireless driver")
216 (description
217 "The b43 firmware tools is a collection of firmware extractor,
218assembler, disassembler, and debugging tools for the Linux kernel b43 wireless
219driver.")
220 (license license:gpl2))))
221
222(define-public binwalk
223 (package
224 (name "binwalk")
225 (version "3.1.0")
226 (source
227 (origin
228 (method git-fetch)
229 (uri (git-reference
230 (url "https://github.com/ReFirmLabs/binwalk")
231 (commit (string-append "v" version))))
232 (file-name (git-file-name name version))
233 (sha256
234 (base32 "1jm1zx8jfj7fsxa87rkbq0qjjb66wqqmvqcs2127wr22g0xa6vvs"))))
235 (build-system cargo-build-system)
236 (arguments
237 (list
238 #:install-source? #f
239 ;; Tests are racy (see
240 ;; <https://github.com/ReFirmLabs/binwalk/issues/963>).
241 #:parallel-tests? #f
242 ;; These tests fail on the v3.1.0 release.
243 ;; They will be most likely fixed on the next release, where the
244 ;; test files are included in the source itself.
245 ;; See <https://github.com/ReFirmLabs/binwalk/issues/882>.
246 #:cargo-test-flags ''("--"
247 "--skip=binwalk::Binwalk"
248 "--skip=binwalk::Binwalk::scan"
249 "--skip=binwalk::Binwalk::analyze"
250 "--skip=binwalk::Binwalk::extract")))
251 (native-inputs (list pkg-config))
252 (inputs (cons* fontconfig xz
253 (cargo-inputs 'binwalk)))
254 (home-page "https://github.com/ReFirmLabs/binwalk")
255 (synopsis "Firmware analysis tool")
256 (description "Binwalk is a tool for analyzing, reverse engineering, and
257extracting firmware images.")
258 (license license:expat)))
259
260(define-public fwupd-efi
261 (package
262 (name "fwupd-efi")
263 (version "1.7")
264 (source
265 (origin
266 (method git-fetch)
267 (uri (git-reference
268 (url "https://github.com/fwupd/fwupd-efi")
269 (commit version)))
270 (file-name (git-file-name name version))
271 (sha256
272 (base32 "0n4v6pyg8fmrasdplkb03vjklqhp2k0zn9l8hmjfgibbf6g6mi9x"))))
273 (build-system meson-build-system)
274 (arguments
275 `(#:configure-flags
276 ,#~(list (string-append
277 "-Defi-libdir=" #$(this-package-input "gnu-efi") "/lib")
278 (string-append
279 "-Defi-includedir=" #$(this-package-input "gnu-efi") "/include/efi")
280 (string-append
281 "-Dpython=" #+(this-package-native-input "python") "/bin/python3")
282 "-Dgenpeimg=enabled")))
283 (native-inputs (list pkg-config python mingw-w64-tools))
284 (inputs (list gnu-efi))
285 (home-page "https://fwupd.org/")
286 (synopsis "EFI Application used by uefi-capsule plugin in fwupd")
287 (description "This package provides an EFI executable for fwupd, which is
288used in the process of installing and updating firmware.")
289 (license license:lgpl2.1+)))
290
291(define-public fwupd
292 (package
293 (name "fwupd")
294 (version "1.9.32")
295 (source (origin
296 (method git-fetch)
297 (uri (git-reference
298 (url "https://github.com/fwupd/fwupd")
299 (commit version)))
300 (file-name (git-file-name name version))
301 (sha256
302 (base32
303 "0nabjgskbpinj7sj44kblnd8g6psppas4g8qgajfs3p19skp07y1"))))
304 (build-system meson-build-system)
305 (arguments
306 (list
307 #:configure-flags #~(list "--wrap-mode=nofallback"
308 "-Dsystemd=false"
309 (string-append "-Defi_os_dir="
310 #$gnu-efi "/lib")
311 "-Defi_binary=false"
312 (string-append "-Dudevdir="
313 #$output "/lib/udev")
314 "--localstatedir=/var"
315 (string-append "--libexecdir="
316 #$output "/libexec")
317 "-Dsupported_build=true"
318 ;; Disable LVFS, because it contains
319 ;; nonfree firmwares.
320 "-Dlvfs=disabled")
321 #:glib-or-gtk? #t ;To wrap binaries and/or compile schemas
322 #:phases
323 #~(modify-phases %standard-phases
324 (add-after 'unpack 'make-source-writable
325 (lambda _
326 (for-each (lambda (file)
327 ;; Skip symlinks as `make-file-writable' fails for those.
328 (unless (eq? 'symlink (stat:type (lstat file)))
329 (format #t "Make writable: ~A~%" file)
330 (make-file-writable file)))
331 (find-files "."))
332 (substitute* "src/fu-self-test.c"
333 (("/bin/sh")
334 (which "sh")))
335 ;; fwupdmgr checks for missing polkit actions, prints
336 ;; error message and exits if the polkit actions are
337 ;; not found.
338 ;; The path points to gnu store path of polkit and
339 ;; there are no actions there. Point this to the actual
340 ;; location used on Guix System. This will still fail on
341 ;; foreign distros as /usr/share/polkit-1 is used mostly.
342 (substitute* "src/fu-util.c"
343 (("g_autofree gchar \\*directory = NULL;")
344 "")
345 (("directory = fu_path_from_kind\\(FU_PATH_KIND_POLKIT_ACTIONS\\)")
346 "const gchar* directory = \"/etc/polkit-1/actions\""))))
347 ;; These two files are zipped by Python, so need a newer timestamp.
348 (add-after 'unpack 'newer-timestamps-for-python-zip
349 (lambda _
350 (let ((circa-1980 (* 10 366 24 60 60)))
351 (for-each (lambda (file)
352 (make-file-writable file)
353 (utime file circa-1980 circa-1980))
354 '("./libfwupdplugin/tests/colorhug/firmware.bin"
355 "./libfwupdplugin/tests/colorhug/firmware.bin.asc")))))
356 (add-before 'build 'setup-home
357 (lambda _
358 (setenv "HOME" "/tmp")))
359 (add-before 'install 'no-polkit-magic
360 (lambda _
361 (setenv "PKEXEC_UID" "something")))
362 (add-after 'install 'ensure-all-remotes-are-disabled
363 ;; Because no remote currently promises to offer only free
364 ;; software firmwares, disable them to prevent a user to
365 ;; unknowingly install proprietary firmware updates.
366 (lambda _
367 (substitute* (find-files (string-append #$output "/etc")
368 "\\.conf$")
369 (("Enabled=true")
370 "Enabled=false"))))
371 (add-after 'glib-or-gtk-wrap 'install-fwupd.efi
372 ;; fwupd looks for its .efi file within its own prefix, so link
373 ;; the directory containing the arch-specific executable here.
374 ;; If we install a symlink to the efi directory before
375 ;; 'glib-or-gtk-wrap, then the wrapping procedure mistakes the
376 ;; directory symlink for an executable and tries to wrap it.
377 (lambda _
378 (symlink (string-append #$(this-package-input "fwupd-efi")
379 "/libexec/fwupd/efi")
380 (string-append #$output "/libexec/fwupd/efi")))))))
381 (native-inputs (list gobject-introspection
382 python-jinja2
383 python-pygobject
384 python-pillow
385 python-pycairo
386 python
387 pkg-config
388 vala
389 gtk-doc
390 which
391 umockdev
392 `(,glib "bin")
393 help2man
394 gettext-minimal))
395 (inputs (append
396 (list bash-completion
397 elogind
398 libgudev
399 libxmlb
400 sqlite
401 polkit
402 eudev
403 libelf
404 tpm2-tss
405 cairo
406 efivar
407 pango
408 protobuf-c
409 fwupd-efi
410 mingw-w64-tools
411 gnu-efi)
412 (if (supported-package? libsmbios
413 (or (and=> (%current-target-system)
414 platform-target->system)
415 (%current-system)))
416 (list libsmbios)
417 '())))
418 ;; In Requires of fwupd*.pc.
419 (propagated-inputs (list curl
420 gcab
421 glib
422 gnutls
423 gusb
424 json-glib
425 libarchive
426 libjcat))
427 (home-page "https://fwupd.org/")
428 (synopsis "Daemon to allow session software to update firmware")
429 (description "This package aims to make updating firmware on GNU/Linux
430automatic, safe and reliable. It is used by tools such as GNOME Software.")
431 (license license:lgpl2.1+)))
432
433(define-public openfwwf-firmware
434 (package
435 (name "openfwwf-firmware")
436 (version "5.2")
437 (source
438 (origin
439 (method url-fetch)
440 (uri (string-append "http://netweb.ing.unibs.it/~openfwwf/firmware/"
441 "openfwwf-" version ".tar.gz"))
442 (sha256
443 (base32
444 "1p60gdi7w88s7qw82d3g9v7mk887mhvidf4l5q5hh09j10h37q4x"))))
445 (build-system gnu-build-system)
446 (native-inputs
447 (list b43-tools))
448 (arguments
449 `(#:make-flags (list (string-append "PREFIX="
450 (assoc-ref %outputs "out")
451 "/lib/firmware/b43-open"))
452 #:target #f ; Package produces firmware.
453 #:tests? #f ;no tests
454 #:phases (modify-phases %standard-phases
455 (delete 'configure))))
456 (home-page "http://netweb.ing.unibs.it/~openfwwf/")
457 (synopsis "Firmware for BCM43xx devices")
458 (description
459 "This is firmware from Open FirmWare for WiFi networks (OpenFWWF) for the
460Broadcom/AirForce chipset BCM43xx with Wireless-Core Revision 5. It is used
461by the b43-open driver of Linux-libre.")
462 (license license:gpl2)))
463
464(define-public eg25-manager
465 (package
466 (name "eg25-manager")
467 (version "0.5.2")
468 (source (origin
469 (method git-fetch)
470 (uri (git-reference
471 (url "https://gitlab.com/mobian1/devices/eg25-manager")
472 (commit version)))
473 (file-name (git-file-name name version))
474 (sha256
475 (base32
476 "0fq10y01iz7lfp27c1sqqqyg7qr8xyfs1ly5c97vqqk6k4kbwxk6"))))
477 (build-system meson-build-system)
478 (arguments
479 (list
480 #:phases
481 #~(modify-phases %standard-phases
482 (add-after 'unpack 'patch-path
483 (lambda* (#:key inputs #:allow-other-keys)
484 (substitute* "udev/80-modem-eg25.rules"
485 (("/bin/grep") (search-input-file inputs "/bin/grep"))))))))
486 (native-inputs (list curl
487 `(,glib "bin") pkg-config))
488 (inputs (list grep libgpiod libgudev libusb))
489 (synopsis "Manager daemon for the Quectel EG25 mobile broadband modem")
490 (description
491 "This package provides a manager daemon for the Quectel EG25 mobile
492broadband modem as found, for example, on PinePhone.")
493 (home-page "https://gitlab.com/mobian1/devices/eg25-manager")
494 (license license:gpl3+)))
495
496(define-public fcode-utils
497 (package
498 (name "fcode-utils")
499 (version "1.0.3")
500 (source
501 (origin
502 (method git-fetch)
503 (uri (git-reference
504 (url "https://github.com/openbios/fcode-utils")
505 (commit (string-append "v" version))))
506 (file-name (git-file-name name version))
507 (sha256
508 (base32 "0yyqmiqvlf644jrv8x39aqdqywdnm80k62d2assgcammwbc7krya"))))
509 (build-system gnu-build-system)
510 (arguments
511 (list
512 #:test-target "tests"
513 #:make-flags
514 #~(list (string-append "CC=" #$(cc-for-target))
515 (string-append "STRIP=" #$(strip-for-target))
516 (string-append "DESTDIR=" #$output))
517 #:phases
518 #~(modify-phases %standard-phases
519 (delete 'configure)))) ; No configure script.
520 (native-inputs
521 (list tcsh))
522 (home-page "https://www.openfirmware.info/FCODE_suite")
523 (synopsis "Utilities to process FCODE, OpenFirmware's byte code")
524 (description "This is the OpenBIOS FCODE suite. It contains a set of
525utilities used to process FCODE, OpenFirmware's byte code, consisting of:
526@enumerate
527@item toke - A tokenizer
528@item detok - A detokenizer
529@item romheaders - A PCI rom header utility
530@item localvalues - A portable implementation of Forth local values
531@end enumerate")
532 (license (list license:gpl2
533 ;; localvalues implementation and some documentation.
534 license:cpl1.0))))
535
536(define* (make-openbios-package name arch)
537 (let ((target (cond
538 ((string-suffix? "ppc" arch)
539 "powerpc-linux-gnu")
540 ((string-suffix? "amd64" arch)
541 "x86_64-linux-gnu")
542 ((string-suffix? "x86" arch)
543 "i686-linux-gnu")
544 (else (string-append arch "-linux-gnu"))))
545 ;; 1.1 was released in May 2013.
546 (commit "c3a19c1e54977a53027d6232050e1e3e39a98a1b")
547 (revision "2"))
548 (package
549 (name name)
550 (version (git-version "1.1" revision commit))
551 (source (origin
552 (method git-fetch)
553 (uri (git-reference
554 (url "https://github.com/openbios/openbios")
555 (commit commit)))
556 (file-name (git-file-name "openbios" version))
557 (sha256
558 (base32
559 "00a6lpbmknvy5qr8q3y2gd0mmv1lywmhch2fgssyhq7nczb6f34r"))
560 (patches (search-patches "openbios-aarch64-riscv64-support.patch"))))
561 (build-system gnu-build-system)
562 (arguments
563 (list #:tests? #f ;no tests
564 #:phases
565 #~(modify-phases %standard-phases
566 (add-after 'unpack 'build-reproducibly
567 (lambda _
568 (substitute* "Makefile.target"
569 (("TZ=UTC date \\+")
570 "TZ=UTC date --date=@1 +"))))
571 (replace 'configure
572 (lambda* (#:key (configure-flags #~'()) #:allow-other-keys)
573 (apply invoke "./config/scripts/switch-arch" #$arch
574 configure-flags)))
575 (replace 'install
576 (lambda _
577 (let ((build-target
578 (if (string-contains #$arch "-")
579 (car (reverse (string-split #$arch #\-)))
580 #$arch)))
581 (for-each (lambda (elf)
582 (install-file elf
583 (string-append #$output
584 "/share/firmware")))
585 (find-files (string-append "obj-" build-target)
586 "\\.elf$"))))))))
587 (native-inputs
588 (append (if (string-prefix? (%current-system) target)
589 '()
590 (list (cross-gcc target) (cross-binutils target)))
591 (list fcode-utils libxslt which)))
592 (home-page "https://openfirmware.info/Welcome_to_OpenBIOS")
593 (synopsis "Open Firmware implementation")
594 (description
595 "OpenBIOS is an implementation of the IEEE 1275-1994 \"Open Firmware\"
596specification. It can be used as a system firmware, as a boot loader, or
597provide OpenFirmware functionality on top of an already running system.")
598 ;; Some files are GPLv2 only.
599 (license license:gpl2))))
600
601(define-public openbios-qemu-ppc
602 (let ((base (make-openbios-package "openbios-qemu-ppc" "qemu-ppc")))
603 (package
604 (inherit base)
605 (arguments
606 (substitute-keyword-arguments arguments
607 ;; No need to cross-compile, package produces reproducible firmware.
608 ((#:target _ #f) #f)
609 ((#:phases phases)
610 #~(modify-phases #$phases
611 (add-after 'install 'rename-executable
612 (lambda _
613 (with-directory-excursion #$output
614 (rename-file "share/firmware" "share/qemu")
615 (rename-file "share/qemu/openbios-qemu.elf"
616 "share/qemu/openbios-ppc")))))))))))
617
618(define* (make-opensbi-package platform name #:optional (arch "riscv64"))
619 (package
620 (name name)
621 (version "1.8.1")
622 (source
623 (origin
624 (method git-fetch)
625 (uri (git-reference
626 (url "https://github.com/riscv-software-src/opensbi")
627 (commit (string-append "v" version))))
628 (file-name (git-file-name "opensbi" version))
629 (sha256
630 (base32 "1246phiacymk3w2sf7h5hziz68jg83gw20vk112b5ln7jx8vcgcw"))))
631 (build-system gnu-build-system)
632 (native-inputs
633 (append
634 (if (and (not (string-prefix? "riscv64" (%current-system)))
635 (string-prefix? "riscv64" arch))
636 (list (cross-gcc "riscv64-linux-gnu")
637 (cross-binutils "riscv64-linux-gnu"))
638 '())
639 (list python)))
640 (arguments
641 (list
642 #:tests? #f ; no check target
643 #:target #f ; Package produces firmware.
644 #:make-flags
645 #~(list (string-append "PLATFORM=" #$platform)
646 #$@(if (and (not (string-prefix? "riscv64" (%current-system)))
647 (string-prefix? "riscv64" arch))
648 `("CROSS_COMPILE=riscv64-linux-gnu-")
649 `("CC=gcc"))
650 "FW_PAYLOAD=n"
651 "V=1")
652 #:phases
653 #~(modify-phases %standard-phases
654 (delete 'configure)
655 (replace 'install
656 (lambda* (#:key outputs #:allow-other-keys)
657 (for-each
658 (lambda (file)
659 (install-file file #$output))
660 (find-files "." "fw_.*\\.(elf|bin)$")))))))
661 (home-page "https://github.com/riscv-software-src/opensbi")
662 (synopsis "RISC-V @acronym{SBI, Supervisor Binary Interface} implementation")
663 (description
664 "OpenSBI is the reference implementation of the RISC-V @acronym{SBI,
665Supervisory Binary Interface} specifications for platform-specific firmwares
666executing in M-mode.")
667 (license (list license:bsd-2
668 ;; lib/utils/libfdt/* is dual licensed under bsd-2 and gpl2+.
669 license:gpl2+
670 ;; platform/ariane-fpga/* is gpl2.
671 license:gpl2))))
672
673(define-public opensbi-generic
674 (make-opensbi-package "generic" "opensbi-generic"))
675
676(define-public opensbi-qemu
677 (package
678 (inherit opensbi-generic)
679 (name "opensbi-qemu")
680 (native-inputs '())
681 (inputs (list opensbi-generic))
682 (build-system trivial-build-system)
683 (arguments
684 (list #:modules '((guix build utils))
685 #:builder
686 #~(begin
687 (use-modules ((guix build utils)))
688 (let ((opensbi-riscv64 (search-input-file %build-inputs
689 "fw_dynamic.bin"))
690 (out (string-append #$output "/share/qemu")))
691 (mkdir-p out)
692 (symlink opensbi-riscv64
693 (string-append
694 out "/opensbi-riscv64-generic-fw_dynamic.bin"))))))
695 (synopsis "OpenSBI firmware files for QEMU")
696 (description
697 "This package contains OpenSBI firmware files for use with QEMU.")))
698
699(define-public opensbi-for-visionfive2
700 (package
701 (inherit opensbi-generic)
702 (name "opensbi-for-visionfive2")
703 (arguments
704 (substitute-keyword-arguments
705 (package-arguments opensbi-generic)
706 ((#:make-flags flags)
707 ;; visionfive2's u-boot need opensbi with the following flags.
708 ;; see https://docs.u-boot.org/en/latest/board/starfive/visionfive2.html
709 #~(cons* "FW_TEXT_START=0x40000000"
710 "FW_OPTIONS=0"
711 #$flags))))))
712
713(define-public seabios
714 (package
715 (name "seabios")
716 (version "1.17.0")
717 (source
718 (origin
719 (method git-fetch)
720 (uri (git-reference
721 (url "https://review.coreboot.org/seabios.git")
722 (commit (string-append "rel-" version))))
723 (file-name (git-file-name name version))
724 (sha256
725 (base32 "0v4rsv2mh6rmb9n2fc1df439z16qgmnkbv0vb5ylmpqzqfbjjd3q"))
726 (modules '((guix build utils)))
727 (snippet
728 #~(begin
729 ;; Delete IASL-generated files.
730 (for-each delete-file (find-files "." "\\.hex$"))))))
731 (build-system gnu-build-system)
732 (native-inputs
733 (list acpica python-wrapper))
734 (arguments
735 (list
736 #:tests? #f ;no tests
737 #:target #f ; Package produces firmware.
738 #:make-flags
739 ;; If EXTRAVERSION is not set the build system will embed the current
740 ;; date in binaries. Use this opportunity to personalize as recommended
741 ;; by Build_overview.md.
742 #~'("EXTRAVERSION=/GNU Guix"
743 "V=1") ;build verbosely
744 #:phases
745 #~(modify-phases %standard-phases
746 (replace 'configure
747 (lambda _
748 ;; Ensure this file is present in case we're building from a git
749 ;; checkout instead of release tarball.
750 (call-with-output-file ".version"
751 (lambda (port)
752 (format port #$(package-version this-package))))
753 ;; If we use (cc-for-target) then we have the system prefix
754 ;; twice or we might have the wrong prefix.
755 (setenv "CC" "gcc")))
756 (replace 'install
757 (lambda _
758 (install-file "out/bios.bin"
759 (string-append #$output "/share/firmware")))))))
760 (home-page "https://www.seabios.org/")
761 (synopsis "BIOS implementation")
762 (description "SeaBIOS is an implementation of a 16bit x86 BIOS. SeaBIOS
763can run in an emulator or it can run natively on X86 hardware with the use of
764coreboot.")
765 (supported-systems '("i686-linux" "x86_64-linux"))
766 ;; Dual licensed.
767 (license (list license:gpl3+ license:lgpl3+
768 ;; src/fw/acpi-dsdt.dsl is lgpl2
769 license:lgpl2.1
770 ;; src/fw/lzmadecode.c and src/fw/lzmadecode.h are lgpl3+ and
771 ;; cpl with a linking exception.
772 license:cpl1.0))))
773
774(define (format-qemu-firmware-config-options config-file)
775 "Format a Scheme list of all the configuration options found in CONFIG-FILE,
776configuration file such as \"roms/config.seabios-256k\", as found in the QEMU
777source."
778 (pretty-print (map (cut string-drop <> 7) ;strip CONFIG_ prefix
779 (filter (cut string-prefix? "CONFIG_" <>)
780 (string-split
781 (string-trim-right
782 (call-with-input-file config-file
783 get-string-all))
784 #\newline)))))
785
786(define-public seabios-qemu
787 (package/inherit seabios
788 (name "seabios-qemu")
789 (native-inputs
790 (if (member (%current-system) '("i686-linux" "x86_64-linux"))
791 (package-native-inputs seabios)
792 (modify-inputs native-inputs
793 (prepend (cross-gcc "i686-linux-gnu")
794 (cross-binutils "i686-linux-gnu")))))
795 (supported-systems %supported-systems)
796 (arguments
797 (substitute-keyword-arguments arguments
798 ((#:modules modules %default-gnu-modules)
799 `((ice-9 match)
800 (ice-9 threads)
801 ,@modules))
802 ((#:phases phases)
803 #~(modify-phases #$phases
804 #$@(match (%current-system)
805 ((or "i686-linux" "x86_64-linux")
806 #~())
807 (_
808 #~((add-after 'configure 'configure-cross
809 (lambda _
810 (substitute* "Makefile"
811 (("CROSS_PREFIX=")
812 "CROSS_PREFIX=i686-linux-gnu-")))))))
813 (replace 'build
814 (lambda* (#:key (make-flags #~'()) #:allow-other-keys)
815 ;; Note: These BIOS configurations are taken from QEMUs roms/
816 ;; directory. To extract the config options, you can use the
817 ;; `format-qemu-firmware-config-options' helper procedure
818 ;; defined above.
819 (define bioses
820 '( ;; The standard BIOS using default options.
821 ("bios-256k" . ("QEMU=y" "ROM_SIZE=256" "ATA_DMA=n"))
822 ;; A minimal BIOS for old QEMU machine types.
823 ("bios-128k"
824 . ("QEMU=y"
825 "ROM_SIZE=128"
826 "ATA_DMA=n"
827 "XEN=n"
828 "ATA_PIO32=n"
829 "AHCI=n"
830 "SDCARD=n"
831 "VIRTIO_BLK=n"
832 "VIRTIO_SCSI=n"
833 "PVSCSI=n"
834 "ESP_SCSI=n"
835 "LSI_SCSI=n"
836 "MEGASAS=n"
837 "MPT_SCSI=n"
838 "NVME=n"
839 "USE_SMM=n"
840 "VGAHOOKS=n"
841 "HOST_BIOS_GEOMETRY=n"
842 "USB=n"
843 "PMTIMER=n"
844 "PCIBIOS=n"
845 "DISABLE_A20=n"
846 "WRITABLE_UPPERMEMORY=n"
847 "TCGBIOS=n"
848 "ACPI=n"
849 "ACPI_PARSE=n"
850 "DEBUG_SERIAL=n"
851 "DEBUG_SERIAL_MMIO=n"))
852 ;; Minimal BIOS for the "microvm" machine type.
853 ("bios-microvm"
854 . ("QEMU=y"
855 "QEMU_HARDWARE=y"
856 "PERMIT_UNALIGNED_PCIROM=y"
857 "ROM_SIZE=128"
858 "XEN=n"
859 "BOOTSPLASH=n"
860 "ATA=n"
861 "AHCI=n"
862 "SDCARD=n"
863 "PVSCSI=n"
864 "ESP_SCSI=n"
865 "LSI_SCSI=n"
866 "MEGASAS=n"
867 "MPT_SCSI=n"
868 "FLOPPY=n"
869 "FLASH_FLOPPY=n"
870 "NVME=n"
871 "PS2PORT=n"
872 "USB=n"
873 "LPT=n"
874 "RTC_TIMER=n"
875 "USE_SMM=n"
876 "PMTIMER=n"
877 "TCGBIOS=n"
878 "HARDWARE_IRQ=n"
879 "ACPI_PARSE=y"))
880 ("vgabios-ati"
881 . ("QEMU=y"
882 "BUILD_VGABIOS=y"
883 "VGA_ATI=y"
884 "VGA_PCI=y"))
885 ("vgabios-bochs-display"
886 . ("BUILD_VGABIOS=y"
887 "DISPLAY_BOCHS=y"
888 "VGA_PCI=y"))
889 ("vgabios-cirrus" .
890 ("BUILD_VGABIOS=y" "VGA_CIRRUS=y" "VGA_PCI=y"))
891 ("vgabios-isavga" .
892 ("BUILD_VGABIOS=y" "VGA_BOCHS=y" "VGA_PCI=n"))
893 ("vgabios-qxl"
894 . ("BUILD_VGABIOS=y"
895 "VGA_BOCHS=y"
896 "VGA_PCI=y"
897 "OVERRIDE_PCI_ID=y"
898 "VGA_VID=0x1b36"
899 "VGA_DID=0x0100"))
900 ("vgabios-ramfb" .
901 ("BUILD_VGABIOS=y" "VGA_RAMFB=y" "VGA_PCI=n"))
902 ("vgabios-stdvga" .
903 ("BUILD_VGABIOS=y" "VGA_BOCHS=y" "VGA_PCI=y"))
904 ("vgabios-virtio"
905 . ("BUILD_VGABIOS=y"
906 "VGA_BOCHS=y"
907 "VGA_PCI=y"
908 "OVERRIDE_PCI_ID=y"
909 "VGA_VID=0x1af4"
910 "VGA_DID=0x1050"))
911 ("vgabios-vmware"
912 . ("BUILD_VGABIOS=y"
913 "VGA_BOCHS=y"
914 "VGA_PCI=y"
915 "OVERRIDE_PCI_ID=y"
916 "VGA_VID=0x15ad"
917 "VGA_DID=0x0405"))))
918 (mkdir "out")
919 (n-par-for-each
920 (parallel-job-count)
921 (match-lambda
922 ((target . config)
923 (let* ((dot-config (string-append (getcwd) "/" target
924 "/.config"))
925 (flags (append
926 make-flags
927 (list (string-append "KCONFIG_CONFIG="
928 dot-config)
929 (string-append "OUT=" target "/")))))
930 (mkdir target)
931 (call-with-output-file dot-config
932 (lambda (port)
933 (for-each (lambda (entry)
934 (format port "CONFIG_~a~%" entry))
935 config)))
936 (apply invoke "make" "oldnoconfig" flags)
937 (apply invoke "make" flags)
938 (link (string-append target "/"
939 (if (string-prefix? "vgabios" target)
940 "vgabios.bin" "bios.bin"))
941 (string-append "out/" target ".bin")))))
942 bioses)))
943 (replace 'install
944 (lambda _
945 (let ((firmware (string-append #$output "/share/qemu")))
946 (for-each (lambda (bios)
947 (install-file bios firmware))
948 (find-files "out" "\\.bin$"))
949 (with-directory-excursion firmware
950 ;; Compatibility symlinks for QEMU.
951 (symlink "bios-128k.bin" "bios.bin")
952 (symlink "vgabios-isavga.bin" "vgabios.bin")))))))))))
953
954(define-public sgabios
955 ;; There are no tags in the repository.
956 (let ((commit "72f39d48bedf044e202fd51fecf3e2218fc2ae66")
957 (revision "0"))
958 (package
959 (name "sgabios")
960 (version (git-version "0.0" revision commit))
961 (home-page "https://gitlab.com/qemu-project/sgabios")
962 (source (origin
963 (method git-fetch)
964 (uri (git-reference (url home-page) (commit commit)))
965 (file-name (git-file-name name version))
966 (sha256
967 (base32
968 "0ybl021i0xaz18wzq4q13ifypy5b3dj8m11c8m0qdiq00g06vm0i"))))
969 (build-system gnu-build-system)
970 (arguments
971 (list #:make-flags
972 #~'(#$@(if (member (%current-system) '("i686-linux" "x86_64-linux"))
973 #~("CC=gcc")
974 #~("CC=i686-linux-gnu-gcc"
975 "LD=i686-linux-gnu-ld"
976 "OBJCOPY=i686-linux-gnu-objcopy"))
977 "HOSTCC=gcc")
978 #:parallel-build? #f
979 #:tests? #f ;no tests
980 #:target #f ; Package produces firmware.
981 #:phases
982 #~(modify-phases %standard-phases
983 (add-after 'unpack 'build-reproducibly
984 (lambda _
985 (substitute* "Makefile"
986 (("BUILD_DATE = .*")
987 "BUILD_DATE = \\\"Jan 1 1970\\\"\n")
988 (("BUILD_SHORT_DATE = .*")
989 "BUILD_SHORT_DATE = \\\"1/1/70\\\"\n"))))
990 (delete 'configure)
991 (replace 'install
992 (lambda _
993 (install-file "sgabios.bin"
994 (string-append #$output "/share/qemu")))))))
995 (native-inputs
996 (if (member (%current-system) '("i686-linux" "x86_64-linux"))
997 '()
998 (list (cross-gcc "i686-linux-gnu")
999 (cross-binutils "i686-linux-gnu"))))
1000 (synopsis "Serial graphics adapter BIOS")
1001 (description
1002 "SGABIOS provides a means for legacy PC software to communicate with an
1003attached serial console as if a VGA card is attached. It is designed to be
1004inserted into a BIOS as an option ROM to provide over a serial port the display
1005and input capabilities normally handled by a VGA adapter and a keyboard, and
1006additionally provide hooks for logging displayed characters for later collection
1007after an operating system boots.")
1008 (license license:asl2.0))))
1009
1010(define-public edk2-tools
1011 (package
1012 (name "edk2-tools")
1013 (version "202402")
1014 (source (origin
1015 (method git-fetch)
1016 (uri (git-reference
1017 (url "https://github.com/tianocore/edk2")
1018 (commit (string-append "edk2-stable" version))
1019 ;; EDK2 makes extensive use of submodules.
1020 (recursive? #t)))
1021 (file-name (git-file-name name version))
1022 (sha256
1023 (base32
1024 "0y7jfpijgi099znhzjklnsczn0k0vm1d1qznq9x2a2sa0glydsin"))))
1025 (build-system gnu-build-system)
1026 (arguments
1027 (list #:make-flags
1028 #~(list (string-append "BUILD_CC=" #$(cc-for-target))
1029 (string-append "CC=" #$(cc-for-target)))
1030 #:test-target "Tests"
1031 #:phases
1032 #~(modify-phases %standard-phases
1033 (add-after 'unpack 'change-directory
1034 (lambda _
1035 (chdir "BaseTools")))
1036 (replace 'build
1037 (lambda* (#:key (make-flags #~'()) #:allow-other-keys)
1038 ;; The default build target also runs tests.
1039 (apply invoke "make" "-C" "Source/C" make-flags)))
1040 (delete 'configure)
1041 (replace 'install
1042 (lambda _
1043 (mkdir #$output)
1044 (copy-recursively "Source/C/bin"
1045 (string-append #$output "/bin")))))))
1046 (native-inputs
1047 (list python-wrapper))
1048 (inputs
1049 (list `(,util-linux "lib"))) ;for libuuid
1050 (home-page
1051 "https://github.com/tianocore/tianocore.github.io/wiki/EDK-II-Tools-List")
1052 (synopsis "EFI development tools")
1053 (description
1054 "This package contains tools for processing UEFI firmware content.
1055Executables included are:
1056
1057@itemize
1058@item @code{EfiRom}: Build Option ROM images.
1059@item @code{GenFfs}: Generate FFS files.
1060@item @code{GenFv}: Generate a PI firmware volume image.
1061@item @code{GenFw}: Get image data from PE32 files.
1062@item @code{GenSec}: Generate EFI_SECTION type files.
1063@item @code{VfrCompile}: Parse preprocessed UEFI and Framework VFR files.
1064@item @code{VolInfo}: Display the contents of a firmware volume.
1065@end itemize")
1066 ;; See BaseTools/Source/C/GNUmakefile
1067 (supported-systems '("x86_64-linux" "i686-linux" "armhf-linux"
1068 "aarch64-linux" "riscv64-linux"))
1069 (license license:bsd-2)))
1070
1071(define* (make-ovmf-firmware arch)
1072 (let ((toolchain "GCC")
1073 (arch-string (match arch
1074 ("x86_64" "X64")
1075 ("i686" "IA32")
1076 ("aarch64" "AARCH64")
1077 ("armhf" "ARM")
1078 ("riscv64" "RISCV64")
1079 ("loongarch64" "LOONGARCH64")
1080 (_ "NONE"))))
1081 (package
1082 (inherit edk2-tools)
1083 (name (string-append "ovmf-" arch))
1084 (arguments
1085 (list
1086 #:tests? #f ; No check target.
1087 #:target #f ; Package produces firmware.
1088 #:modules '((guix build gnu-build-system)
1089 (guix build utils)
1090 (ice-9 match))
1091 #:phases
1092 #~(modify-phases %standard-phases
1093 (add-after 'unpack 'patch-source
1094 (lambda _
1095 (substitute* "edksetup.sh"
1096 (("^return \\$\\?")
1097 "exit $?"))))
1098 (add-before 'configure 'set-env
1099 (lambda _
1100 (unless (string-prefix? #$arch #$(%current-system))
1101 (setenv (string-append #$toolchain "_X64_PREFIX")
1102 "x86_64-linux-gnu-")
1103 (setenv (string-append #$toolchain "_IA32_PREFIX")
1104 "i686-linux-gnu-")
1105 (setenv (string-append #$toolchain "_AARCH64_PREFIX")
1106 "aarch64-linux-gnu-")
1107 (setenv (string-append #$toolchain "_ARM_PREFIX")
1108 "arm-linux-gnueabihf-")
1109 (setenv (string-append #$toolchain "_RISCV64_PREFIX")
1110 "riscv64-linux-gnu-")
1111 (setenv (string-append #$toolchain "_LOONGARCH64_PREFIX")
1112 "loongarch64-linux-gnu-"))))
1113 (replace 'configure
1114 (lambda _
1115 (let* ((cwd (getcwd))
1116 (tools (string-append cwd "/BaseTools"))
1117 (bin (string-append tools "/BinWrappers/PosixLike")))
1118 (setenv "WORKSPACE" cwd)
1119 (setenv "EDK_TOOLS_PATH" tools)
1120 (setenv "PYTHON3_ENABLE" "TRUE")
1121 (setenv "PYTHON_COMMAND" "python3")
1122 (setenv "PATH" (string-append (getenv "PATH") ":" bin))
1123 (invoke "bash" "edksetup.sh")
1124 (substitute* "Conf/target.txt"
1125 (("^TARGET[ ]*=.*$") "TARGET = RELEASE\n")
1126 (("^TOOL_CHAIN_TAG[ ]*=.*$")
1127 (string-append "TOOL_CHAIN_TAG = " #$toolchain "\n"))
1128 (("^TARGET_ARCH[ ]*=.*$")
1129 (string-append "TARGET_ARCH = " #$arch-string
1130 "\n"))
1131 (("^MAX_CONCURRENT_THREAD_NUMBER[ ]*=.*$")
1132 (format #f "MAX_CONCURRENT_THREAD_NUMBER = ~a~%"
1133 (number->string (parallel-job-count)))))
1134 ;; Build build support.
1135 (setenv "CC" "gcc")
1136 (invoke "make" "-C" tools))))
1137 (replace 'build
1138 (lambda _
1139 (invoke "build" "-a" #$arch-string "-t" #$toolchain "-p"
1140 (match #$arch
1141 ("x86_64"
1142 "OvmfPkg/OvmfPkgX64.dsc")
1143 ("i686"
1144 "OvmfPkg/OvmfPkgIa32.dsc")
1145 ((or "aarch64" "armhf")
1146 "ArmVirtPkg/ArmVirtQemu.dsc")
1147 ("riscv64"
1148 "OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc")
1149 (_ #t)))))
1150 (add-before 'install 'install-efi-shell
1151 (lambda _
1152 (let ((fmw (string-append #$output "/share/firmware")))
1153 (mkdir-p fmw)
1154 (for-each
1155 (lambda (file)
1156 (copy-file file
1157 (string-append fmw "/Shell_"
1158 (string-downcase #$arch-string)
1159 ".efi")))
1160 (find-files "Build" "Shell\\.efi"))))))))
1161 (native-inputs
1162 (append
1163 (list acpica
1164 perl
1165 python-3
1166 (list util-linux "lib"))
1167 (maybe-nasm (string-append arch "-" arch))
1168 (if (not (string-prefix? arch (%current-system)))
1169 (if (string=? arch "armhf")
1170 (list (cross-gcc "arm-linux-gnueabihf")
1171 (cross-binutils "arm-linux-gnueabihf"))
1172 (list (cross-gcc (string-append arch "-linux-gnu"))
1173 (cross-binutils (string-append arch "-linux-gnu"))))
1174 '())))
1175 (synopsis "UEFI firmware for QEMU")
1176 (description "OVMF is an EDK II based project to enable UEFI support for
1177Virtual Machines. OVMF contains a sample UEFI firmware for QEMU and KVM.")
1178 (license (list license:expat
1179 license:bsd-2 license:bsd-3 license:bsd-4)))))
1180
1181(define (ovmf-aux-file name)
1182 "Return as a gexp the auxiliary OVMF file corresponding to NAME."
1183 (local-file (search-auxiliary-file (string-append "ovmf/" name))))
1184
1185(define-public ovmf-x86-64
1186 (let ((base (make-ovmf-firmware "x86_64")))
1187 (package
1188 (inherit base)
1189 (name "ovmf-x86-64")
1190 (arguments
1191 (substitute-keyword-arguments arguments
1192 ((#:phases phases)
1193 #~(modify-phases #$phases
1194 (replace 'install
1195 (lambda _
1196 (let ((fmw (string-append #$output "/share/firmware")))
1197 (mkdir-p fmw)
1198 (for-each
1199 (lambda (file)
1200 (copy-file
1201 (string-append "Build/OvmfX64/RELEASE_GCC"
1202 "/FV/" file ".fd")
1203 (string-append fmw "/" (string-downcase file) "_x64.bin")))
1204 (list "OVMF"
1205 "OVMF_CODE"
1206 "OVMF_VARS")))))
1207 (add-after 'install 'install-qemu-firmware-metadata
1208 (lambda _
1209 ;; The QEMU firmware metadata files are taken from the
1210 ;; Fedora project (see:
1211 ;; https://src.fedoraproject.org/rpms/edk2/tree/rawhide).
1212 (let ((51-edk2-ovmf-2m-raw-x64-nosb.json-source
1213 #$(ovmf-aux-file "51-edk2-ovmf-2m-raw-x64-nosb.json"))
1214 (51-edk2-ovmf-2m-raw-x64-nosb.json-dest
1215 (string-append #$output "/share/qemu/firmware/"
1216 "51-edk2-ovmf-2m-raw-x64-nosb.json")))
1217 (mkdir-p (dirname 51-edk2-ovmf-2m-raw-x64-nosb.json-dest))
1218 (copy-file 51-edk2-ovmf-2m-raw-x64-nosb.json-source
1219 51-edk2-ovmf-2m-raw-x64-nosb.json-dest)
1220 (substitute* 51-edk2-ovmf-2m-raw-x64-nosb.json-dest
1221 (("/usr/share/edk2/ovmf/OVMF_(CODE|VARS).fd" _ kind)
1222 (string-append
1223 #$output "/share/firmware/ovmf_"
1224 (string-downcase kind) "_x64.bin")))))))))))))
1225
1226(define-public ovmf-i686
1227 (let ((base (make-ovmf-firmware "i686")))
1228 (package
1229 (inherit base)
1230 (arguments
1231 (substitute-keyword-arguments arguments
1232 ((#:phases phases)
1233 #~(modify-phases #$phases
1234 (replace 'install
1235 (lambda _
1236 (let ((fmw (string-append #$output "/share/firmware")))
1237 (mkdir-p fmw)
1238 (for-each
1239 (lambda (file)
1240 (copy-file
1241 (string-append "Build/OvmfIa32/RELEASE_GCC"
1242 "/FV/" file ".fd")
1243 (string-append fmw "/" (string-downcase file) "_ia32.bin")))
1244 (list "OVMF"
1245 "OVMF_CODE"
1246 "OVMF_VARS"))))))))))))
1247
1248(define-public ovmf-aarch64
1249 (let ((base (make-ovmf-firmware "aarch64")))
1250 (package
1251 (inherit base)
1252 (arguments
1253 (substitute-keyword-arguments arguments
1254 ((#:phases phases)
1255 #~(modify-phases #$phases
1256 (replace 'install
1257 (lambda _
1258 (let ((fmw (string-append #$output "/share/firmware"))
1259 (build-dir "Build/ArmVirtQemu-AARCH64/RELEASE_GCC/FV"))
1260 (mkdir-p fmw)
1261 ;; QEMU's virt machine requires 64 MiB pflash devices on
1262 ;; AArch64. Pad the firmware files to match.
1263 (copy-file (string-append build-dir "/QEMU_EFI.fd")
1264 (string-append fmw "/ovmf_aarch64.bin"))
1265 (truncate-file (string-append fmw "/ovmf_aarch64.bin")
1266 (* 64 1024 1024))))))))))))
1267
1268(define-public ovmf-arm
1269 (let ((base (make-ovmf-firmware "armhf")))
1270 (package
1271 (inherit base)
1272 (name "ovmf-arm")
1273 (arguments
1274 (substitute-keyword-arguments arguments
1275 ((#:phases phases)
1276 #~(modify-phases #$phases
1277 (replace 'install
1278 (lambda _
1279 (let ((fmw (string-append #$output "/share/firmware")))
1280 (mkdir-p fmw)
1281 (copy-file (string-append "Build/ArmVirtQemu-ARM/"
1282 "RELEASE_GCC/FV/QEMU_EFI.fd")
1283 (string-append fmw "/ovmf_arm.bin"))))))))))))
1284
1285(define-public ovmf-riscv64
1286 (let ((base (make-ovmf-firmware "riscv64")))
1287 (package
1288 (inherit base)
1289 (arguments
1290 (substitute-keyword-arguments arguments
1291 ((#:phases phases)
1292 #~(modify-phases #$phases
1293 (replace 'install
1294 (lambda _
1295 (let ((fmw (string-append #$output "/share/firmware")))
1296 (mkdir-p fmw)
1297 (with-directory-excursion "Build/RiscVVirtQemu/RELEASE_GCC/FV"
1298 (install-file "RISCV_VIRT_CODE.fd" fmw)
1299 (install-file "RISCV_VIRT_VARS.fd" fmw))))))))))))
1300
1301(define* (make-arm-trusted-firmware platform #:key
1302 (triplet "aarch64-linux-gnu")
1303 (make-flags '("DEBUG=1")))
1304 (define (native-build?)
1305 "Return #t if the host and target platforms differ."
1306 (or (not triplet)
1307 ;;%current-system is a *triplet*, unlike its name would suggest.
1308 (string=? (%current-system) (gnu-triplet->nix-system triplet))))
1309 (package
1310 (name (downstream-package-name "arm-trusted-firmware-" platform))
1311 (version "2.12.9")
1312 (source
1313 (origin
1314 (method git-fetch)
1315 (uri (git-reference
1316 (url (string-append "https://git.trustedfirmware.org"
1317 "/TF-A/trusted-firmware-a.git/"))
1318 (commit (string-append "lts-v" version))))
1319 (file-name (git-file-name "arm-trusted-firmware" version))
1320 (sha256
1321 (base32 "0zlb3g9qn7i8xr731nrsdqf00s03wv1ybhc28ka5nwniaccpg9dx"))
1322 (patches (search-patches "8mq-enable-imx_hab_handler.patch"
1323 "8mq-move-stack-to-ocram_s.patch"))
1324 (modules '((guix build utils)))
1325 ;; Remove binary blobs: they don't reference a source or license.
1326 (snippet #~(for-each delete-file (find-files "." "\\.bin$")))))
1327 (build-system gnu-build-system)
1328 (arguments
1329 (list
1330 #:target (and (not (native-build?)) triplet)
1331 #:phases
1332 #~(modify-phases %standard-phases
1333 (add-after 'unpack 'fix-cross-build
1334 ;; Fix ATF commit ffb7742125def3e0acca4c7e4d3215af5ce25a31
1335 (lambda _
1336 (unless #$(native-build?)
1337 (substitute* "plat/rockchip/rk3399/drivers/m0/Makefile"
1338 (("-oc") "-oc-default"))
1339 (substitute* "make_helpers/build_macros.mk"
1340 (("-oc") "-oc-default")
1341 (("-od") "-od-default")))))
1342 (delete 'configure) ;no configure script
1343 (replace 'install
1344 (lambda _
1345 (for-each (lambda (file)
1346 (install-file file #$output))
1347 (find-files "." "\\.(bin|elf)$")))))
1348 #:make-flags
1349 #~(list (string-append "PLAT=" #$platform)
1350 #$@(if (not (native-build?))
1351 (list (string-append "CROSS_COMPILE=" triplet "-"))
1352 '("CC=gcc"))
1353 #$@make-flags)
1354 #:tests? #f)) ;no test suite
1355 (native-inputs (list python))
1356 (home-page "https://www.trustedfirmware.org/")
1357 (synopsis "Secure world software for ARMv7-A and ARMv8-A")
1358 (description
1359 "ARM Trusted Firmware provides a reference implementation of secure
1360world software for ARMv7-A and ARMv8-A, including a Secure Monitor
1361executing at @dfn{Exception Level 3} (EL3). It implements various ARM
1362interface standards, such as:
1363@enumerate
1364@item The Power State Coordination Interface (PSCI)
1365@item Trusted Board Boot Requirements (TBBR, ARM DEN0006C-1)
1366@item SMC Calling Convention
1367@item System Control and Management Interface
1368@item Software Delegated Exception Interface (SDEI)
1369@end enumerate")
1370 (license (list license:bsd-3
1371 license:bsd-2)))) ; libfdt
1372
1373(define-public arm-trusted-firmware-sun50i-a64
1374 (make-arm-trusted-firmware "sun50i_a64"))
1375
1376(define-public arm-trusted-firmware-sun50i-h616
1377 (make-arm-trusted-firmware "sun50i_h616"))
1378
1379(define-public arm-trusted-firmware-rk3328
1380 (make-arm-trusted-firmware "rk3328"))
1381
1382(define-public arm-trusted-firmware-rk3399
1383 (let ((base (make-arm-trusted-firmware "rk3399")))
1384 (package
1385 (inherit base)
1386 (native-inputs (modify-inputs native-inputs
1387 (prepend (cross-gcc "arm-none-eabi")
1388 (cross-binutils "arm-none-eabi")))))))
1389
1390(define-public arm-trusted-firmware-rk3588
1391 (make-arm-trusted-firmware "rk3588"))
1392
1393(define-public arm-trusted-firmware-imx8mq
1394 ;; Remove debug symbols because of limited OCRAM.
1395 (make-arm-trusted-firmware "imx8mq" #:make-flags '()))
1396
1397(define make-crust-firmware
1398 (mlambda (platform)
1399 (package
1400 (name (string-append "crust-"
1401 (string-replace-substring platform "_" "-")
1402 "-firmware"))
1403 (version "0.6")
1404 (source
1405 (origin
1406 (method git-fetch)
1407 (uri (git-reference
1408 ;; There are only GitHub generated release snapshots.
1409 (url "https://github.com/crust-firmware/crust")
1410 (commit (string-append "v" version))))
1411 (file-name (git-file-name "crust" version))
1412 (sha256
1413 (base32
1414 "1blq6bi2rmg4qqwwr07pamv28b50mwcsybhpn9bws8vbzxa43afd"))))
1415 (build-system gnu-build-system)
1416 (arguments
1417 (list
1418 #:target "or1k-elf"
1419 #:tests? #f ;no test suite
1420 #:make-flags #~'("CROSS_COMPILE=or1k-elf-"
1421 "V=1"
1422 "HOSTAR=ar"
1423 "HOSTCC=gcc"
1424 "LEX=flex")
1425 #:phases
1426 #~(modify-phases %standard-phases
1427 (delete 'configure)
1428 (add-before 'build 'defconfig
1429 (lambda* (#:key make-flags #:allow-other-keys)
1430 (let ((config-name (string-append #$platform "_defconfig")))
1431 (apply invoke "make" (cons config-name make-flags)))))
1432 (replace 'install
1433 (lambda _
1434 (for-each (lambda (file)
1435 (install-file file (string-append #$output
1436 "/libexec")))
1437 (find-files "." "(scp\\.bin|\\.config)$")))))))
1438 (native-inputs (list bison flex))
1439 (home-page "https://github.com/crust-firmware/crust")
1440 (synopsis "Firmware for Allwinner sunxi SoCs")
1441 (description "Crust improves battery life and thermal performance by
1442implementing a deep sleep state. During deep sleep, the CPU cores, the DRAM
1443controller, and most onboard peripherals are powered down, reducing power
1444consumption by 80% or more compared to an idle device. On boards without a
1445PMIC, Crust is also responsible for orderly power-off and power-on of the
1446device. For this to work, Crust runs outside the main CPU and DRAM, on a
1447dedicated always-on microprocessor called a System Control Processor (SCP).
1448Crust is designed to run on a specific SCP implementation, Allwinner's
1449AR100.")
1450 ;; Most files are dual-licensed "BSD-3 OR GPL2", a few are GPL2 only.
1451 (license (list license:bsd-3 license:gpl2)))))
1452
1453(define make-crust-tools
1454 (mlambda (platform firmware)
1455 (package
1456 (inherit firmware)
1457 (name (string-append "crust-"
1458 (string-replace-substring platform "_" "-")
1459 "-tools"))
1460 (arguments
1461 (list #:make-flags
1462 #~(list "V=1"
1463 "LEX=flex"
1464 (string-append "HOSTAR=" #$(ar-for-target))
1465 (string-append "HOSTCC=" #$(cc-for-target)))
1466 #:phases
1467 #~(modify-phases %standard-phases
1468 (add-after 'unpack 'do-not-build-tests
1469 (lambda _
1470 ;; Attempting to build the tools test binary on a
1471 ;; non-aarch64 architecture fails with: "No cache
1472 ;; cleaning implementation available for this
1473 ;; architecture". Avoid building it (see:
1474 ;; https://github.com/crust-firmware/crust/issues/182).
1475 (substitute* "tools/Makefile"
1476 (("tools-y \\+= test") ""))))
1477 (replace 'configure
1478 (lambda* (#:key inputs native-inputs #:allow-other-keys)
1479 (copy-file (search-input-file inputs "/libexec/.config")
1480 ".config")))
1481 (replace 'build
1482 (lambda* (#:key make-flags parallel-build?
1483 #:allow-other-keys)
1484 (apply invoke "make" "tools"
1485 `(,@(if parallel-build?
1486 `("-j"
1487 ,(number->string (parallel-job-count)))
1488 '())
1489 ,@make-flags))))
1490 (replace 'install
1491 (lambda _
1492 (install-file "build/tools/load"
1493 (string-append #$output "/bin")))))))
1494 (synopsis "Firmware for Allwinner sunxi SoCs (tools)")
1495 (inputs (list firmware)))))
1496
1497(define make-crust-package
1498 (mlambda (platform)
1499 (let* ((firmware (make-crust-firmware platform))
1500 (tools (make-crust-tools platform firmware)))
1501 (package
1502 (inherit firmware)
1503 (name (string-append "crust-"
1504 (string-replace-substring platform "_" "-")))
1505 (source #f)
1506 (build-system trivial-build-system)
1507 (arguments
1508 (list #:modules '((guix build union))
1509 #:builder
1510 #~(begin
1511 (use-modules (ice-9 match)
1512 (guix build union))
1513
1514 (match %build-inputs
1515 (((names . directory) ...)
1516 (union-build #$output directory))))))
1517 (native-inputs '())
1518 (inputs (list firmware tools))))))
1519
1520(define-public crust-pinebook
1521 (make-crust-package "pinebook"))
1522
1523(define-public crust-pine64-plus
1524 (make-crust-package "pine64_plus"))
1525
1526
1527;;;
1528;;; ErgoDox firmware.
1529;;;
1530
1531(define* (make-ergodox-firmware/implementation layout #:key override.c
1532 override.h)
1533 "Return an ergodox-firmware package for LAYOUT, optionally using OVERRIDE.C,
1534a C source file-like object to override LAYOUT which may be accompanied by
1535OVERRIDE.H, to also override the corresponding layout include file."
1536 (let ((revision "0")
1537 (commit "89b7e2bfdafb2a87e0248846d5c95cc5e9a27858"))
1538 (package
1539 (name (string-append "ergodox-firmware-" layout))
1540 (version (git-version "1" revision commit))
1541 (source (origin
1542 (method git-fetch)
1543 (uri (git-reference
1544 (url "https://github.com/benblazak/ergodox-firmware")
1545 (commit commit)))
1546 (file-name (git-file-name name version))
1547 (sha256
1548 (base32
1549 "1z28frxyb21nz90frycrpsbxjp09374wawayvjphnwc8njlvkkpy"))
1550 (patches
1551 (search-patches "ergodox-firmware-fix-json-target.patch"
1552 "ergodox-firmware-fix-numpad.patch"))))
1553 (build-system gnu-build-system)
1554 (arguments
1555 (list
1556 #:tests? #f ;no test suite
1557 #:target "avr"
1558 #:make-flags
1559 #~(list (string-append "LAYOUT=" #$layout)
1560 ;; Simplify the output directory name.
1561 "ROOT=output")
1562 #:phases
1563 #~(modify-phases %standard-phases
1564 (add-after 'unpack 'copy-override-files
1565 (lambda _
1566 (when #$override.c
1567 (copy-file #$override.c
1568 (format #f "src/keyboard/ergodox/layout/~a.c"
1569 #$layout)))
1570 (when #$override.h
1571 (copy-file #$override.h
1572 (format #f "src/keyboard/ergodox/layout/~a.h"
1573 #$layout)))))
1574 ;; The Makefile-based build system lacks configure
1575 ;; and install targets.
1576 (delete 'configure)
1577 (replace 'install
1578 (lambda _
1579 (with-directory-excursion "output"
1580 (install-file "firmware.hex" #$output)
1581 (install-file "firmware.eep" #$output)
1582 (install-file "firmware--layout.html" #$output)))))))
1583 (native-inputs (list python))
1584 (home-page "https://www.ergodox.io")
1585 (synopsis "Firmware for the ErgoDox keyboard")
1586 (description (format #f "This package contains the original firmware for
1587the ErgoDox keyboard, built using the ~a layout (as defined in the
1588@file{src/keyboard/ergodox/layout/~@*~a.c} source file). It contains the
1589@file{firmware.hex} and the @file{firmware.eep} files, which can be loaded to
1590a target using the @code{teensy-loader-cli} package as well as a
1591@file{firmware--layout.html} file, useful to easily visualize the
1592corresponding layout." layout))
1593 (license license:expat))))
1594
1595(define make-ergodox-firmware
1596 (memoize make-ergodox-firmware/implementation))
1597
1598(define-public ergodox-firmware-colemak-jc-mod
1599 (make-ergodox-firmware "colemak-jc-mod"))
1600
1601(define-public ergodox-firmware-colemak-symbol-mod
1602 (make-ergodox-firmware "colemak-symbol-mod"))
1603
1604(define-public ergodox-firmware-dvorak-kinesis-mod
1605 (make-ergodox-firmware "dvorak-kinesis-mod"))
1606
1607(define-public ergodox-firmware-qwerty-kinesis-mod
1608 (make-ergodox-firmware "qwerty-kinesis-mod"))
1609
1610(define-public ergodox-firmware-workman-p-kinesis-mod
1611 (make-ergodox-firmware "workman-p-kinesis-mod"))
1612
1613
1614;;;
1615;;; QMK Firmware.
1616;;;
1617
1618(define-public qmk
1619 (package
1620 (name "qmk")
1621 (version "1.2.0")
1622 (source (origin
1623 (method url-fetch)
1624 (uri (pypi-uri "qmk" version))
1625 (sha256
1626 (base32
1627 "0j4ana65v5x1rg262a9nvwnr8hc1zay1gw74brv2n6s09ind2jqn"))))
1628 (build-system pyproject-build-system)
1629 (arguments
1630 (list
1631 #:tests? #f ;no tests
1632 #:modules '((guix build pyproject-build-system)
1633 (guix build utils)
1634 (srfi srfi-26))
1635 #:phases
1636 #~(modify-phases %standard-phases
1637 (add-after 'wrap 'wrap-path
1638 ;; Wrap all the tools needed for the 'setup' and 'compile' actions
1639 ;; (tested with the 'ergodox_ez' keyboard).
1640 (lambda* (#:key inputs outputs #:allow-other-keys)
1641 (wrap-program (search-input-file outputs "bin/qmk")
1642 `("PATH" prefix
1643 ,(map (compose dirname
1644 (cut search-input-file inputs <>))
1645 '("bin/avrdude"
1646 "bin/awk"
1647 "bin/cmp"
1648 "bin/dfu-programmer"
1649 "bin/dfu-util"
1650 "bin/git"
1651 "bin/grep"
1652 "bin/make"
1653 "bin/python3"
1654 "bin/sh"
1655 ;; TODO: Remove after git is wrapped with these.
1656 "bin/basename"
1657 "bin/sed"
1658 "bin/uname")))))))))
1659 ;; The inputs are not propagated since qmk is to be used strictly as a
1660 ;; command.
1661 (inputs
1662 ;; The 'qmk setup' command advises to use GCC at version 8, and there are
1663 ;; compilation errors in some firmware otherwise.
1664 (list avrdude
1665 bash-minimal
1666 dfu-programmer
1667 dfu-util
1668 diffutils
1669 git-minimal/pinned ;for the clone action
1670 gawk
1671 gnu-make
1672 grep
1673 python
1674 python-appdirs
1675 python-dotty-dict
1676 python-hid
1677 python-hjson
1678 python-jsonschema
1679 python-milc
1680 python-pillow
1681 python-pygments
1682 python-pyserial
1683 python-pyusb
1684 ;; These are added to workaround faults in our git package (see
1685 ;; bug#65924).
1686 coreutils-minimal
1687 sed
1688 util-linux))
1689 (native-inputs (list python-setuptools python-wheel))
1690 (home-page "https://qmk.fm")
1691 (synopsis "Command line utility to manage QMK keyboard firmwares")
1692 (description "The QMK CLI provides a @acronym{CLI, command line interface}
1693based program to help users work with the QMK firmware, which can be used for
1694multiple custom keyboards such as Planck, ErgoDox, Corne and others.
1695
1696This @acronym{CLI} program is mainly used for building the QMK firmware, but
1697also has some other convenience utilities. It is highly recommended to
1698install the udev rules provided by the @code{qmk-udev-rules} package to avoid
1699having to run @command{qmk} as root when flashing the firmware.")
1700 (license license:expat)))
1701
1702(define* (make-qmk-firmware/implementation keyboard keymap
1703 #:key (description "")
1704 keymap-json
1705 keymap-source-directory
1706 keyboard-source-directory)
1707 "Return a package to build the QMK firmware for KEYBOARD with KEYMAP.
1708Keyboard should be the name of a sub-directory under the @file{keyboards} directory.
1709For custom keymaps, KEYMAP-JSON, a file-like object of a JSON representation of
1710KEYMAP as generated by the @url{https://config.qmk.fm/, QMK Configurator} tool or
1711KEYMAP-SOURCE-DIRECTORY, a file-like object directory containing the keymap source
1712files files such as @file{keymap.c}, can be provided. For keyboards not available in
1713upstream repository, provide a file-like object directory containing the whole
1714keyboard definition in KEYBOARD-SOURCE-DIRECTORY."
1715 (package
1716 (name (string-append "qmk-firmware-"
1717 (regexp-substitute/global #f "[_/]" keyboard
1718 'pre "-" 'post)
1719 "-"
1720 (string-replace-substring keymap "_" "-")))
1721 ;; Note: When updating this package, make sure to also update the commit
1722 ;; used for the LUFA submodule in the 'copy-lufa-source' phase below.
1723 (version "0.33.8")
1724 (source (origin
1725 (method git-fetch)
1726 (uri (git-reference
1727 (url "https://github.com/qmk/qmk_firmware")
1728 (commit version)))
1729 (file-name (git-file-name "qmk-firmware" version))
1730 (sha256
1731 (base32
1732 "0sz3m7xgqvcsjwm8wpcghdakf2c1qczidm6l6p5icbz3wphvd3ar"))))
1733 (build-system gnu-build-system)
1734 (arguments
1735 (list
1736 #:modules '((guix build gnu-build-system)
1737 (guix build utils)
1738 (ice-9 ftw)
1739 (ice-9 match)
1740 (srfi srfi-26))
1741 #:target "avr"
1742 ;; XXX: Running a test target like "test:$keyboard" doesn't seem to run
1743 ;; anything and causes the .hex file to be regenerated; leave the tests
1744 ;; out for now.
1745 #:tests? #f
1746 #:make-flags
1747 #~(list #$(format #f "~a:~a" keyboard keymap)
1748 (string-append "SHELL=" (search-input-file
1749 %build-inputs "bin/sh")))
1750 #:phases
1751 #~(modify-phases %standard-phases
1752 (replace 'configure
1753 (lambda _
1754 ;; Do not attempt to retrieve information from git during the
1755 ;; build.
1756 (setenv "SKIP_GIT" "1")))
1757 (add-after 'unpack 'copy-lufa-source
1758 ;; QMK carries a custom fork of LUFA as a git submodule; make sure
1759 ;; the same commit is used (see:
1760 ;; <https://github.com/qmk/qmk_firmware/tree/master/lib>).
1761 (lambda _
1762 (copy-recursively
1763 #$(let ((commit "549b97320d515bfca2f95c145a67bd13be968faa"))
1764 (origin
1765 (inherit (package-source lufa))
1766 (uri (git-reference
1767 (url "https://github.com/qmk/lufa")
1768 (commit commit)))
1769 (file-name (git-file-name "lufa" commit))
1770 (sha256
1771 (base32
1772 "1rmhm4rxvq8skxqn6vc4n4ly1ak6whj7c386zbsci4pxx548n9h4"))))
1773 "lib/lufa")))
1774 #$@(if keyboard-source-directory
1775 #~((add-after 'unpack 'copy-keyboard-source-directory
1776 (lambda _
1777 (let ((keyboard-dir #$(string-append "keyboards/" keyboard)))
1778 (false-if-exception (delete-file-recursively
1779 keyboard-dir))
1780 (copy-recursively #$keyboard-source-directory
1781 keyboard-dir)))))
1782 #~())
1783 #$@(if keymap-source-directory
1784 #~((add-after 'unpack 'copy-keymap-source-directory
1785 (lambda _
1786 (let ((keymap-dir #$(string-append "keyboards/" keyboard
1787 "/keymaps/" keymap)))
1788 (false-if-exception (delete-file-recursively
1789 keymap-dir))
1790 (copy-recursively #$keymap-source-directory
1791 keymap-dir)))))
1792 #~())
1793 #$@(if keymap-json
1794 #~((replace 'build
1795 (lambda _
1796 (invoke "qmk" "compile" #$keymap-json))))
1797 #~())
1798 (replace 'install
1799 (lambda _
1800 (match (scandir "." (lambda (f)
1801 (false-if-exception
1802 (member (string-take-right f 4)
1803 '(".bin" ".hex" ".uf2")))))
1804 (()
1805 (error "no built binary file found"))
1806 ((hex ..1)
1807 (for-each (cut install-file <> #$output) hex))))))))
1808 ;; Some of the build tools are required to be on the PATH, as the make
1809 ;; files do not always operate through 'qmk'; all of qmk's inputs must
1810 ;; thus be made available.
1811 (native-inputs (modify-inputs (package-inputs qmk)
1812 (append qmk)))
1813 (home-page "https://qmk.fm/")
1814 (synopsis "Keyboard firmware for Atmel AVR and Arm USB families")
1815 (description
1816 (format #f "QMK (Quantum Mechanical Keyboard Firmware) is a keyboard
1817firmware based on the @url{https://github.com/tmk/tmk_keyboard, tmk_keyboard
1818firmware} with some useful features for Atmel AVR and ARM controllers, and
1819more specifically, the @url{https://olkb.com/, OLKB product line}, the
1820@url{https://ergodox-ez.com/, ErgoDox EZ keyboard}, and the
1821@url{https://clueboard.co/, Clueboard product line}.~@[~%~%~a~]" description))
1822 (license license:gpl2+)))
1823
1824(define make-qmk-firmware (memoize make-qmk-firmware/implementation))
1825
1826(define-public qmk-firmware-ergodox-ez-default
1827 (make-qmk-firmware
1828 "ergodox_ez" "default" #:description
1829 "This is the default keymap used on the ErgoDox EZ keyboard. It includes
1830the novel MEH and Hyper keys pioneered by the ErgoDox EZ, easy to reach
1831Control/Shift modifiers keys, and two-functions hold keys to access layer 1.
1832Layer 1 contains function keys, symbols, a numpad as well as brightness keys.
1833Layer 2 contains multimedia and mouse keys. See the
1834@file{keyboards/ergodox_ez/keymaps/default/keymap.c} source file for the
1835keymap definition, or the
1836@url{https://configure.ergodox-ez.com/ergodox-ez/layouts/JwwW/latest/0,
1837ErgoDox EZ Configurator} page."))
1838
1839(define-public qmk-udev-rules
1840 (package
1841 (name "qmk-udev-rules")
1842 (version "0.1.23")
1843 (source (origin
1844 (method git-fetch)
1845 (uri (git-reference
1846 (url "https://github.com/qmk/qmk_udev")
1847 (commit (string-append "v" version))))
1848 (file-name (git-file-name "qmk-udev" version))
1849 (sha256
1850 (base32
1851 "1jmqzl4a1zzphmpav2m4fgdxq8v229vrgg27ncq5x1hsg279i71f"))))
1852 (build-system gnu-build-system)
1853 (arguments
1854 (list
1855 #:make-flags
1856 #~(list (string-append "CC=" #$(cc-for-target))
1857 (string-append "PREFIX=" #$output))
1858 #:tests? #f
1859 #:phases
1860 #~(modify-phases %standard-phases
1861 (add-after 'unpack 'patch-udev-rules
1862 (lambda _
1863 (substitute* "50-qmk.rules"
1864 (("qmk_id")
1865 (string-append #$output "/lib/udev/qmk_id")))))
1866 (delete 'configure))))
1867 (home-page "https://qmk.fm/")
1868 (synopsis "Udev rules for QMK Firmware")
1869 (description
1870 "This package provides a set of udev rules to specify the proper
1871privileges for flashing QMK compatible devices without needing root. The
1872rules require the group @code{plugdev} to be added to each user that needs
1873this.")
1874 (license license:gpl2+)))
1875
1876(define-public senoko-chibios
1877 (package
1878 (name "senoko-chibios")
1879 (version "2.5")
1880 (source (origin
1881 (method git-fetch)
1882 (uri (git-reference
1883 (url "https://github.com/xobs/senoko-chibios-3.git")
1884 (commit (string-append "v" version))))
1885 (file-name (git-file-name name version))
1886 (sha256
1887 (base32
1888 "1qdpxzqdh0l65rzfbrm1lqzpik3nyg8wa7k0b8b6apj2w6vsp5pv"))))
1889 (build-system gnu-build-system)
1890 (arguments
1891 (list #:tests? #f ; no tests
1892 #:make-flags #~(list "USE_VERBOSE_COMPILE=yes")
1893 #:phases
1894 #~(modify-phases %standard-phases
1895 (delete 'configure)
1896 (add-after 'unpack 'patch
1897 (lambda* (#:key outputs #:allow-other-keys)
1898 (chdir "senoko")
1899 (substitute* "Makefile"
1900 ;; We don't have those dependencies since we delete .git
1901 ;; after checkout.
1902 ((" [$][(]CHIBIOS[)]/.git/HEAD [$][(]CHIBIOS[)]/.git/index")
1903 "")
1904 (("[$][(]shell git rev-parse HEAD[)]")
1905 ;; Uniquely identify the version.
1906 (assoc-ref outputs "out")))))
1907 (replace 'install
1908 (lambda* (#:key outputs #:allow-other-keys)
1909 (let ((destination (string-append (assoc-ref outputs "out")
1910 "/lib/firmware")))
1911 (install-file "build/senoko.elf" destination)
1912 (install-file "build/senoko.hex" destination)))))))
1913 (synopsis "Firmware for Novena battery or passthrough board")
1914 (description "This package provides the firmware for the Novena battery
1915or passthrough board.")
1916 (supported-systems '("armhf-linux")) ; actually cortex-m3
1917 (home-page "https://github.com/xobs/senoko-chibios-3/")
1918 (license license:gpl3+)))
1919
1920(define (make-qmk-newlib-nano-arm-none-eabi)
1921 (let ((base (make-newlib-nano-arm-none-eabi)))
1922 (package
1923 (inherit base)
1924 (native-inputs
1925 (modify-inputs native-inputs
1926 (replace "xgcc" (make-gcc-arm-none-eabi-12.3.rel1)))))))
1927
1928(define* (make-qmk-firmware-keychron keyboard keymap
1929 #:key (description "")
1930 keymap-json
1931 keymap-source-directory
1932 keyboard-source-directory)
1933 (let ((base (make-qmk-firmware keyboard keymap
1934 #:description description
1935 #:keymap-json keymap-json
1936 #:keymap-source-directory keymap-source-directory
1937 #:keyboard-source-directory keyboard-source-directory)))
1938 (package
1939 (inherit base)
1940 (name (string-append "qmk-firmware-"
1941 (regexp-substitute/global #f "[_/]" keyboard
1942 'pre "-" 'post)
1943 "-"
1944 (string-replace-substring keymap "_" "-")))
1945 ;; Note: When updating this package, make sure to also update the commit
1946 ;; used for the LUFA submodule in the 'copy-lufa-source' phase below.
1947 (version "0.28.0")
1948 (source (origin
1949 (method git-fetch)
1950 (uri (git-reference
1951 (url "https://github.com/qmk/qmk_firmware")
1952 (commit version)))
1953 (file-name (git-file-name "qmk-firmware" version))
1954 (sha256
1955 (base32
1956 "1skj7iq6dad48xhy2ljjmwpbhhdv3gk7cmi28lh3xfsnxphm4v8r"))))
1957 (arguments
1958 (substitute-keyword-arguments arguments
1959 ((#:phases phases)
1960 #~(modify-phases #$phases
1961 (replace 'copy-lufa-source
1962 ;; QMK carries a custom fork of LUFA as a git submodule; make sure
1963 ;; the same commit is used (see:
1964 ;; https://github.com/qmk/qmk_firmware/tree/master/lib).
1965 (lambda _
1966 (copy-recursively
1967 #$(let ((commit "549b97320d515bfca2f95c145a67bd13be968faa"))
1968 (origin
1969 (inherit (package-source lufa))
1970 (uri (git-reference
1971 (url "https://github.com/qmk/lufa")
1972 (commit commit)))
1973 (file-name (git-file-name "lufa" commit))
1974 (sha256
1975 (base32
1976 "1rmhm4rxvq8skxqn6vc4n4ly1ak6whj7c386zbsci4pxx548n9h4"))))
1977 "lib/lufa")))
1978 (add-after 'unpack 'setenv
1979 (lambda _
1980 ;; Because newlib-nano is also compiled without FPU.
1981 (setenv "USE_FPU" "no")))
1982 (add-after 'unpack 'copy-chibios-source
1983 (lambda _
1984 ;; Newest version.
1985 (copy-recursively
1986 #$(origin
1987 (method git-fetch)
1988 (uri (git-reference
1989 (url "https://github.com/qmk/ChibiOS")
1990 (commit "2365f844292513ea0ee9eea6ab778d56f9ccd3b9")))
1991 ;(file-name (git-file-name name version))
1992 (sha256
1993 (base32
1994 "1ivkrx4nv0sa4nfryzbq5h40vs7vik8p0dp9czjh2srql520y7yq")))
1995 "lib/chibios")))
1996 (add-after 'unpack 'copy-printf-source
1997 ;; Newest version.
1998 (lambda _
1999 (copy-recursively
2000 #$(origin
2001 (method git-fetch)
2002 (uri (git-reference
2003 (url "https://github.com/qmk/printf.git")
2004 (commit "c2e3b4e10d281e7f0f694d3ecbd9f320977288cc")))
2005 ;(file-name (git-file-name name version))
2006 (sha256
2007 (base32
2008 "0r501hkk0idwfm6qs09g1wb808ga452gz39dw32x13rmg3a901s6")))
2009 "lib/printf")))))))
2010 (native-inputs
2011 (modify-inputs native-inputs
2012 (prepend
2013 (package
2014 (inherit (make-qmk-newlib-nano-arm-none-eabi))
2015 (native-search-paths
2016 (list (search-path-specification
2017 (variable "CROSS_C_INCLUDE_PATH")
2018 (files '("arm-none-eabi/include")))
2019 (search-path-specification
2020 (variable "CROSS_CPLUS_INCLUDE_PATH")
2021 (files '("arm-none-eabi/include"
2022 "arm-none-eabi/include/c++"
2023 "arm-none-eabi/include/c++/arm-none-eabi")))
2024 (search-path-specification
2025 (variable "CROSS_LIBRARY_PATH")
2026 (files '("arm-none-eabi/lib"))))))
2027 (make-gcc-arm-none-eabi-12.3.rel1)
2028 (cross-binutils "arm-none-eabi")))))))
2029
2030(define-public qmk-firmware-keychron-c1-pro-ansi-rgb-default
2031 (make-qmk-firmware-keychron "keychron/c1_pro/ansi/rgb" "default"
2032 #:description
2033 "This package provides the firmware for the Keychron C1 Pro ANSI RGB with default keymap."))
2034
2035(define-public qmk-firmware-keychron-c1-pro-ansi-white-default
2036 (make-qmk-firmware-keychron "keychron/c1_pro/ansi/white" "default"
2037 #:description
2038 "This package provides the firmware for the Keychron C1 Pro ANSI white with default keymap."))
2039
2040(define-public qmk-firmware-keychron-c2-pro-ansi-rgb-default
2041 (make-qmk-firmware-keychron "keychron/c2_pro/ansi/rgb" "default"
2042 #:description
2043 "This package provides the firmware for the Keychron C2 Pro ANSI RGB with default keymap."))
2044
2045(define-public qmk-firmware-keychron-c2-pro-ansi-white-default
2046 (make-qmk-firmware-keychron "keychron/c2_pro/ansi/white" "default"
2047 #:description
2048 "This package provides the firmware for the Keychron C2 Pro ANSI white with default keymap."))
2049
2050(define-public qmk-firmware-keychron-c3-pro-ansi-red-default
2051 (make-qmk-firmware-keychron "keychron/c3_pro/ansi/red" "default"
2052 #:description
2053 "This package provides the firmware for the Keychron C3 Pro ANSI Red with default keymap."))
2054
2055(define-public qmk-firmware-keychron-c3-pro-ansi-rgb-default
2056 (make-qmk-firmware-keychron "keychron/c3_pro/ansi/rgb" "default"
2057 #:description
2058 "This package provides the firmware for the Keychron C3 Pro ANSI RGB with default keymap."))
2059
2060(define-public qmk-firmware-keychron-q0-base-default
2061 (make-qmk-firmware-keychron "keychron/q0/base" "default"
2062 #:description
2063 "This package provides the firmware for the Keychron Q0 Base with default keymap."))
2064
2065(define-public qmk-firmware-keychron-q0-plus-default
2066 (make-qmk-firmware-keychron "keychron/q0/plus" "default"
2067 #:description
2068 "This package provides the firmware for the Keychron Q0 Plus with default keymap."))
2069
2070(define-public qmk-firmware-keychron-q10-ansi-encoder-default
2071 (make-qmk-firmware-keychron "keychron/q10/ansi_encoder" "default"
2072 #:description
2073 "This package provides the firmware for the Keychron Q10 ANSI with default keymap and with encoder."))
2074
2075(define-public qmk-firmware-keychron-q10-iso-encoder-default
2076 (make-qmk-firmware-keychron "keychron/q10/iso_encoder" "default"
2077 #:description
2078 "This package provides the firmware for the Keychron Q10 ISO with default keymap and with encoder."))
2079
2080(define-public qmk-firmware-keychron-q11-ansi-encoder-default
2081 (make-qmk-firmware-keychron "keychron/q11/ansi_encoder" "default"
2082 #:description
2083 "This package provides the firmware for the Keychron Q11 ANSI with default keymap and with encoder."))
2084
2085(define-public qmk-firmware-keychron-q11-iso-encoder-default
2086 (make-qmk-firmware-keychron "keychron/q11/iso_encoder" "default"
2087 #:description
2088 "This package provides the firmware for the Keychron Q11 ISO with default keymap and with encoder."))
2089
2090(define-public qmk-firmware-keychron-q12-ansi-encoder-default
2091 (make-qmk-firmware-keychron "keychron/q12/ansi_encoder" "default"
2092 #:description
2093 "This package provides the firmware for the Keychron Q12 ANSI with default keymap and with encoder."))
2094
2095(define-public qmk-firmware-keychron-q12-iso-encoder-default
2096 (make-qmk-firmware-keychron "keychron/q12/iso_encoder" "default"
2097 #:description
2098 "This package provides the firmware for the Keychron Q12 ISO with default keymap and with encoder."))
2099
2100(define-public qmk-firmware-keychron-q1v2-ansi-default
2101 (make-qmk-firmware-keychron "keychron/q1v2/ansi" "default"
2102 #:description
2103 "This package provides the firmware for the Keychron Q1v2 ANSI with default keymap."))
2104
2105(define-public qmk-firmware-keychron-q1v2-ansi-encoder-default
2106 (make-qmk-firmware-keychron "keychron/q1v2/ansi_encoder" "default"
2107 #:description
2108 "This package provides the firmware for the Keychron Q1v2 ANSI with default keymap and with encoder."))
2109
2110(define-public qmk-firmware-keychron-q1v2-iso-default
2111 (make-qmk-firmware-keychron "keychron/q1v2/iso" "default"
2112 #:description
2113 "This package provides the firmware for the Keychron Q1v2 ISO with default keymap."))
2114
2115(define-public qmk-firmware-keychron-q1v2-iso-encoder-default
2116 (make-qmk-firmware-keychron "keychron/q1v2/iso_encoder" "default"
2117 #:description
2118 "This package provides the firmware for the Keychron Q1v2 ISO with default keymap and with encoder."))
2119
2120(define-public qmk-firmware-keychron-q1v2-jis-default
2121 (make-qmk-firmware-keychron "keychron/q1v2/jis" "default"
2122 #:description
2123 "This package provides the firmware for the Keychron Q1v2 JIS with default keymap."))
2124
2125(define-public qmk-firmware-keychron-q1v2-jis-encoder-default
2126 (make-qmk-firmware-keychron "keychron/q1v2/jis_encoder" "default"
2127 #:description
2128 "This package provides the firmware for the Keychron Q1v2 JIS with default keymap and with encoder."))
2129
2130(define-public qmk-firmware-keychron-q2-ansi-default
2131 (make-qmk-firmware-keychron "keychron/q2/ansi" "default"
2132 #:description
2133 "This package provides the firmware for the Keychron Q2 ANSI with default keymap."))
2134
2135(define-public qmk-firmware-keychron-q2-ansi-encoder-default
2136 (make-qmk-firmware-keychron "keychron/q2/ansi_encoder" "default"
2137 #:description
2138 "This package provides the firmware for the Keychron Q2 ANSI with default keymap and with encoder."))
2139
2140(define-public qmk-firmware-keychron-q2-iso-default
2141 (make-qmk-firmware-keychron "keychron/q2/iso" "default"
2142 #:description
2143 "This package provides the firmware for the Keychron Q2 ISO with default keymap."))
2144
2145(define-public qmk-firmware-keychron-q2-iso-encoder-default
2146 (make-qmk-firmware-keychron "keychron/q2/iso_encoder" "default"
2147 #:description
2148 "This package provides the firmware for the Keychron Q2 ISO with default keymap and with encoder."))
2149
2150(define-public qmk-firmware-keychron-q2-jis-default
2151 (make-qmk-firmware-keychron "keychron/q2/jis" "default"
2152 #:description
2153 "This package provides the firmware for the Keychron Q2 JIS with default keymap."))
2154
2155(define-public qmk-firmware-keychron-q2-jis-encoder-default
2156 (make-qmk-firmware-keychron "keychron/q2/jis_encoder" "default"
2157 #:description
2158 "This package provides the firmware for the Keychron Q2 JIS with default keymap and with encoder."))
2159
2160(define-public qmk-firmware-keychron-q3-ansi-default
2161 (make-qmk-firmware-keychron "keychron/q3/ansi" "default"
2162 #:description
2163 "This package provides the firmware for the Keychron Q3 ANSI with default keymap."))
2164
2165(define-public qmk-firmware-keychron-q3-ansi-encoder-default
2166 (make-qmk-firmware-keychron "keychron/q3/ansi_encoder" "default"
2167 #:description
2168 "This package provides the firmware for the Keychron Q3 ANSI with default keymap and with encoder."))
2169
2170(define-public qmk-firmware-keychron-q3-iso-default
2171 (make-qmk-firmware-keychron "keychron/q3/iso" "default"
2172 #:description
2173 "This package provides the firmware for the Keychron Q3 ISO with default keymap."))
2174
2175(define-public qmk-firmware-keychron-q3-iso-encoder-default
2176 (make-qmk-firmware-keychron "keychron/q3/iso_encoder" "default"
2177 #:description
2178 "This package provides the firmware for the Keychron Q3 ISO with default keymap and with encoder."))
2179
2180(define-public qmk-firmware-keychron-q3-jis-default
2181 (make-qmk-firmware-keychron "keychron/q3/jis" "default"
2182 #:description
2183 "This package provides the firmware for the Keychron Q3 JIS with default keymap."))
2184
2185(define-public qmk-firmware-keychron-q3-jis-encoder-default
2186 (make-qmk-firmware-keychron "keychron/q3/jis_encoder" "default"
2187 #:description
2188 "This package provides the firmware for the Keychron Q3 JIS with default keymap and with encoder."))
2189
2190(define-public qmk-firmware-keychron-q4-ansi-v2-default
2191 (make-qmk-firmware-keychron "keychron/q4/ansi/v2" "default"
2192 #:description
2193 "This package provides the firmware for the Keychron Q4 ANSI with default keymap."))
2194
2195(define-public qmk-firmware-keychron-q4-iso-default
2196 (make-qmk-firmware-keychron "keychron/q4/iso" "default"
2197 #:description
2198 "This package provides the firmware for the Keychron Q4 ISO with default keymap."))
2199
2200(define-public qmk-firmware-keychron-q5-ansi-default
2201 (make-qmk-firmware-keychron "keychron/q5/ansi" "default"
2202 #:description
2203 "This package provides the firmware for the Keychron Q5 ANSI with default keymap."))
2204
2205(define-public qmk-firmware-keychron-q5-ansi-encoder-default
2206 (make-qmk-firmware-keychron "keychron/q5/ansi_encoder" "default"
2207 #:description
2208 "This package provides the firmware for the Keychron Q5 ANSI with default keymap and with encoder."))
2209
2210(define-public qmk-firmware-keychron-q5-iso-default
2211 (make-qmk-firmware-keychron "keychron/q5/iso" "default"
2212 #:description
2213 "This package provides the firmware for the Keychron Q5 ISO with default keymap."))
2214
2215(define-public qmk-firmware-keychron-q5-iso-encoder-default
2216 (make-qmk-firmware-keychron "keychron/q5/iso_encoder" "default"
2217 #:description
2218 "This package provides the firmware for the Keychron Q5 ISO with default keymap and with encoder."))
2219
2220(define-public qmk-firmware-keychron-q60-ansi-default
2221 (make-qmk-firmware-keychron "keychron/q60/ansi" "default"
2222 #:description
2223 "This package provides the firmware for the Keychron Q60 ANSI with default keymap."))
2224
2225(define-public qmk-firmware-keychron-q65-ansi-encoder-default
2226 (make-qmk-firmware-keychron "keychron/q65/ansi_encoder" "default"
2227 #:description
2228 "This package provides the firmware for the Keychron Q65 ANSI with default keymap and with encoder."))
2229
2230(define-public qmk-firmware-keychron-q6-ansi-default
2231 (make-qmk-firmware-keychron "keychron/q6/ansi" "default"
2232 #:description
2233 "This package provides the firmware for the Keychron Q6 ANSI with default keymap."))
2234
2235(define-public qmk-firmware-keychron-q6-ansi-encoder-default
2236 (make-qmk-firmware-keychron "keychron/q6/ansi_encoder" "default"
2237 #:description
2238 "This package provides the firmware for the Keychron Q6 ANSI with default keymap and with encoder."))
2239
2240(define-public qmk-firmware-keychron-q6-iso-default
2241 (make-qmk-firmware-keychron "keychron/q6/iso" "default"
2242 #:description
2243 "This package provides the firmware for the Keychron Q6 ISO with default keymap."))
2244
2245(define-public qmk-firmware-keychron-q6-iso-encoder-default
2246 (make-qmk-firmware-keychron "keychron/q6/iso_encoder" "default"
2247 #:description
2248 "This package provides the firmware for the Keychron Q6 ISO with default keymap and with encoder."))
2249
2250(define-public qmk-firmware-keychron-q7-ansi-default
2251 (make-qmk-firmware-keychron "keychron/q7/ansi" "default"
2252 #:description
2253 "This package provides the firmware for the Keychron Q7 ANSI with default keymap."))
2254
2255(define-public qmk-firmware-keychron-q7-iso-default
2256 (make-qmk-firmware-keychron "keychron/q7/iso" "default"
2257 #:description
2258 "This package provides the firmware for the Keychron Q7 ISO with default keymap."))
2259
2260(define-public qmk-firmware-keychron-q8-ansi-default
2261 (make-qmk-firmware-keychron "keychron/q8/ansi" "default"
2262 #:description
2263 "This package provides the firmware for the Keychron Q8 ANSI with default keymap."))
2264
2265(define-public qmk-firmware-keychron-q8-ansi-encoder-default
2266 (make-qmk-firmware-keychron "keychron/q8/ansi_encoder" "default"
2267 #:description
2268 "This package provides the firmware for the Keychron Q8 ANSI with default keymap and with encoder."))
2269
2270(define-public qmk-firmware-keychron-q8-iso-default
2271 (make-qmk-firmware-keychron "keychron/q8/iso" "default"
2272 #:description
2273 "This package provides the firmware for the Keychron Q8 ISO with default keymap."))
2274
2275(define-public qmk-firmware-keychron-q8-iso-encoder-default
2276 (make-qmk-firmware-keychron "keychron/q8/iso_encoder" "default"
2277 #:description
2278 "This package provides the firmware for the Keychron Q8 ISO with default keymap and with encoder."))
2279
2280(define-public qmk-firmware-keychron-q9-ansi-default
2281 (make-qmk-firmware-keychron "keychron/q9/ansi" "default"
2282 #:description
2283 "This package provides the firmware for the Keychron Q9 ANSI with default keymap."))
2284
2285(define-public qmk-firmware-keychron-q9-ansi-encoder-default
2286 (make-qmk-firmware-keychron "keychron/q9/ansi_encoder" "default"
2287 #:description
2288 "This package provides the firmware for the Keychron Q9 ANSI with default keymap and with encoder."))
2289
2290(define-public qmk-firmware-keychron-q9-iso-default
2291 (make-qmk-firmware-keychron "keychron/q9/iso" "default"
2292 #:description
2293 "This package provides the firmware for the Keychron Q9 ISO with default keymap."))
2294
2295(define-public qmk-firmware-keychron-q9-iso-encoder-default
2296 (make-qmk-firmware-keychron "keychron/q9/iso_encoder" "default"
2297 #:description
2298 "This package provides the firmware for the Keychron Q9 ISO with default keymap and with encoder."))
2299
2300(define-public qmk-firmware-keychron-q9-plus-ansi-encoder-default
2301 (make-qmk-firmware-keychron "keychron/q9_plus/ansi_encoder" "default"
2302 #:description
2303 "This package provides the firmware for the Keychron Q9 Plus ANSI with default keymap and with encoder."))
2304
2305(define-public qmk-firmware-keychron-s1-ansi-rgb-default
2306 (make-qmk-firmware-keychron "keychron/s1/ansi/rgb" "default"
2307 #:description
2308 "This package provides the firmware for the Keychron S1 ANSI RGB with default keymap."))
2309
2310(define-public qmk-firmware-keychron-s1-ansi-white-default
2311 (make-qmk-firmware-keychron "keychron/s1/ansi/white" "default"
2312 #:description
2313 "This package provides the firmware for the Keychron S1 ANSI white with default keymap."))
2314
2315(define-public qmk-firmware-keychron-v10-ansi-encoder-default
2316 (make-qmk-firmware-keychron "keychron/v10/ansi_encoder" "default"
2317 #:description
2318 "This package provides the firmware for the Keychron V10 ANSI with default keymap and with encoder."))
2319
2320(define-public qmk-firmware-keychron-v10-iso-encoder-default
2321 (make-qmk-firmware-keychron "keychron/v10/iso_encoder" "default"
2322 #:description
2323 "This package provides the firmware for the Keychron V10 ISO with default keymap and with encoder."))
2324
2325(define-public qmk-firmware-keychron-v1-ansi-default
2326 (make-qmk-firmware-keychron "keychron/v1/ansi" "default"
2327 #:description
2328 "This package provides the firmware for the Keychron V1 ANSI with default keymap."))
2329
2330(define-public qmk-firmware-keychron-v1-ansi-encoder-default
2331 (make-qmk-firmware-keychron "keychron/v1/ansi_encoder" "default"
2332 #:description
2333 "This package provides the firmware for the Keychron V1 ANSI with default keymap and with encoder."))
2334
2335(define-public qmk-firmware-keychron-v1-iso-default
2336 (make-qmk-firmware-keychron "keychron/v1/iso" "default"
2337 #:description
2338 "This package provides the firmware for the Keychron V1 ISO with default keymap."))
2339
2340(define-public qmk-firmware-keychron-v1-iso-encoder-default
2341 (make-qmk-firmware-keychron "keychron/v1/iso_encoder" "default"
2342 #:description
2343 "This package provides the firmware for the Keychron V1 ISO with default keymap and with encoder."))
2344
2345(define-public qmk-firmware-keychron-v1-jis-default
2346 (make-qmk-firmware-keychron "keychron/v1/jis" "default"
2347 #:description
2348 "This package provides the firmware for the Keychron V1 JIS with default keymap."))
2349
2350(define-public qmk-firmware-keychron-v1-jis-encoder-default
2351 (make-qmk-firmware-keychron "keychron/v1/jis_encoder" "default"
2352 #:description
2353 "This package provides the firmware for the Keychron V1 JIS with default keymap and with encoder."))
2354
2355(define-public qmk-firmware-keychron-v2-ansi-default
2356 (make-qmk-firmware-keychron "keychron/v2/ansi" "default"
2357 #:description
2358 "This package provides the firmware for the Keychron V2 ANSI with default keymap."))
2359
2360(define-public qmk-firmware-keychron-v2-ansi-encoder-default
2361 (make-qmk-firmware-keychron "keychron/v2/ansi_encoder" "default"
2362 #:description
2363 "This package provides the firmware for the Keychron V2-ansi-encoder with default keymap."))
2364
2365(define-public qmk-firmware-keychron-v2-iso-default
2366 (make-qmk-firmware-keychron "keychron/v2/iso" "default"
2367 #:description
2368 "This package provides the firmware for the Keychron V2 ISO with default keymap."))
2369
2370(define-public qmk-firmware-keychron-v2-iso-encoder-default
2371 (make-qmk-firmware-keychron "keychron/v2/iso_encoder" "default"
2372 #:description
2373 "This package provides the firmware for the Keychron V2 ISO with default keymap and with encoder."))
2374
2375(define-public qmk-firmware-keychron-v2-jis-default
2376 (make-qmk-firmware-keychron "keychron/v2/jis" "default"
2377 #:description
2378 "This package provides the firmware for the Keychron V2 JIS with default keymap."))
2379
2380(define-public qmk-firmware-keychron-v2-jis-encoder-default
2381 (make-qmk-firmware-keychron "keychron/v2/jis_encoder" "default"
2382 #:description
2383 "This package provides the firmware for the Keychron V2 JIS with default keymap and with encoder."))
2384
2385(define-public qmk-firmware-keychron-v3-ansi-default
2386 (make-qmk-firmware-keychron "keychron/v3/ansi" "default"
2387 #:description
2388 "This package provides the firmware for the Keychron V3 ANSI with default keymap."))
2389
2390(define-public qmk-firmware-keychron-v3-iso-default
2391 (make-qmk-firmware-keychron "keychron/v3/iso" "default"
2392 #:description
2393 "This package provides the firmware for the Keychron V3 ISO with default keymap."))
2394
2395(define-public qmk-firmware-keychron-v3-jis-default
2396 (make-qmk-firmware-keychron "keychron/v3/jis" "default"
2397 #:description
2398 "This package provides the firmware for the Keychron V3 JIS with default keymap."))
2399
2400(define-public qmk-firmware-keychron-v3-ansi-encoder-default
2401 (make-qmk-firmware-keychron "keychron/v3/ansi_encoder" "default"
2402 #:description
2403 "This package provides the firmware for the Keychron V3 ANSI with default keymap and with an encoder."))
2404
2405(define-public qmk-firmware-keychron-v3-iso-encoder-default
2406 (make-qmk-firmware-keychron "keychron/v3/iso_encoder" "default"
2407 #:description
2408 "This package provides the firmware for the Keychron V3 ISO with default keymap and with encoder."))
2409
2410(define-public qmk-firmware-keychron-v3-jis-encoder-default
2411 (make-qmk-firmware-keychron "keychron/v3/jis_encoder" "default"
2412 #:description
2413 "This package provides the firmware for the Keychron V3 JIS with default keymap and with encoder."))
2414
2415(define-public qmk-firmware-keychron-v4-ansi-default
2416 (make-qmk-firmware-keychron "keychron/v4/ansi" "default"
2417 #:description
2418 "This package provides the firmware for the Keychron V4 ANSI with default keymap."))
2419
2420(define-public qmk-firmware-keychron-v4-iso-default
2421 (make-qmk-firmware-keychron "keychron/v4/iso" "default"
2422 #:description
2423 "This package provides the firmware for the Keychron V4 ISO with default keymap."))
2424
2425(define-public qmk-firmware-keychron-v5-ansi-default
2426 (make-qmk-firmware-keychron "keychron/v5/ansi" "default"
2427 #:description
2428 "This package provides the firmware for the Keychron V5 ANSI with default keymap."))
2429
2430(define-public qmk-firmware-keychron-v5-ansi-encoder-default
2431 (make-qmk-firmware-keychron "keychron/v5/ansi_encoder" "default"
2432 #:description
2433 "This package provides the firmware for the Keychron V5 ANSI with default keymap and with encoder."))
2434
2435(define-public qmk-firmware-keychron-v5-iso-default
2436 (make-qmk-firmware-keychron "keychron/v5/iso" "default"
2437 #:description
2438 "This package provides the firmware for the Keychron V5 ISO with default keymap."))
2439
2440(define-public qmk-firmware-keychron-v5-iso-encoder-default
2441 (make-qmk-firmware-keychron "keychron/v5/iso_encoder" "default"
2442 #:description
2443 "This package provides the firmware for the Keychron V5 ISO with default keymap and with encoder."))
2444
2445(define-public qmk-firmware-keychron-v6-ansi-default
2446 (make-qmk-firmware-keychron "keychron/v6/ansi" "default"
2447 #:description
2448 "This package provides the firmware for the Keychron V6 ANSI with default keymap."))
2449
2450(define-public qmk-firmware-keychron-v6-ansi-encoder-default
2451 (make-qmk-firmware-keychron "keychron/v6/ansi_encoder" "default"
2452 #:description
2453 "This package provides the firmware for the Keychron V6 ANSI with default keymap and with encoder."))
2454
2455(define-public qmk-firmware-keychron-v6-iso-default
2456 (make-qmk-firmware-keychron "keychron/v6/iso" "default"
2457 #:description
2458 "This package provides the firmware for the Keychron V6 ISO with default keymap."))
2459
2460(define-public qmk-firmware-keychron-v6-iso-encoder-default
2461 (make-qmk-firmware-keychron "keychron/v6/iso_encoder" "default"
2462 #:description
2463 "This package provides the firmware for the Keychron V6 ISO with default keymap and with encoder."))
2464
2465(define-public qmk-firmware-keychron-v7-ansi-default
2466 (make-qmk-firmware-keychron "keychron/v7/ansi" "default"
2467 #:description
2468 "This package provides the firmware for the Keychron V7 ANSI with default keymap."))
2469
2470(define-public qmk-firmware-keychron-v7-iso-default
2471 (make-qmk-firmware-keychron "keychron/v7/iso" "default"
2472 #:description
2473 "This package provides the firmware for the Keychron V7 ISO with default keymap."))
2474
2475(define-public qmk-firmware-keychron-v8-ansi-default
2476 (make-qmk-firmware-keychron "keychron/v8/ansi" "default"
2477 #:description
2478 "This package provides the firmware for the Keychron V8 ANSI with default keymap."))
2479
2480(define-public qmk-firmware-keychron-v8-ansi-encoder-default
2481 (make-qmk-firmware-keychron "keychron/v8/ansi_encoder" "default"
2482 #:description
2483 "This package provides the firmware for the Keychron V8 ANSI with default keymap and with encoder."))
2484
2485(define-public qmk-firmware-keychron-v8-iso-default
2486 (make-qmk-firmware-keychron "keychron/v8/iso" "default"
2487 #:description
2488 "This package provides the firmware for the Keychron V8 ISO with default keymap."))
2489
2490(define-public qmk-firmware-keychron-v8-iso-encoder-default
2491 (make-qmk-firmware-keychron "keychron/v8/iso_encoder" "default"
2492 #:description
2493 "This package provides the firmware for the Keychron V8 ISO with default keymap and with encoder."))
2494
2495(define-public firmware-senoko
2496 (package
2497 (name "firmware-senoko")
2498 (version "2.6")
2499 (source (origin
2500 (method git-fetch)
2501 (uri (git-reference
2502 (url "https://github.com/novena-next/firmware-senoko.git")
2503 (commit (string-append "v" version))))
2504 (file-name (git-file-name name version))
2505 (sha256
2506 (base32
2507 "10d6bgqajl0w17xydjv2x22n5m9d1xsjb09r430nakc1v6gn52d5"))))
2508 (build-system copy-build-system)
2509 (arguments
2510 (list #:phases
2511 #~(modify-phases %standard-phases
2512 (add-after 'unpack 'patch
2513 (lambda* (#:key inputs #:allow-other-keys)
2514 (substitute* "update-senoko"
2515 (("^fw=/lib/firmware/senoko.hex")
2516 (string-append "fw="
2517 (assoc-ref inputs "senoko-chibios")
2518 "/lib/firmware/senoko.hex")))
2519 (patch-shebang "update-senoko"))))
2520 #:install-plan
2521 ''(("update-senoko" "bin/")
2522 ("update-senoko.1" "share/man/man1/"))))
2523 (inputs
2524 (list senoko-chibios))
2525 (synopsis "Firmware flasher for Novena battery or passthrough board")
2526 (description "This package provides a way to update the Novena battery or
2527passthrough board firmware on a Novena.")
2528 (supported-systems '("armhf-linux"))
2529 (home-page "https://github.com/novena-next/firmware-senoko")
2530 (license license:bsd-3)))