diff options
| author | Vineet Kumar <git@vineetk.net> | 2026-01-31 20:11:24 -0500 |
|---|---|---|
| committer | Vineet Kumar <git@vineetk.net> | 2026-01-31 20:11:24 -0500 |
| commit | f3add32123afd5e22eaee55ffe5143913094cfea (patch) | |
| tree | 3ccc97ba1a75c19b1203b5228281e1a38bda6948 /epistemia | |
| parent | 54b66a9117025f633096c9a2dfc814e1cb495701 (diff) | |
include preliminary qmk builds for my keyboards and mouse
Diffstat (limited to 'epistemia')
| -rw-r--r-- | epistemia/packages/firmware.scm | 146 |
1 files changed, 146 insertions, 0 deletions
diff --git a/epistemia/packages/firmware.scm b/epistemia/packages/firmware.scm new file mode 100644 index 0000000..6fa49b5 --- /dev/null +++ b/epistemia/packages/firmware.scm | |||
| @@ -0,0 +1,146 @@ | |||
| 1 | (define-module (epistemia packages firmware) | ||
| 2 | #:use-module ((guix licenses) #:prefix license:) | ||
| 3 | #:use-module (guix build-system gnu) | ||
| 4 | #:use-module (guix git-download) | ||
| 5 | #:use-module (guix gexp) | ||
| 6 | #:use-module (guix import egg) | ||
| 7 | #:use-module (guix packages) | ||
| 8 | #:use-module (guix utils) | ||
| 9 | #:use-module (gnu packages embedded) | ||
| 10 | #:use-module (gnu packages firmware) | ||
| 11 | #:use-module (ice-9 regex)) | ||
| 12 | |||
| 13 | ;; originally from guix upstream, but it's old and only for avr | ||
| 14 | (define* (make-qmk-firmware-rp2040 keyboard keymap | ||
| 15 | #:key (description "") | ||
| 16 | keymap-json | ||
| 17 | keymap-source-directory | ||
| 18 | keyboard-source-directory) | ||
| 19 | "Return a package to build the QMK firmware for KEYBOARD with KEYMAP. | ||
| 20 | Keyboard should be the name of a sub-directory under the @file{keyboards} directory. | ||
| 21 | For custom keymaps, KEYMAP-JSON, a file-like object of a JSON representation of | ||
| 22 | KEYMAP as generated by the @url{https://config.qmk.fm/, QMK Configurator} tool or | ||
| 23 | KEYMAP-SOURCE-DIRECTORY, a file-like object directory containing the keymap source | ||
| 24 | files files such as @file{keymap.c}, can be provided. For keyboards not available in | ||
| 25 | upstream repository, provide a file-like object directory containing the whole | ||
| 26 | keyboard definition in KEYBOARD-SOURCE-DIRECTORY." | ||
| 27 | (package | ||
| 28 | (name (string-append "qmk-firmware-" | ||
| 29 | (regexp-substitute/global #f "[_/]" keyboard | ||
| 30 | 'pre "-" 'post) | ||
| 31 | "-" | ||
| 32 | (string-replace-substring keymap "_" "-"))) | ||
| 33 | (version "0.31.9") | ||
| 34 | (source (origin | ||
| 35 | (method git-fetch) | ||
| 36 | (uri (git-reference | ||
| 37 | (url "https://github.com/qmk/qmk_firmware") | ||
| 38 | (commit version))) | ||
| 39 | (file-name (git-file-name "qmk-firmware" version)) | ||
| 40 | (sha256 | ||
| 41 | (base32 | ||
| 42 | "1vc0lp4k6816mgb8l73jmj6kv3b8ij23i9ia9y9s4f72h8z9j91c")))) | ||
| 43 | (build-system gnu-build-system) | ||
| 44 | (arguments | ||
| 45 | (list | ||
| 46 | #:modules '((guix build gnu-build-system) | ||
| 47 | (guix build utils) | ||
| 48 | (ice-9 ftw) | ||
| 49 | (ice-9 match) | ||
| 50 | (srfi srfi-26)) | ||
| 51 | #:target "arm-none-eabi" | ||
| 52 | ;; XXX: Running a test target like "test:$keyboard" doesn't seem to run | ||
| 53 | ;; anything and causes the .hex file to be regenerated; leave the tests | ||
| 54 | ;; out for now. | ||
| 55 | #:tests? #f | ||
| 56 | #:make-flags | ||
| 57 | #~(list #$(format #f "~a:~a" keyboard keymap) | ||
| 58 | (string-append "SHELL=" (search-input-file | ||
| 59 | %build-inputs "bin/sh")) | ||
| 60 | "CONVERT_TO=rp2040_ce") | ||
| 61 | #:phases | ||
| 62 | #~(modify-phases %standard-phases | ||
| 63 | (replace 'configure | ||
| 64 | (lambda _ | ||
| 65 | ;; Do not attempt to retrieve information from git during the | ||
| 66 | ;; build. | ||
| 67 | (setenv "SKIP_GIT" "1"))) | ||
| 68 | (add-after 'unpack 'copy-chibios-source | ||
| 69 | (lambda _ | ||
| 70 | (copy-recursively | ||
| 71 | #$(let ((commit "8bd61b804303f1614d574546c2dd735eeabb09f5")) | ||
| 72 | (origin | ||
| 73 | (method git-fetch) | ||
| 74 | (uri (git-reference | ||
| 75 | (url "https://github.com/qmk/chibios") | ||
| 76 | (commit commit))) | ||
| 77 | (file-name (git-file-name "chibios" commit)) | ||
| 78 | (sha256 | ||
| 79 | (base32 | ||
| 80 | "1waixxdgr48385k1dkf6zpvngdpp78kagkvdpag9y9pg610gqzd2")))) | ||
| 81 | "lib/chibios"))) | ||
| 82 | #$@(if keyboard-source-directory | ||
| 83 | #~((add-after 'unpack 'copy-keyboard-source-directory | ||
| 84 | (lambda _ | ||
| 85 | (let ((keyboard-dir #$(string-append "keyboards/" keyboard))) | ||
| 86 | (false-if-exception (delete-file-recursively | ||
| 87 | keyboard-dir)) | ||
| 88 | (copy-recursively #$keyboard-source-directory | ||
| 89 | keyboard-dir))))) | ||
| 90 | #~()) | ||
| 91 | #$@(if keymap-source-directory | ||
| 92 | #~((add-after 'unpack 'copy-keymap-source-directory | ||
| 93 | (lambda _ | ||
| 94 | (let ((keymap-dir #$(string-append "keyboards/" keyboard | ||
| 95 | "/keymaps/" keymap))) | ||
| 96 | (false-if-exception (delete-file-recursively | ||
| 97 | keymap-dir)) | ||
| 98 | (copy-recursively #$keymap-source-directory | ||
| 99 | keymap-dir))))) | ||
| 100 | #~()) | ||
| 101 | #$@(if keymap-json | ||
| 102 | #~((replace 'build | ||
| 103 | (lambda _ | ||
| 104 | (invoke "qmk" "compile" #$keymap-json)))) | ||
| 105 | #~()) | ||
| 106 | (replace 'install | ||
| 107 | (lambda _ | ||
| 108 | (match (scandir "." (lambda (f) | ||
| 109 | (false-if-exception | ||
| 110 | (member (string-take-right f 4) | ||
| 111 | '(".bin" ".hex" ".uf2"))))) | ||
| 112 | (() | ||
| 113 | (error "no built binary file found")) | ||
| 114 | ((hex ..1) | ||
| 115 | (for-each (cut install-file <> #$output) hex)))))))) | ||
| 116 | ;; Some of the build tools are required to be on the PATH, as the make | ||
| 117 | ;; files do not always operate through 'qmk'; all of qmk's inputs must | ||
| 118 | ;; thus be made available. | ||
| 119 | (native-inputs (modify-inputs (package-inputs qmk) | ||
| 120 | (append qmk | ||
| 121 | (make-newlib-nano-arm-none-eabi)))) | ||
| 122 | (home-page "https://qmk.fm/") | ||
| 123 | (synopsis "Keyboard firmware for Atmel AVR and Arm USB families") | ||
| 124 | (description | ||
| 125 | (format #f "QMK (Quantum Mechanical Keyboard Firmware) is a keyboard | ||
| 126 | firmware based on the @url{https://github.com/tmk/tmk_keyboard, tmk_keyboard | ||
| 127 | firmware} with some useful features for Atmel AVR and ARM controllers, and | ||
| 128 | more specifically, the @url{https://olkb.com/, OLKB product line}, the | ||
| 129 | @url{https://ergodox-ez.com/, ErgoDox EZ keyboard}, and the | ||
| 130 | @url{https://clueboard.co/, Clueboard product line}.~@[~%~%~a~]" description)) | ||
| 131 | (license license:gpl2+))) | ||
| 132 | |||
| 133 | (define-public qmk-crkbd | ||
| 134 | (make-qmk-firmware "crkbd" "default" #:description | ||
| 135 | "The default keymap for the Corne keyboard, a split keyboard with 3x6 vertically | ||
| 136 | staggered keys and 3 thumb keys.")) | ||
| 137 | |||
| 138 | (define-public qmk-ferris-sweep | ||
| 139 | (make-qmk-firmware-rp2040 "ferris/sweep" "default" #:description | ||
| 140 | "The default keymap for the Ferris Sweep keyboard, a version of the | ||
| 141 | Ferris 3x5+2 split keyboard with a daughterboard for MCU.")) | ||
| 142 | |||
| 143 | (define-public qmk-ploopy-adept | ||
| 144 | (make-qmk-firmware-rp2040 "ploopyco/madromys" "default" #:description | ||
| 145 | "The default keymap for the Ploopy Adept open-hardware programmable | ||
| 146 | trackball mouse.")) | ||
