commit 7d908b7c38d20c89fc4f80e9a025476c4b20f87d
parent 4fa0fb1dfd595320678400bc7947af41fd369b84
Author: Vineet Kumar <git@vineetk.net>
Date: Sat, 31 Jan 2026 20:11:24 -0500
include preliminary qmk builds for my keyboards and mouse
Diffstat:
1 file changed, 146 insertions(+), 0 deletions(-)
diff --git a/epistemia/packages/firmware.scm b/epistemia/packages/firmware.scm
@@ -0,0 +1,146 @@
+(define-module (epistemia packages firmware)
+ #:use-module ((guix licenses) #:prefix license:)
+ #:use-module (guix build-system gnu)
+ #:use-module (guix git-download)
+ #:use-module (guix gexp)
+ #:use-module (guix import egg)
+ #:use-module (guix packages)
+ #:use-module (guix utils)
+ #:use-module (gnu packages embedded)
+ #:use-module (gnu packages firmware)
+ #:use-module (ice-9 regex))
+
+;; originally from guix upstream, but it's old and only for avr
+(define* (make-qmk-firmware-rp2040 keyboard keymap
+ #:key (description "")
+ keymap-json
+ keymap-source-directory
+ keyboard-source-directory)
+ "Return a package to build the QMK firmware for KEYBOARD with KEYMAP.
+Keyboard should be the name of a sub-directory under the @file{keyboards} directory.
+For custom keymaps, KEYMAP-JSON, a file-like object of a JSON representation of
+KEYMAP as generated by the @url{https://config.qmk.fm/, QMK Configurator} tool or
+KEYMAP-SOURCE-DIRECTORY, a file-like object directory containing the keymap source
+files files such as @file{keymap.c}, can be provided. For keyboards not available in
+upstream repository, provide a file-like object directory containing the whole
+keyboard definition in KEYBOARD-SOURCE-DIRECTORY."
+ (package
+ (name (string-append "qmk-firmware-"
+ (regexp-substitute/global #f "[_/]" keyboard
+ 'pre "-" 'post)
+ "-"
+ (string-replace-substring keymap "_" "-")))
+ (version "0.31.9")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/qmk/qmk_firmware")
+ (commit version)))
+ (file-name (git-file-name "qmk-firmware" version))
+ (sha256
+ (base32
+ "1vc0lp4k6816mgb8l73jmj6kv3b8ij23i9ia9y9s4f72h8z9j91c"))))
+ (build-system gnu-build-system)
+ (arguments
+ (list
+ #:modules '((guix build gnu-build-system)
+ (guix build utils)
+ (ice-9 ftw)
+ (ice-9 match)
+ (srfi srfi-26))
+ #:target "arm-none-eabi"
+ ;; XXX: Running a test target like "test:$keyboard" doesn't seem to run
+ ;; anything and causes the .hex file to be regenerated; leave the tests
+ ;; out for now.
+ #:tests? #f
+ #:make-flags
+ #~(list #$(format #f "~a:~a" keyboard keymap)
+ (string-append "SHELL=" (search-input-file
+ %build-inputs "bin/sh"))
+ "CONVERT_TO=rp2040_ce")
+ #:phases
+ #~(modify-phases %standard-phases
+ (replace 'configure
+ (lambda _
+ ;; Do not attempt to retrieve information from git during the
+ ;; build.
+ (setenv "SKIP_GIT" "1")))
+ (add-after 'unpack 'copy-chibios-source
+ (lambda _
+ (copy-recursively
+ #$(let ((commit "8bd61b804303f1614d574546c2dd735eeabb09f5"))
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/qmk/chibios")
+ (commit commit)))
+ (file-name (git-file-name "chibios" commit))
+ (sha256
+ (base32
+ "1waixxdgr48385k1dkf6zpvngdpp78kagkvdpag9y9pg610gqzd2"))))
+ "lib/chibios")))
+ #$@(if keyboard-source-directory
+ #~((add-after 'unpack 'copy-keyboard-source-directory
+ (lambda _
+ (let ((keyboard-dir #$(string-append "keyboards/" keyboard)))
+ (false-if-exception (delete-file-recursively
+ keyboard-dir))
+ (copy-recursively #$keyboard-source-directory
+ keyboard-dir)))))
+ #~())
+ #$@(if keymap-source-directory
+ #~((add-after 'unpack 'copy-keymap-source-directory
+ (lambda _
+ (let ((keymap-dir #$(string-append "keyboards/" keyboard
+ "/keymaps/" keymap)))
+ (false-if-exception (delete-file-recursively
+ keymap-dir))
+ (copy-recursively #$keymap-source-directory
+ keymap-dir)))))
+ #~())
+ #$@(if keymap-json
+ #~((replace 'build
+ (lambda _
+ (invoke "qmk" "compile" #$keymap-json))))
+ #~())
+ (replace 'install
+ (lambda _
+ (match (scandir "." (lambda (f)
+ (false-if-exception
+ (member (string-take-right f 4)
+ '(".bin" ".hex" ".uf2")))))
+ (()
+ (error "no built binary file found"))
+ ((hex ..1)
+ (for-each (cut install-file <> #$output) hex))))))))
+ ;; Some of the build tools are required to be on the PATH, as the make
+ ;; files do not always operate through 'qmk'; all of qmk's inputs must
+ ;; thus be made available.
+ (native-inputs (modify-inputs (package-inputs qmk)
+ (append qmk
+ (make-newlib-nano-arm-none-eabi))))
+ (home-page "https://qmk.fm/")
+ (synopsis "Keyboard firmware for Atmel AVR and Arm USB families")
+ (description
+ (format #f "QMK (Quantum Mechanical Keyboard Firmware) is a keyboard
+firmware based on the @url{https://github.com/tmk/tmk_keyboard, tmk_keyboard
+firmware} with some useful features for Atmel AVR and ARM controllers, and
+more specifically, the @url{https://olkb.com/, OLKB product line}, the
+@url{https://ergodox-ez.com/, ErgoDox EZ keyboard}, and the
+@url{https://clueboard.co/, Clueboard product line}.~@[~%~%~a~]" description))
+ (license license:gpl2+)))
+
+(define-public qmk-crkbd
+ (make-qmk-firmware "crkbd" "default" #:description
+ "The default keymap for the Corne keyboard, a split keyboard with 3x6 vertically
+staggered keys and 3 thumb keys."))
+
+(define-public qmk-ferris-sweep
+ (make-qmk-firmware-rp2040 "ferris/sweep" "default" #:description
+ "The default keymap for the Ferris Sweep keyboard, a version of the
+Ferris 3x5+2 split keyboard with a daughterboard for MCU."))
+
+(define-public qmk-ploopy-adept
+ (make-qmk-firmware-rp2040 "ploopyco/madromys" "default" #:description
+ "The default keymap for the Ploopy Adept open-hardware programmable
+trackball mouse."))