projects/guix·blob ruby-team · refs

2521 lines · 108.0 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 (inherit qmk-firmware-ergodox-ez-default)
1842 (name "qmk-udev-rules")
1843 (version "0.22.3")
1844 (source (origin
1845 (method git-fetch)
1846 (uri (git-reference
1847 (url "https://github.com/qmk/qmk_firmware")
1848 (commit version)))
1849 (file-name (git-file-name "qmk-firmware" version))
1850 (sha256
1851 (base32
1852 "0s1lcnv7cddpn768p7mrc5bkxhx0ba5p77ya007dnkbk36c33d0w"))))
1853 (build-system copy-build-system)
1854 (arguments
1855 '(#:install-plan '(("./util/udev" "lib/udev/rules.d"
1856 #:include-regexp ("rules$")))))
1857 (native-inputs '())
1858 (inputs '())
1859 (propagated-inputs '())
1860 (synopsis "Udev rules for QMK Firmware")
1861 (description
1862 "This package provides a set of udev rules to specify the proper
1863privileges for flashing QMK compatible devices without needing root. The
1864rules require the group @code{plugdev} to be added to each user that needs
1865this.")))
1866
1867(define-public senoko-chibios
1868 (package
1869 (name "senoko-chibios")
1870 (version "2.5")
1871 (source (origin
1872 (method git-fetch)
1873 (uri (git-reference
1874 (url "https://github.com/xobs/senoko-chibios-3.git")
1875 (commit (string-append "v" version))))
1876 (file-name (git-file-name name version))
1877 (sha256
1878 (base32
1879 "1qdpxzqdh0l65rzfbrm1lqzpik3nyg8wa7k0b8b6apj2w6vsp5pv"))))
1880 (build-system gnu-build-system)
1881 (arguments
1882 (list #:tests? #f ; no tests
1883 #:make-flags #~(list "USE_VERBOSE_COMPILE=yes")
1884 #:phases
1885 #~(modify-phases %standard-phases
1886 (delete 'configure)
1887 (add-after 'unpack 'patch
1888 (lambda* (#:key outputs #:allow-other-keys)
1889 (chdir "senoko")
1890 (substitute* "Makefile"
1891 ;; We don't have those dependencies since we delete .git
1892 ;; after checkout.
1893 ((" [$][(]CHIBIOS[)]/.git/HEAD [$][(]CHIBIOS[)]/.git/index")
1894 "")
1895 (("[$][(]shell git rev-parse HEAD[)]")
1896 ;; Uniquely identify the version.
1897 (assoc-ref outputs "out")))))
1898 (replace 'install
1899 (lambda* (#:key outputs #:allow-other-keys)
1900 (let ((destination (string-append (assoc-ref outputs "out")
1901 "/lib/firmware")))
1902 (install-file "build/senoko.elf" destination)
1903 (install-file "build/senoko.hex" destination)))))))
1904 (synopsis "Firmware for Novena battery or passthrough board")
1905 (description "This package provides the firmware for the Novena battery
1906or passthrough board.")
1907 (supported-systems '("armhf-linux")) ; actually cortex-m3
1908 (home-page "https://github.com/xobs/senoko-chibios-3/")
1909 (license license:gpl3+)))
1910
1911(define (make-qmk-newlib-nano-arm-none-eabi)
1912 (let ((base (make-newlib-nano-arm-none-eabi)))
1913 (package
1914 (inherit base)
1915 (native-inputs
1916 (modify-inputs native-inputs
1917 (replace "xgcc" (make-gcc-arm-none-eabi-12.3.rel1)))))))
1918
1919(define* (make-qmk-firmware-keychron keyboard keymap
1920 #:key (description "")
1921 keymap-json
1922 keymap-source-directory
1923 keyboard-source-directory)
1924 (let ((base (make-qmk-firmware keyboard keymap
1925 #:description description
1926 #:keymap-json keymap-json
1927 #:keymap-source-directory keymap-source-directory
1928 #:keyboard-source-directory keyboard-source-directory)))
1929 (package
1930 (inherit base)
1931 (name (string-append "qmk-firmware-"
1932 (regexp-substitute/global #f "[_/]" keyboard
1933 'pre "-" 'post)
1934 "-"
1935 (string-replace-substring keymap "_" "-")))
1936 ;; Note: When updating this package, make sure to also update the commit
1937 ;; used for the LUFA submodule in the 'copy-lufa-source' phase below.
1938 (version "0.28.0")
1939 (source (origin
1940 (method git-fetch)
1941 (uri (git-reference
1942 (url "https://github.com/qmk/qmk_firmware")
1943 (commit version)))
1944 (file-name (git-file-name "qmk-firmware" version))
1945 (sha256
1946 (base32
1947 "1skj7iq6dad48xhy2ljjmwpbhhdv3gk7cmi28lh3xfsnxphm4v8r"))))
1948 (arguments
1949 (substitute-keyword-arguments arguments
1950 ((#:phases phases)
1951 #~(modify-phases #$phases
1952 (replace 'copy-lufa-source
1953 ;; QMK carries a custom fork of LUFA as a git submodule; make sure
1954 ;; the same commit is used (see:
1955 ;; https://github.com/qmk/qmk_firmware/tree/master/lib).
1956 (lambda _
1957 (copy-recursively
1958 #$(let ((commit "549b97320d515bfca2f95c145a67bd13be968faa"))
1959 (origin
1960 (inherit (package-source lufa))
1961 (uri (git-reference
1962 (url "https://github.com/qmk/lufa")
1963 (commit commit)))
1964 (file-name (git-file-name "lufa" commit))
1965 (sha256
1966 (base32
1967 "1rmhm4rxvq8skxqn6vc4n4ly1ak6whj7c386zbsci4pxx548n9h4"))))
1968 "lib/lufa")))
1969 (add-after 'unpack 'setenv
1970 (lambda _
1971 ;; Because newlib-nano is also compiled without FPU.
1972 (setenv "USE_FPU" "no")))
1973 (add-after 'unpack 'copy-chibios-source
1974 (lambda _
1975 ;; Newest version.
1976 (copy-recursively
1977 #$(origin
1978 (method git-fetch)
1979 (uri (git-reference
1980 (url "https://github.com/qmk/ChibiOS")
1981 (commit "2365f844292513ea0ee9eea6ab778d56f9ccd3b9")))
1982 ;(file-name (git-file-name name version))
1983 (sha256
1984 (base32
1985 "1ivkrx4nv0sa4nfryzbq5h40vs7vik8p0dp9czjh2srql520y7yq")))
1986 "lib/chibios")))
1987 (add-after 'unpack 'copy-printf-source
1988 ;; Newest version.
1989 (lambda _
1990 (copy-recursively
1991 #$(origin
1992 (method git-fetch)
1993 (uri (git-reference
1994 (url "https://github.com/qmk/printf.git")
1995 (commit "c2e3b4e10d281e7f0f694d3ecbd9f320977288cc")))
1996 ;(file-name (git-file-name name version))
1997 (sha256
1998 (base32
1999 "0r501hkk0idwfm6qs09g1wb808ga452gz39dw32x13rmg3a901s6")))
2000 "lib/printf")))))))
2001 (native-inputs
2002 (modify-inputs native-inputs
2003 (prepend
2004 (package
2005 (inherit (make-qmk-newlib-nano-arm-none-eabi))
2006 (native-search-paths
2007 (list (search-path-specification
2008 (variable "CROSS_C_INCLUDE_PATH")
2009 (files '("arm-none-eabi/include")))
2010 (search-path-specification
2011 (variable "CROSS_CPLUS_INCLUDE_PATH")
2012 (files '("arm-none-eabi/include"
2013 "arm-none-eabi/include/c++"
2014 "arm-none-eabi/include/c++/arm-none-eabi")))
2015 (search-path-specification
2016 (variable "CROSS_LIBRARY_PATH")
2017 (files '("arm-none-eabi/lib"))))))
2018 (make-gcc-arm-none-eabi-12.3.rel1)
2019 (cross-binutils "arm-none-eabi")))))))
2020
2021(define-public qmk-firmware-keychron-c1-pro-ansi-rgb-default
2022 (make-qmk-firmware-keychron "keychron/c1_pro/ansi/rgb" "default"
2023 #:description
2024 "This package provides the firmware for the Keychron C1 Pro ANSI RGB with default keymap."))
2025
2026(define-public qmk-firmware-keychron-c1-pro-ansi-white-default
2027 (make-qmk-firmware-keychron "keychron/c1_pro/ansi/white" "default"
2028 #:description
2029 "This package provides the firmware for the Keychron C1 Pro ANSI white with default keymap."))
2030
2031(define-public qmk-firmware-keychron-c2-pro-ansi-rgb-default
2032 (make-qmk-firmware-keychron "keychron/c2_pro/ansi/rgb" "default"
2033 #:description
2034 "This package provides the firmware for the Keychron C2 Pro ANSI RGB with default keymap."))
2035
2036(define-public qmk-firmware-keychron-c2-pro-ansi-white-default
2037 (make-qmk-firmware-keychron "keychron/c2_pro/ansi/white" "default"
2038 #:description
2039 "This package provides the firmware for the Keychron C2 Pro ANSI white with default keymap."))
2040
2041(define-public qmk-firmware-keychron-c3-pro-ansi-red-default
2042 (make-qmk-firmware-keychron "keychron/c3_pro/ansi/red" "default"
2043 #:description
2044 "This package provides the firmware for the Keychron C3 Pro ANSI Red with default keymap."))
2045
2046(define-public qmk-firmware-keychron-c3-pro-ansi-rgb-default
2047 (make-qmk-firmware-keychron "keychron/c3_pro/ansi/rgb" "default"
2048 #:description
2049 "This package provides the firmware for the Keychron C3 Pro ANSI RGB with default keymap."))
2050
2051(define-public qmk-firmware-keychron-q0-base-default
2052 (make-qmk-firmware-keychron "keychron/q0/base" "default"
2053 #:description
2054 "This package provides the firmware for the Keychron Q0 Base with default keymap."))
2055
2056(define-public qmk-firmware-keychron-q0-plus-default
2057 (make-qmk-firmware-keychron "keychron/q0/plus" "default"
2058 #:description
2059 "This package provides the firmware for the Keychron Q0 Plus with default keymap."))
2060
2061(define-public qmk-firmware-keychron-q10-ansi-encoder-default
2062 (make-qmk-firmware-keychron "keychron/q10/ansi_encoder" "default"
2063 #:description
2064 "This package provides the firmware for the Keychron Q10 ANSI with default keymap and with encoder."))
2065
2066(define-public qmk-firmware-keychron-q10-iso-encoder-default
2067 (make-qmk-firmware-keychron "keychron/q10/iso_encoder" "default"
2068 #:description
2069 "This package provides the firmware for the Keychron Q10 ISO with default keymap and with encoder."))
2070
2071(define-public qmk-firmware-keychron-q11-ansi-encoder-default
2072 (make-qmk-firmware-keychron "keychron/q11/ansi_encoder" "default"
2073 #:description
2074 "This package provides the firmware for the Keychron Q11 ANSI with default keymap and with encoder."))
2075
2076(define-public qmk-firmware-keychron-q11-iso-encoder-default
2077 (make-qmk-firmware-keychron "keychron/q11/iso_encoder" "default"
2078 #:description
2079 "This package provides the firmware for the Keychron Q11 ISO with default keymap and with encoder."))
2080
2081(define-public qmk-firmware-keychron-q12-ansi-encoder-default
2082 (make-qmk-firmware-keychron "keychron/q12/ansi_encoder" "default"
2083 #:description
2084 "This package provides the firmware for the Keychron Q12 ANSI with default keymap and with encoder."))
2085
2086(define-public qmk-firmware-keychron-q12-iso-encoder-default
2087 (make-qmk-firmware-keychron "keychron/q12/iso_encoder" "default"
2088 #:description
2089 "This package provides the firmware for the Keychron Q12 ISO with default keymap and with encoder."))
2090
2091(define-public qmk-firmware-keychron-q1v2-ansi-default
2092 (make-qmk-firmware-keychron "keychron/q1v2/ansi" "default"
2093 #:description
2094 "This package provides the firmware for the Keychron Q1v2 ANSI with default keymap."))
2095
2096(define-public qmk-firmware-keychron-q1v2-ansi-encoder-default
2097 (make-qmk-firmware-keychron "keychron/q1v2/ansi_encoder" "default"
2098 #:description
2099 "This package provides the firmware for the Keychron Q1v2 ANSI with default keymap and with encoder."))
2100
2101(define-public qmk-firmware-keychron-q1v2-iso-default
2102 (make-qmk-firmware-keychron "keychron/q1v2/iso" "default"
2103 #:description
2104 "This package provides the firmware for the Keychron Q1v2 ISO with default keymap."))
2105
2106(define-public qmk-firmware-keychron-q1v2-iso-encoder-default
2107 (make-qmk-firmware-keychron "keychron/q1v2/iso_encoder" "default"
2108 #:description
2109 "This package provides the firmware for the Keychron Q1v2 ISO with default keymap and with encoder."))
2110
2111(define-public qmk-firmware-keychron-q1v2-jis-default
2112 (make-qmk-firmware-keychron "keychron/q1v2/jis" "default"
2113 #:description
2114 "This package provides the firmware for the Keychron Q1v2 JIS with default keymap."))
2115
2116(define-public qmk-firmware-keychron-q1v2-jis-encoder-default
2117 (make-qmk-firmware-keychron "keychron/q1v2/jis_encoder" "default"
2118 #:description
2119 "This package provides the firmware for the Keychron Q1v2 JIS with default keymap and with encoder."))
2120
2121(define-public qmk-firmware-keychron-q2-ansi-default
2122 (make-qmk-firmware-keychron "keychron/q2/ansi" "default"
2123 #:description
2124 "This package provides the firmware for the Keychron Q2 ANSI with default keymap."))
2125
2126(define-public qmk-firmware-keychron-q2-ansi-encoder-default
2127 (make-qmk-firmware-keychron "keychron/q2/ansi_encoder" "default"
2128 #:description
2129 "This package provides the firmware for the Keychron Q2 ANSI with default keymap and with encoder."))
2130
2131(define-public qmk-firmware-keychron-q2-iso-default
2132 (make-qmk-firmware-keychron "keychron/q2/iso" "default"
2133 #:description
2134 "This package provides the firmware for the Keychron Q2 ISO with default keymap."))
2135
2136(define-public qmk-firmware-keychron-q2-iso-encoder-default
2137 (make-qmk-firmware-keychron "keychron/q2/iso_encoder" "default"
2138 #:description
2139 "This package provides the firmware for the Keychron Q2 ISO with default keymap and with encoder."))
2140
2141(define-public qmk-firmware-keychron-q2-jis-default
2142 (make-qmk-firmware-keychron "keychron/q2/jis" "default"
2143 #:description
2144 "This package provides the firmware for the Keychron Q2 JIS with default keymap."))
2145
2146(define-public qmk-firmware-keychron-q2-jis-encoder-default
2147 (make-qmk-firmware-keychron "keychron/q2/jis_encoder" "default"
2148 #:description
2149 "This package provides the firmware for the Keychron Q2 JIS with default keymap and with encoder."))
2150
2151(define-public qmk-firmware-keychron-q3-ansi-default
2152 (make-qmk-firmware-keychron "keychron/q3/ansi" "default"
2153 #:description
2154 "This package provides the firmware for the Keychron Q3 ANSI with default keymap."))
2155
2156(define-public qmk-firmware-keychron-q3-ansi-encoder-default
2157 (make-qmk-firmware-keychron "keychron/q3/ansi_encoder" "default"
2158 #:description
2159 "This package provides the firmware for the Keychron Q3 ANSI with default keymap and with encoder."))
2160
2161(define-public qmk-firmware-keychron-q3-iso-default
2162 (make-qmk-firmware-keychron "keychron/q3/iso" "default"
2163 #:description
2164 "This package provides the firmware for the Keychron Q3 ISO with default keymap."))
2165
2166(define-public qmk-firmware-keychron-q3-iso-encoder-default
2167 (make-qmk-firmware-keychron "keychron/q3/iso_encoder" "default"
2168 #:description
2169 "This package provides the firmware for the Keychron Q3 ISO with default keymap and with encoder."))
2170
2171(define-public qmk-firmware-keychron-q3-jis-default
2172 (make-qmk-firmware-keychron "keychron/q3/jis" "default"
2173 #:description
2174 "This package provides the firmware for the Keychron Q3 JIS with default keymap."))
2175
2176(define-public qmk-firmware-keychron-q3-jis-encoder-default
2177 (make-qmk-firmware-keychron "keychron/q3/jis_encoder" "default"
2178 #:description
2179 "This package provides the firmware for the Keychron Q3 JIS with default keymap and with encoder."))
2180
2181(define-public qmk-firmware-keychron-q4-ansi-v2-default
2182 (make-qmk-firmware-keychron "keychron/q4/ansi/v2" "default"
2183 #:description
2184 "This package provides the firmware for the Keychron Q4 ANSI with default keymap."))
2185
2186(define-public qmk-firmware-keychron-q4-iso-default
2187 (make-qmk-firmware-keychron "keychron/q4/iso" "default"
2188 #:description
2189 "This package provides the firmware for the Keychron Q4 ISO with default keymap."))
2190
2191(define-public qmk-firmware-keychron-q5-ansi-default
2192 (make-qmk-firmware-keychron "keychron/q5/ansi" "default"
2193 #:description
2194 "This package provides the firmware for the Keychron Q5 ANSI with default keymap."))
2195
2196(define-public qmk-firmware-keychron-q5-ansi-encoder-default
2197 (make-qmk-firmware-keychron "keychron/q5/ansi_encoder" "default"
2198 #:description
2199 "This package provides the firmware for the Keychron Q5 ANSI with default keymap and with encoder."))
2200
2201(define-public qmk-firmware-keychron-q5-iso-default
2202 (make-qmk-firmware-keychron "keychron/q5/iso" "default"
2203 #:description
2204 "This package provides the firmware for the Keychron Q5 ISO with default keymap."))
2205
2206(define-public qmk-firmware-keychron-q5-iso-encoder-default
2207 (make-qmk-firmware-keychron "keychron/q5/iso_encoder" "default"
2208 #:description
2209 "This package provides the firmware for the Keychron Q5 ISO with default keymap and with encoder."))
2210
2211(define-public qmk-firmware-keychron-q60-ansi-default
2212 (make-qmk-firmware-keychron "keychron/q60/ansi" "default"
2213 #:description
2214 "This package provides the firmware for the Keychron Q60 ANSI with default keymap."))
2215
2216(define-public qmk-firmware-keychron-q65-ansi-encoder-default
2217 (make-qmk-firmware-keychron "keychron/q65/ansi_encoder" "default"
2218 #:description
2219 "This package provides the firmware for the Keychron Q65 ANSI with default keymap and with encoder."))
2220
2221(define-public qmk-firmware-keychron-q6-ansi-default
2222 (make-qmk-firmware-keychron "keychron/q6/ansi" "default"
2223 #:description
2224 "This package provides the firmware for the Keychron Q6 ANSI with default keymap."))
2225
2226(define-public qmk-firmware-keychron-q6-ansi-encoder-default
2227 (make-qmk-firmware-keychron "keychron/q6/ansi_encoder" "default"
2228 #:description
2229 "This package provides the firmware for the Keychron Q6 ANSI with default keymap and with encoder."))
2230
2231(define-public qmk-firmware-keychron-q6-iso-default
2232 (make-qmk-firmware-keychron "keychron/q6/iso" "default"
2233 #:description
2234 "This package provides the firmware for the Keychron Q6 ISO with default keymap."))
2235
2236(define-public qmk-firmware-keychron-q6-iso-encoder-default
2237 (make-qmk-firmware-keychron "keychron/q6/iso_encoder" "default"
2238 #:description
2239 "This package provides the firmware for the Keychron Q6 ISO with default keymap and with encoder."))
2240
2241(define-public qmk-firmware-keychron-q7-ansi-default
2242 (make-qmk-firmware-keychron "keychron/q7/ansi" "default"
2243 #:description
2244 "This package provides the firmware for the Keychron Q7 ANSI with default keymap."))
2245
2246(define-public qmk-firmware-keychron-q7-iso-default
2247 (make-qmk-firmware-keychron "keychron/q7/iso" "default"
2248 #:description
2249 "This package provides the firmware for the Keychron Q7 ISO with default keymap."))
2250
2251(define-public qmk-firmware-keychron-q8-ansi-default
2252 (make-qmk-firmware-keychron "keychron/q8/ansi" "default"
2253 #:description
2254 "This package provides the firmware for the Keychron Q8 ANSI with default keymap."))
2255
2256(define-public qmk-firmware-keychron-q8-ansi-encoder-default
2257 (make-qmk-firmware-keychron "keychron/q8/ansi_encoder" "default"
2258 #:description
2259 "This package provides the firmware for the Keychron Q8 ANSI with default keymap and with encoder."))
2260
2261(define-public qmk-firmware-keychron-q8-iso-default
2262 (make-qmk-firmware-keychron "keychron/q8/iso" "default"
2263 #:description
2264 "This package provides the firmware for the Keychron Q8 ISO with default keymap."))
2265
2266(define-public qmk-firmware-keychron-q8-iso-encoder-default
2267 (make-qmk-firmware-keychron "keychron/q8/iso_encoder" "default"
2268 #:description
2269 "This package provides the firmware for the Keychron Q8 ISO with default keymap and with encoder."))
2270
2271(define-public qmk-firmware-keychron-q9-ansi-default
2272 (make-qmk-firmware-keychron "keychron/q9/ansi" "default"
2273 #:description
2274 "This package provides the firmware for the Keychron Q9 ANSI with default keymap."))
2275
2276(define-public qmk-firmware-keychron-q9-ansi-encoder-default
2277 (make-qmk-firmware-keychron "keychron/q9/ansi_encoder" "default"
2278 #:description
2279 "This package provides the firmware for the Keychron Q9 ANSI with default keymap and with encoder."))
2280
2281(define-public qmk-firmware-keychron-q9-iso-default
2282 (make-qmk-firmware-keychron "keychron/q9/iso" "default"
2283 #:description
2284 "This package provides the firmware for the Keychron Q9 ISO with default keymap."))
2285
2286(define-public qmk-firmware-keychron-q9-iso-encoder-default
2287 (make-qmk-firmware-keychron "keychron/q9/iso_encoder" "default"
2288 #:description
2289 "This package provides the firmware for the Keychron Q9 ISO with default keymap and with encoder."))
2290
2291(define-public qmk-firmware-keychron-q9-plus-ansi-encoder-default
2292 (make-qmk-firmware-keychron "keychron/q9_plus/ansi_encoder" "default"
2293 #:description
2294 "This package provides the firmware for the Keychron Q9 Plus ANSI with default keymap and with encoder."))
2295
2296(define-public qmk-firmware-keychron-s1-ansi-rgb-default
2297 (make-qmk-firmware-keychron "keychron/s1/ansi/rgb" "default"
2298 #:description
2299 "This package provides the firmware for the Keychron S1 ANSI RGB with default keymap."))
2300
2301(define-public qmk-firmware-keychron-s1-ansi-white-default
2302 (make-qmk-firmware-keychron "keychron/s1/ansi/white" "default"
2303 #:description
2304 "This package provides the firmware for the Keychron S1 ANSI white with default keymap."))
2305
2306(define-public qmk-firmware-keychron-v10-ansi-encoder-default
2307 (make-qmk-firmware-keychron "keychron/v10/ansi_encoder" "default"
2308 #:description
2309 "This package provides the firmware for the Keychron V10 ANSI with default keymap and with encoder."))
2310
2311(define-public qmk-firmware-keychron-v10-iso-encoder-default
2312 (make-qmk-firmware-keychron "keychron/v10/iso_encoder" "default"
2313 #:description
2314 "This package provides the firmware for the Keychron V10 ISO with default keymap and with encoder."))
2315
2316(define-public qmk-firmware-keychron-v1-ansi-default
2317 (make-qmk-firmware-keychron "keychron/v1/ansi" "default"
2318 #:description
2319 "This package provides the firmware for the Keychron V1 ANSI with default keymap."))
2320
2321(define-public qmk-firmware-keychron-v1-ansi-encoder-default
2322 (make-qmk-firmware-keychron "keychron/v1/ansi_encoder" "default"
2323 #:description
2324 "This package provides the firmware for the Keychron V1 ANSI with default keymap and with encoder."))
2325
2326(define-public qmk-firmware-keychron-v1-iso-default
2327 (make-qmk-firmware-keychron "keychron/v1/iso" "default"
2328 #:description
2329 "This package provides the firmware for the Keychron V1 ISO with default keymap."))
2330
2331(define-public qmk-firmware-keychron-v1-iso-encoder-default
2332 (make-qmk-firmware-keychron "keychron/v1/iso_encoder" "default"
2333 #:description
2334 "This package provides the firmware for the Keychron V1 ISO with default keymap and with encoder."))
2335
2336(define-public qmk-firmware-keychron-v1-jis-default
2337 (make-qmk-firmware-keychron "keychron/v1/jis" "default"
2338 #:description
2339 "This package provides the firmware for the Keychron V1 JIS with default keymap."))
2340
2341(define-public qmk-firmware-keychron-v1-jis-encoder-default
2342 (make-qmk-firmware-keychron "keychron/v1/jis_encoder" "default"
2343 #:description
2344 "This package provides the firmware for the Keychron V1 JIS with default keymap and with encoder."))
2345
2346(define-public qmk-firmware-keychron-v2-ansi-default
2347 (make-qmk-firmware-keychron "keychron/v2/ansi" "default"
2348 #:description
2349 "This package provides the firmware for the Keychron V2 ANSI with default keymap."))
2350
2351(define-public qmk-firmware-keychron-v2-ansi-encoder-default
2352 (make-qmk-firmware-keychron "keychron/v2/ansi_encoder" "default"
2353 #:description
2354 "This package provides the firmware for the Keychron V2-ansi-encoder with default keymap."))
2355
2356(define-public qmk-firmware-keychron-v2-iso-default
2357 (make-qmk-firmware-keychron "keychron/v2/iso" "default"
2358 #:description
2359 "This package provides the firmware for the Keychron V2 ISO with default keymap."))
2360
2361(define-public qmk-firmware-keychron-v2-iso-encoder-default
2362 (make-qmk-firmware-keychron "keychron/v2/iso_encoder" "default"
2363 #:description
2364 "This package provides the firmware for the Keychron V2 ISO with default keymap and with encoder."))
2365
2366(define-public qmk-firmware-keychron-v2-jis-default
2367 (make-qmk-firmware-keychron "keychron/v2/jis" "default"
2368 #:description
2369 "This package provides the firmware for the Keychron V2 JIS with default keymap."))
2370
2371(define-public qmk-firmware-keychron-v2-jis-encoder-default
2372 (make-qmk-firmware-keychron "keychron/v2/jis_encoder" "default"
2373 #:description
2374 "This package provides the firmware for the Keychron V2 JIS with default keymap and with encoder."))
2375
2376(define-public qmk-firmware-keychron-v3-ansi-default
2377 (make-qmk-firmware-keychron "keychron/v3/ansi" "default"
2378 #:description
2379 "This package provides the firmware for the Keychron V3 ANSI with default keymap."))
2380
2381(define-public qmk-firmware-keychron-v3-iso-default
2382 (make-qmk-firmware-keychron "keychron/v3/iso" "default"
2383 #:description
2384 "This package provides the firmware for the Keychron V3 ISO with default keymap."))
2385
2386(define-public qmk-firmware-keychron-v3-jis-default
2387 (make-qmk-firmware-keychron "keychron/v3/jis" "default"
2388 #:description
2389 "This package provides the firmware for the Keychron V3 JIS with default keymap."))
2390
2391(define-public qmk-firmware-keychron-v3-ansi-encoder-default
2392 (make-qmk-firmware-keychron "keychron/v3/ansi_encoder" "default"
2393 #:description
2394 "This package provides the firmware for the Keychron V3 ANSI with default keymap and with an encoder."))
2395
2396(define-public qmk-firmware-keychron-v3-iso-encoder-default
2397 (make-qmk-firmware-keychron "keychron/v3/iso_encoder" "default"
2398 #:description
2399 "This package provides the firmware for the Keychron V3 ISO with default keymap and with encoder."))
2400
2401(define-public qmk-firmware-keychron-v3-jis-encoder-default
2402 (make-qmk-firmware-keychron "keychron/v3/jis_encoder" "default"
2403 #:description
2404 "This package provides the firmware for the Keychron V3 JIS with default keymap and with encoder."))
2405
2406(define-public qmk-firmware-keychron-v4-ansi-default
2407 (make-qmk-firmware-keychron "keychron/v4/ansi" "default"
2408 #:description
2409 "This package provides the firmware for the Keychron V4 ANSI with default keymap."))
2410
2411(define-public qmk-firmware-keychron-v4-iso-default
2412 (make-qmk-firmware-keychron "keychron/v4/iso" "default"
2413 #:description
2414 "This package provides the firmware for the Keychron V4 ISO with default keymap."))
2415
2416(define-public qmk-firmware-keychron-v5-ansi-default
2417 (make-qmk-firmware-keychron "keychron/v5/ansi" "default"
2418 #:description
2419 "This package provides the firmware for the Keychron V5 ANSI with default keymap."))
2420
2421(define-public qmk-firmware-keychron-v5-ansi-encoder-default
2422 (make-qmk-firmware-keychron "keychron/v5/ansi_encoder" "default"
2423 #:description
2424 "This package provides the firmware for the Keychron V5 ANSI with default keymap and with encoder."))
2425
2426(define-public qmk-firmware-keychron-v5-iso-default
2427 (make-qmk-firmware-keychron "keychron/v5/iso" "default"
2428 #:description
2429 "This package provides the firmware for the Keychron V5 ISO with default keymap."))
2430
2431(define-public qmk-firmware-keychron-v5-iso-encoder-default
2432 (make-qmk-firmware-keychron "keychron/v5/iso_encoder" "default"
2433 #:description
2434 "This package provides the firmware for the Keychron V5 ISO with default keymap and with encoder."))
2435
2436(define-public qmk-firmware-keychron-v6-ansi-default
2437 (make-qmk-firmware-keychron "keychron/v6/ansi" "default"
2438 #:description
2439 "This package provides the firmware for the Keychron V6 ANSI with default keymap."))
2440
2441(define-public qmk-firmware-keychron-v6-ansi-encoder-default
2442 (make-qmk-firmware-keychron "keychron/v6/ansi_encoder" "default"
2443 #:description
2444 "This package provides the firmware for the Keychron V6 ANSI with default keymap and with encoder."))
2445
2446(define-public qmk-firmware-keychron-v6-iso-default
2447 (make-qmk-firmware-keychron "keychron/v6/iso" "default"
2448 #:description
2449 "This package provides the firmware for the Keychron V6 ISO with default keymap."))
2450
2451(define-public qmk-firmware-keychron-v6-iso-encoder-default
2452 (make-qmk-firmware-keychron "keychron/v6/iso_encoder" "default"
2453 #:description
2454 "This package provides the firmware for the Keychron V6 ISO with default keymap and with encoder."))
2455
2456(define-public qmk-firmware-keychron-v7-ansi-default
2457 (make-qmk-firmware-keychron "keychron/v7/ansi" "default"
2458 #:description
2459 "This package provides the firmware for the Keychron V7 ANSI with default keymap."))
2460
2461(define-public qmk-firmware-keychron-v7-iso-default
2462 (make-qmk-firmware-keychron "keychron/v7/iso" "default"
2463 #:description
2464 "This package provides the firmware for the Keychron V7 ISO with default keymap."))
2465
2466(define-public qmk-firmware-keychron-v8-ansi-default
2467 (make-qmk-firmware-keychron "keychron/v8/ansi" "default"
2468 #:description
2469 "This package provides the firmware for the Keychron V8 ANSI with default keymap."))
2470
2471(define-public qmk-firmware-keychron-v8-ansi-encoder-default
2472 (make-qmk-firmware-keychron "keychron/v8/ansi_encoder" "default"
2473 #:description
2474 "This package provides the firmware for the Keychron V8 ANSI with default keymap and with encoder."))
2475
2476(define-public qmk-firmware-keychron-v8-iso-default
2477 (make-qmk-firmware-keychron "keychron/v8/iso" "default"
2478 #:description
2479 "This package provides the firmware for the Keychron V8 ISO with default keymap."))
2480
2481(define-public qmk-firmware-keychron-v8-iso-encoder-default
2482 (make-qmk-firmware-keychron "keychron/v8/iso_encoder" "default"
2483 #:description
2484 "This package provides the firmware for the Keychron V8 ISO with default keymap and with encoder."))
2485
2486(define-public firmware-senoko
2487 (package
2488 (name "firmware-senoko")
2489 (version "2.6")
2490 (source (origin
2491 (method git-fetch)
2492 (uri (git-reference
2493 (url "https://github.com/novena-next/firmware-senoko.git")
2494 (commit (string-append "v" version))))
2495 (file-name (git-file-name name version))
2496 (sha256
2497 (base32
2498 "10d6bgqajl0w17xydjv2x22n5m9d1xsjb09r430nakc1v6gn52d5"))))
2499 (build-system copy-build-system)
2500 (arguments
2501 (list #:phases
2502 #~(modify-phases %standard-phases
2503 (add-after 'unpack 'patch
2504 (lambda* (#:key inputs #:allow-other-keys)
2505 (substitute* "update-senoko"
2506 (("^fw=/lib/firmware/senoko.hex")
2507 (string-append "fw="
2508 (assoc-ref inputs "senoko-chibios")
2509 "/lib/firmware/senoko.hex")))
2510 (patch-shebang "update-senoko"))))
2511 #:install-plan
2512 ''(("update-senoko" "bin/")
2513 ("update-senoko.1" "share/man/man1/"))))
2514 (inputs
2515 (list senoko-chibios))
2516 (synopsis "Firmware flasher for Novena battery or passthrough board")
2517 (description "This package provides a way to update the Novena battery or
2518passthrough board firmware on a Novena.")
2519 (supported-systems '("armhf-linux"))
2520 (home-page "https://github.com/novena-next/firmware-senoko")
2521 (license license:bsd-3)))