diff mbox series

[bug#67534] gnu: qmk: Support custom keyboards.

Message ID 940c712802a6bb69dde97dca4b6c01524d0a0a1e.1701289507.git.sarg@sarg.org.ru
State New
Headers show
Series [bug#67534] gnu: qmk: Support custom keyboards. | expand

Commit Message

Sergey Trofimov Nov. 29, 2023, 8:32 p.m. UTC
* gnu/packages/firmware.scm (make-qmk-firmware/implementation):
Add keyboard-source-directory parameter.
---
 gnu/packages/firmware.scm | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)


base-commit: cd46757c1a0f886848fbb6828c028dd2a2532767
--
2.41.0

Comments

Sergey Trofimov March 21, 2024, 9:16 p.m. UTC | #1
Hi Maxim,

may I ask your review here, as you've authored qmk firmware 
package. I'm adding `keyboard-source-directory` to the 
`make-qmk-firmware` procedure, so that a custom firmware could be 
built without upstreaming a keyboard definition to the main QMK 
repo. Here is how I use it: 
https://github.com/sarg/keyboard/blob/91b87a830ef6029c1023c0d8fc877c067b12ab1e/guix.scm

Best regards,
Sergey
Maxim Cournoyer April 1, 2024, 12:21 a.m. UTC | #2
Hi!

Sergey Trofimov <sarg@sarg.org.ru> writes:

> Hi Maxim,
>
> may I ask your review here, as you've authored qmk firmware
> package. I'm adding `keyboard-source-directory` to the
> `make-qmk-firmware` procedure, so that a custom firmware could be
> built without upstreaming a keyboard definition to the main QMK
> repo. Here is how I use it:
> https://github.com/sarg/keyboard/blob/91b87a830ef6029c1023c0d8fc877c067b12ab1e/guix.scm

Makes sense.  I'll push shortly.
diff mbox series

Patch

diff --git a/gnu/packages/firmware.scm b/gnu/packages/firmware.scm
index 294bbea184..e06b321cde 100644
--- a/gnu/packages/firmware.scm
+++ b/gnu/packages/firmware.scm
@@ -1406,14 +1406,16 @@  (define-public qmk
 (define* (make-qmk-firmware/implementation keyboard keymap
                                            #:key (description "")
                                            keymap-json
-                                           keymap-source-directory)
+                                           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."
+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-"
                          (string-replace-substring keyboard "_" "-") "-"
@@ -1472,6 +1474,15 @@  (define* (make-qmk-firmware/implementation keyboard keymap
                       (base32
                        "1rmhm4rxvq8skxqn6vc4n4ly1ak6whj7c386zbsci4pxx548n9h4"))))
                "lib/lufa")))
+          #$@(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 _