[PATCH 0/2] Qmk cli

OpenSubmitted by Jan Wielkiewicz.
Details
3 participants
  • Nicolò Balzarotti
  • Mathieu Othacehe
  • Jan Wielkiewicz
Owner
unassigned
Severity
normal
J
J
Jan Wielkiewicz wrote on 2 Aug 2020 22:42
(address . guix-patches@gnu.org)(name . Jan Wielkiewicz)(address . tona_kosmicznego_smiecia@interia.pl)
20200802204208.14992-1-tona_kosmicznego_smiecia@interia.pl
Hello,

these patches add qmk-cli - a command line utility helping its users to mofify
and flash qmk firmware on input devices like keyboards or mouses.
I also add one python dependency.
Project's website: https://qmk.fm/


Jan Wielkiewicz (2):
gnu: Add python-hjson.
gnu: Add qmk-cli.

gnu/packages/hardware.scm | 50 +++++++++++++++++++++++++++++++++++++
gnu/packages/python-xyz.scm | 20 +++++++++++++++
2 files changed, 70 insertions(+)


Jan Wielkiewicz

--
2.28.0
J
J
Jan Wielkiewicz wrote on 2 Aug 2020 22:49
[PATCH 1/2] gnu: Add python-hjson.
(address . 42682@debbugs.gnu.org)(name . Jan Wielkiewicz)(address . tona_kosmicznego_smiecia@interia.pl)
20200802204910.15356-1-tona_kosmicznego_smiecia@interia.pl
* gnu/packages/python-xyz.scm (python-hjson): New variable.
---
gnu/packages/python-xyz.scm | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)

Toggle diff (37 lines)
diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index 9ab0b12383..316865ddf1 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -83,6 +83,7 @@
 ;;; Copyright © 2020 Michael Rohleder <mike@rohleder.de>
 ;;; Copyright © 2020 Vinicius Monego <monego@posteo.net>
 ;;; Copyright © 2020 Guy Fleury Iteriteka <gfleury@disroot.org>
+;;; Copyright © 2020 Jan Wielkiewicz <tona_kosmicznego_smiecia@interia.pl>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -21298,3 +21299,22 @@ and have a maximum lifetime built-in.")
      "This package contains a small collection of test tool plugins for
 @code{nose2} and @code{flake8}.")
     (license license:asl2.0)))
+
+(define-public python-hjson
+  (package
+   (name "python-hjson")
+   (version "3.0.1")
+   (source
+    (origin
+     (method url-fetch)
+     (uri (pypi-uri "hjson" version))
+     (sha256
+      (base32
+       "1yaimcgz8w0ps1wk28wk9g9zdidp79d14xqqj9rjkvxalvx2f5qx"))))
+   (build-system python-build-system)
+   (arguments
+    '(#:tests? #f)) ; no tests
+   (home-page "http://github.com/hjson/hjson-py")
+   (synopsis "User interface for JSON.")
+   (description "Hjson, a user interface for JSON.")
+   (license license:expat)))
-- 
2.28.0
J
J
Jan Wielkiewicz wrote on 2 Aug 2020 22:49
[PATCH 2/2] gnu: Add qmk-cli.
(address . 42682@debbugs.gnu.org)(name . Jan Wielkiewicz)(address . tona_kosmicznego_smiecia@interia.pl)
20200802204910.15356-2-tona_kosmicznego_smiecia@interia.pl
* gnu/packages/hardware.scm (qmk-cli): New variable.
---
gnu/packages/hardware.scm | 50 +++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)

Toggle diff (92 lines)
diff --git a/gnu/packages/hardware.scm b/gnu/packages/hardware.scm
index 211a5a34ac..adab986d75 100644
--- a/gnu/packages/hardware.scm
+++ b/gnu/packages/hardware.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2018, 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
 ;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re>
+;;; Copyright © 2020 Jan Wielkiewicz <tona_kosmicznego_smiecia@interia.pl>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -19,6 +20,7 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (gnu packages hardware)
+  #:use-module (gnu packages avr)
   #:use-module (gnu packages admin)
   #:use-module (gnu packages autotools)
   #:use-module (gnu packages bash)
@@ -27,6 +29,8 @@
   #:use-module (gnu packages cpp)
   #:use-module (gnu packages crypto)
   #:use-module (gnu packages documentation)
+  #:use-module (gnu packages embedded)
+  #:use-module (gnu packages flashing-tools)
   #:use-module (gnu packages gcc)
   #:use-module (gnu packages glib)
   #:use-module (gnu packages libusb)
@@ -36,10 +40,14 @@
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages polkit)
   #:use-module (gnu packages protobuf)
+  #:use-module (gnu packages python)
+  #:use-module (gnu packages python-xyz)
+  #:use-module (gnu packages version-control)
   #:use-module (gnu packages xdisorg)
   #:use-module (gnu packages xml)
   #:use-module (gnu packages xorg)
   #:use-module (guix build-system gnu)
+  #:use-module (guix build-system python)
   #:use-module (guix download)
   #:use-module (guix git-download)
   #:use-module ((guix licenses) #:prefix license:)
@@ -465,3 +473,45 @@ authorization policies (what kind of USB devices are authorized) as well as
 method of use policies (how a USB device may interact with the system).
 Simply put, it is a USB device whitelisting tool.")
     (license license:gpl2)))
+
+(define-public qmk-cli
+  (package
+    (name "qmk-cli")
+    (version "0.0.35")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (pypi-uri "qmk" version))
+       (sha256
+        (base32
+         "1dd3q38r5bs9ih8jiwsb7q2655wyka2a8wlwv7yln9narlqwl177"))))
+    (build-system python-build-system)
+    (propagated-inputs
+     `(("arm-none-eabi-gcc" ,gcc-arm-none-eabi-7-2018-q2-update)
+       ("avr-gcc" ,avr-toolchain-5)
+       ("avrdude" ,avrdude)
+       ("dfu-programmer" ,dfu-programmer)
+       ("dfu-util" ,dfu-util)
+       ("git" ,git)
+       ("python3" ,python)
+       ("python-appdirs" ,python-appdirs)
+       ("python-argcomplete" ,python-argcomplete)
+       ("python-colorama" ,python-colorama)
+       ("python-flake8" ,python-flake8)
+       ("python-hjson" ,python-hjson)
+       ("python-nose2" ,python-nose2)
+       ("python-yapf" ,python-yapf)))
+    (arguments
+     `(#:phases (modify-phases %standard-phases
+                  (add-before 'check 'set-qmk-home
+                    (lambda _
+                      ;; tests fail without this variable set
+                      (setenv "QMK_HOME"
+                              "")
+                      #t)))))
+    (home-page "https://github.com/qmk/qmk_cli")
+    (synopsis
+     "Tools for developing QMK Firmware")
+    (description
+     "A program to help users work with QMK Firmware.")
+    (license license:expat)))
-- 
2.28.0
M
M
Mathieu Othacehe wrote on 3 Aug 2020 10:21
Re: [bug#42682] [PATCH 1/2] gnu: Add python-hjson.
(name . Jan Wielkiewicz)(address . tona_kosmicznego_smiecia@interia.pl)(address . 42682@debbugs.gnu.org)
873654uolk.fsf@gnu.org
Hello Jan,

Thanks for this patch. Please make sure to run the linter that reports
two warnings here.

Toggle quote (18 lines)
> +(define-public python-hjson
> + (package
> + (name "python-hjson")
> + (version "3.0.1")
> + (source
> + (origin
> + (method url-fetch)
> + (uri (pypi-uri "hjson" version))
> + (sha256
> + (base32
> + "1yaimcgz8w0ps1wk28wk9g9zdidp79d14xqqj9rjkvxalvx2f5qx"))))
> + (build-system python-build-system)
> + (arguments
> + '(#:tests? #f)) ; no tests
> + (home-page "http://github.com/hjson/hjson-py")
> + (synopsis "User interface for JSON.")
> + (description "Hjson, a user interface for JSON.")

You need to elaborate on that with at least two or three sentences,
explaining what is this user interface and what does it bring.

Thanks,

Mathieu
M
M
Mathieu Othacehe wrote on 3 Aug 2020 10:26
Re: [bug#42682] [PATCH 2/2] gnu: Add qmk-cli.
(name . Jan Wielkiewicz)(address . tona_kosmicznego_smiecia@interia.pl)(address . 42682@debbugs.gnu.org)
87y2mwt9t0.fsf@gnu.org
Toggle quote (16 lines)
> + (propagated-inputs
> + `(("arm-none-eabi-gcc" ,gcc-arm-none-eabi-7-2018-q2-update)
> + ("avr-gcc" ,avr-toolchain-5)
> + ("avrdude" ,avrdude)
> + ("dfu-programmer" ,dfu-programmer)
> + ("dfu-util" ,dfu-util)
> + ("git" ,git)
> + ("python3" ,python)
> + ("python-appdirs" ,python-appdirs)
> + ("python-argcomplete" ,python-argcomplete)
> + ("python-colorama" ,python-colorama)
> + ("python-flake8" ,python-flake8)
> + ("python-hjson" ,python-hjson)
> + ("python-nose2" ,python-nose2)
> + ("python-yapf" ,python-yapf)))

Do we really need to propagate all those inputs? Can't we hardcode the
path to those tools directly in the sources, if they are not registered at
build time?

Toggle quote (8 lines)
> + (arguments
> + `(#:phases (modify-phases %standard-phases
> + (add-before 'check 'set-qmk-home
> + (lambda _
> + ;; tests fail without this variable set
> + (setenv "QMK_HOME"
> + "")

Who is supposed to set it otherwise?

Toggle quote (2 lines)
> + "A program to help users work with QMK Firmware.")

You also need to elaborate here :)

Thanks,

Mathieu
J
J
Jan Wielkiewicz wrote on 3 Aug 2020 14:28
Re: [bug#42682] [PATCH 1/2] gnu: Add python-hjson.
(name . Mathieu Othacehe)(address . othacehe@gnu.org)(address . 42682@debbugs.gnu.org)
20200803142824.125def3c@interia.pl
Dnia 2020-08-03, o godz. 10:21:11
Mathieu Othacehe <othacehe@gnu.org> napisał(a):

Toggle quote (5 lines)
>
> Hello Jan,
>
> Thanks for this patch. Please make sure to run the linter that reports
> two warnings here.
Okay. I'll check that.
Toggle quote (3 lines)
>
> You need to elaborate on that with at least two or three sentences,
> explaining what is this user interface and what does it bring.
To be honest, I'm not sure what they mean by "user interface to JSON".
They vaguely explain this on their website https://hjson.github.io/
I'm also not sure if I'm permited to just copy and paste text from
their website because of copyright.
My English is also sloppy sometimes and I fail to write meaningful
description about too abstract things.
I can try diving in and check what it does, but I don't have any
experience with Python.

Toggle quote (3 lines)
> Thanks,
>
> Mathieu
J
J
Jan Wielkiewicz wrote on 3 Aug 2020 14:43
Re: [bug#42682] [PATCH 2/2] gnu: Add qmk-cli.
(name . Mathieu Othacehe)(address . othacehe@gnu.org)(address . 42682@debbugs.gnu.org)
20200803144349.06022fa4@interia.pl
Dnia 2020-08-03, o godz. 10:26:03
Mathieu Othacehe <othacehe@gnu.org> napisał(a):

Toggle quote (18 lines)
>
> > + (propagated-inputs
> > + `(("arm-none-eabi-gcc" ,gcc-arm-none-eabi-7-2018-q2-update)
> > + ("avr-gcc" ,avr-toolchain-5)
> > + ("avrdude" ,avrdude)
> > + ("dfu-programmer" ,dfu-programmer)
> > + ("dfu-util" ,dfu-util)
> > + ("git" ,git)
> > + ("python3" ,python)
> > + ("python-appdirs" ,python-appdirs)
> > + ("python-argcomplete" ,python-argcomplete)
> > + ("python-colorama" ,python-colorama)
> > + ("python-flake8" ,python-flake8)
> > + ("python-hjson" ,python-hjson)
> > + ("python-nose2" ,python-nose2)
> > + ("python-yapf" ,python-yapf)))
>
> Do we really need to propagate all those inputs?
The python dependencies were added to propagated inputs automatically
by "guix import". The other tools are needed in the user profine,
because qmk-cli uses them, for example it fetches qmk firmware from
git, it runs some *python stuff* and when user is done making changes
to their firmware, qmk cli builds the firmware using the compiler and
flashes it using dfu.

I think it would be cool if Guix allowed defining profiles and
environments the same way it allows defining packages.
This way installing qmk-cli would also install say qmk-profile with all
headers (and tools) needed for development. Now, even though
arv-toolchain is installed, I have to run "guix environment qmk-cli" to
be able to work with the firmware without getting build errors.

Toggle quote (3 lines)
> Can't we hardcode the
> path to those tools directly in the sources, if they are not
> registered at build time?
I need them installed, so qmk-cli doesn't complain. Should the user be
responsible for installing all the tools needed for development?

Toggle quote (9 lines)
> > + (arguments
> > + `(#:phases (modify-phases %standard-phases
> > + (add-before 'check 'set-qmk-home
> > + (lambda _
> > + ;; tests fail without this variable set
> > + (setenv "QMK_HOME"
> > + "")
>
> Who is supposed to set it otherwise?
I'm not sure. That's the first thing qmk-cli sets when it is already
installed. Normally, qmk-cli is installed by pip, maybe it is
responsible for setting the variables?

Toggle quote (3 lines)
> > + "A program to help users work with QMK Firmware.")
>
> You also need to elaborate here :)
Should I describe what qmk firmware is or say more about what working
with qmk firmware is, or both?

Toggle quote (3 lines)
> Thanks,
>
> Mathieu
M
M
Mathieu Othacehe wrote on 5 Aug 2020 11:17
(name . Jan Wielkiewicz)(address . tona_kosmicznego_smiecia@interia.pl)(address . 42682@debbugs.gnu.org)
87o8npjvt4.fsf@gnu.org
Hello Jan,

Toggle quote (8 lines)
>> Do we really need to propagate all those inputs?
> The python dependencies were added to propagated inputs automatically
> by "guix import". The other tools are needed in the user profine,
> because qmk-cli uses them, for example it fetches qmk firmware from
> git, it runs some *python stuff* and when user is done making changes
> to their firmware, qmk cli builds the firmware using the compiler and
> flashes it using dfu.

Turns out qmk_cli is just a wrapper around qmk_firmware. It clones qmk
firmware repository because it cannot locate a qmk_firmware directory
using QMK_HOME variable.

I think the proper way to do things would be to package qmk_firwmare
first (it has a root shell.nix file that should help). Then this package
would define QMK_HOME using "search-paths".

This way, qmk_cli would just require some python libraries, but would
not propagate git, and the toolchains.

Does it make sense?

Thanks,

Mathieu
J
J
Jan Wielkiewicz wrote on 5 Aug 2020 14:22
(name . Mathieu Othacehe)(address . othacehe@gnu.org)(address . 42682@debbugs.gnu.org)
20200805142240.075ac063@interia.pl
Dnia 2020-08-05, o godz. 11:17:43
Mathieu Othacehe <othacehe@gnu.org> napisał(a):

Toggle quote (24 lines)
>
> Hello Jan,
>
> >> Do we really need to propagate all those inputs?
> > The python dependencies were added to propagated inputs
> > automatically by "guix import". The other tools are needed in the
> > user profine, because qmk-cli uses them, for example it fetches qmk
> > firmware from git, it runs some *python stuff* and when user is
> > done making changes to their firmware, qmk cli builds the firmware
> > using the compiler and flashes it using dfu.
>
> Turns out qmk_cli is just a wrapper around qmk_firmware. It clones qmk
> firmware repository because it cannot locate a qmk_firmware directory
> using QMK_HOME variable.
>
> I think the proper way to do things would be to package qmk_firwmare
> first (it has a root shell.nix file that should help). Then this
> package would define QMK_HOME using "search-paths".
>
> This way, qmk_cli would just require some python libraries, but would
> not propagate git, and the toolchains.
>
> Does it make sense?

But the entire point of qmk firmware is that the user configures it. I
had to modify the source code to make my keyboard work and add some
extra features like layouts, special keys. Your solution will only work
for the unmodified and default firmware, or is there a Guix solution
for it I'm not aware of, like a convenient interface for user defined
packages?

Toggle quote (3 lines)
> Thanks,
>
> Mathieu
M
M
Mathieu Othacehe wrote on 7 Aug 2020 10:20
(name . Jan Wielkiewicz)(address . tona_kosmicznego_smiecia@interia.pl)(address . 42682@debbugs.gnu.org)
87364yq33y.fsf@gnu.org
Hello,

Toggle quote (7 lines)
> But the entire point of qmk firmware is that the user configures it. I
> had to modify the source code to make my keyboard work and add some
> extra features like layouts, special keys. Your solution will only work
> for the unmodified and default firmware, or is there a Guix solution
> for it I'm not aware of, like a convenient interface for user defined
> packages?

Oh I see. Nonetheless, qmk_cli is a thin wrapper around qmk_firmware. I
think it would make more sense to have qmk_firmware properly packaged.

This way we would offer people a way to build their customized firmware
without propagating toolchains and fetching a git repository.

WDYT?

Mathieu
J
J
Jan Wielkiewicz wrote on 7 Aug 2020 17:44
(name . Mathieu Othacehe)(address . othacehe@gnu.org)(address . 42682@debbugs.gnu.org)
20200807174401.21be8219@interia.pl
Dnia 2020-08-07, o godz. 10:20:17
Mathieu Othacehe <othacehe@gnu.org> napisał(a):

Toggle quote (18 lines)
>
> Hello,
>
> > But the entire point of qmk firmware is that the user configures
> > it. I had to modify the source code to make my keyboard work and
> > add some extra features like layouts, special keys. Your solution
> > will only work for the unmodified and default firmware, or is there
> > a Guix solution for it I'm not aware of, like a convenient
> > interface for user defined packages?
>
> Oh I see. Nonetheless, qmk_cli is a thin wrapper around qmk_firmware.
> I think it would make more sense to have qmk_firmware properly
> packaged.
>
> This way we would offer people a way to build their customized
> firmware without propagating toolchains and fetching a git repository.
>
> WDYT?
I can do this then, give me some time.

Toggle quote (3 lines)
> Mathieu


Jan Wielkiewicz
N
N
Nicolò Balzarotti wrote on 5 Feb 2021 12:39
(address . 42682@debbugs.gnu.org)
87sg6a216c.fsf@guixSD.i-did-not-set--mail-host-address--so-tickle-me
Jan Wielkiewicz <tona_kosmicznego_smiecia@interia.pl> writes:

Toggle quote (28 lines)
> Dnia 2020-08-07, o godz. 10:20:17
> Mathieu Othacehe <othacehe@gnu.org> napisał(a):
>
>>
>> Hello,
>>
>> > But the entire point of qmk firmware is that the user configures
>> > it. I had to modify the source code to make my keyboard work and
>> > add some extra features like layouts, special keys. Your solution
>> > will only work for the unmodified and default firmware, or is there
>> > a Guix solution for it I'm not aware of, like a convenient
>> > interface for user defined packages?
>>
>> Oh I see. Nonetheless, qmk_cli is a thin wrapper around qmk_firmware.
>> I think it would make more sense to have qmk_firmware properly
>> packaged.
>>
>> This way we would offer people a way to build their customized
>> firmware without propagating toolchains and fetching a git repository.
>>
>> WDYT?
> I can do this then, give me some time.
>
>> Mathieu
>
>
> Jan Wielkiewicz

Hi Jan, have you been working on this? My new qmk-supported keyboard is
coming and I'd love to be able to flash it with guix.

I built qmk-firmware in guix (but there are bundled dependencies that
still need to be removed).

I was planning to use mugur with it, which calls

make -C source-path keyboard:type

So, my first idea (which should apply to qmk-cli too) was to patch this
to call guix build --with-source and hopefully get this working, but I
don't know how robust this is (or if it is even going to work).

(I'll also have to package https://github.com/zsa/wally,but it does not
seem to require qmk-cli)

Nicolò
J
J
Jan Wielkiewicz wrote on 24 Feb 2021 22:41
(name . Nicolò Balzarotti)(address . anothersms@gmail.com)
20210224224150.12ddc261@interia.pl
Dnia 2021-02-05, o godz. 12:39:55
Nicolò Balzarotti <anothersms@gmail.com> napisał(a):

Toggle quote (2 lines)
> Hi Jan, have you been working on this? My new qmk-supported keyboard
> is coming and I'd love to be able to flash it with guix.
Nope, I'm quite busy studying right now, will resume my work this
summer.

Toggle quote (16 lines)
> I built qmk-firmware in guix (but there are bundled dependencies that
> still need to be removed).
>
> I was planning to use mugur with it, which calls
>
> make -C source-path keyboard:type
>
> So, my first idea (which should apply to qmk-cli too) was to patch
> this to call guix build --with-source and hopefully get this working,
> but I don't know how robust this is (or if it is even going to work).
>
> (I'll also have to package https://github.com/zsa/wally, but it does
> not seem to require qmk-cli)
>
> Nicolò

I totally don't remember what the issue was about. If you have a
working package then go ahead.
Thanks for info anyway, I'll check it out later.

Jan Wielkiewicz
N
N
Nicolò Balzarotti wrote on 24 Feb 2021 23:23
(name . Jan Wielkiewicz)(address . tona_kosmicznego_smiecia@interia.pl)
87sg5l9kba.fsf@guixSD.i-did-not-set--mail-host-address--so-tickle-me
Toggle quote (4 lines)
> I totally don't remember what the issue was about. If you have a
> working package then go ahead.
> Thanks for info anyway, I'll check it out later.

Ok, I'll send some patches in the following days :)

Thanks, Nicolo'
?