From patchwork Tue Sep 26 19:04:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Cournoyer X-Patchwork-Id: 54328 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 8C27827BBE2; Tue, 26 Sep 2023 20:39:51 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 8792E27BBEA for ; Tue, 26 Sep 2023 20:39:48 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlDta-0006nn-PQ; Tue, 26 Sep 2023 15:38:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qlDtW-0006gL-Gh for guix-patches@gnu.org; Tue, 26 Sep 2023 15:38:54 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qlDtU-0006ML-JP for guix-patches@gnu.org; Tue, 26 Sep 2023 15:38:54 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qlDtg-00011c-Ms; Tue, 26 Sep 2023 15:39:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#66217] [PATCH 08/22] gnu: Add qmk-firmware-ergodox-ez-default. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: efraim@flashner.co.il, vagrant@debian.org, guix-patches@gnu.org Resent-Date: Tue, 26 Sep 2023 19:39:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66217 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 66217@debbugs.gnu.org Cc: Maxim Cournoyer , Efraim Flashner , Vagrant Cascadian X-Debbugs-Original-Xcc: Efraim Flashner , Vagrant Cascadian Received: via spool by 66217-submit@debbugs.gnu.org id=B66217.16957571143743 (code B ref 66217); Tue, 26 Sep 2023 19:39:04 +0000 Received: (at 66217) by debbugs.gnu.org; 26 Sep 2023 19:38:34 +0000 Received: from localhost ([127.0.0.1]:49827 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qlDtB-0000y7-RJ for submit@debbugs.gnu.org; Tue, 26 Sep 2023 15:38:34 -0400 Received: from mail-qk1-x72f.google.com ([2607:f8b0:4864:20::72f]:60742) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qlDsv-0000vK-0W for 66217@debbugs.gnu.org; Tue, 26 Sep 2023 15:38:18 -0400 Received: by mail-qk1-x72f.google.com with SMTP id af79cd13be357-77407e21d3cso600802685a.1 for <66217@debbugs.gnu.org>; Tue, 26 Sep 2023 12:38:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695757078; x=1696361878; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TYD1dbar7wz9g8zUo5lkA35Sg5ie+isGxSm8vTEqRWs=; b=RznXA4pjYMjjtGW7FOFkZ+4+8dpfsyQc5Tk4i8X5VEFQCF6nFzHMrQYXSOsGLFaexY JyvJahBQvWZtHf1E+rT/MbWBtn/OpagY0etCe2tB744ZIBwYnp/nctkRVQpEiLtmmsqT oyb5zVgDtN5NZxrkoDYii2C7+z94n0lLyFsT1CVySNcdz0/uHlpdQyZ3JqWJrdAa//GT pFyCUqf95DWlMF94EiTqmT0VEBcQ9U8QoQwWB7ywW50vRQVaB+tGIHJ5gHn8KYo1ZgLP re6FkVotgKhGgKMPXOb/hjDicx2/LSz2Xf7nvkdB7tvBHqW+EhhH3eHgld03pJjQy0cI 7eFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695757078; x=1696361878; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TYD1dbar7wz9g8zUo5lkA35Sg5ie+isGxSm8vTEqRWs=; b=q1Ar+WQHjnxM3J1ldPAaHZ7Ew2Ahvv0vRT51dEeHN3pI0EGnt7Pw3pXPC7XVux9RIc mUcr7wUPatCceY/aU6LJ30whggQv9oYc1LpmJFzVuE/YunUzsgRwNo3zmP0b/IR4LuCi amdEpPWdchQDsmSEjMHn3GOr7URwS3PeELlhp5iy+zcFe11xdzLlU/DMlxx25WuAWacM UnWSvS8/ydUaGzlh9vRDvM5XqhMEnpz/nuJn/QSnZ/YYLmVdoEcEpb23dqWA7alv8aTE xQlxwOH3NlPMKAUgteus/vGBAGe+wt5GCVByFcH+285BIjPHa9Zf3sdyc19fxiOMpZbC revA== X-Gm-Message-State: AOJu0YxTIOEnYgnwhp7do9JXJ9OC7kA6kWyse+t1HgdK+AlE4rTZbFAB Ia2Sx1b5kA2q/sSx+3Q6cONtvTEVbJc= X-Google-Smtp-Source: AGHT+IHuPbXiKc1F13eOK1rmafQtJSi/MaLdp9je2gG0QtDkPw3xkFfZvOkSdp0c6ePwL/mpwGAJQA== X-Received: by 2002:a05:620a:f14:b0:76c:9391:6922 with SMTP id v20-20020a05620a0f1400b0076c93916922mr13460093qkl.24.1695757077979; Tue, 26 Sep 2023 12:37:57 -0700 (PDT) Received: from localhost.localdomain (dsl-10-130-229.b2b2c.ca. [72.10.130.229]) by smtp.gmail.com with ESMTPSA id a13-20020a05620a16cd00b0076cbcf8ad3bsm2887595qkn.55.2023.09.26.12.37.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 12:37:57 -0700 (PDT) From: Maxim Cournoyer Date: Tue, 26 Sep 2023 15:04:31 -0400 Message-ID: <1a7b1a9eb1d7c0dacb807b19ba949b55e851692a.1695754731.git.maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/packages/firmware.scm (make-qmk-firmware/implementation) (make-qmk-firmware): New procedures. (qmk-firmware-ergodox-ez-default): New variable. --- gnu/packages/firmware.scm | 126 +++++++++++++++++++++++++++++++++++++- 1 file changed, 125 insertions(+), 1 deletion(-) diff --git a/gnu/packages/firmware.scm b/gnu/packages/firmware.scm index 1957fb8aac4..7220177eadb 100644 --- a/gnu/packages/firmware.scm +++ b/gnu/packages/firmware.scm @@ -28,6 +28,7 @@ (define-module (gnu packages firmware) #:use-module ((guix licenses) #:prefix license:) + #:use-module (guix memoization) #:use-module (guix packages) #:use-module (guix download) #:use-module (guix gexp) @@ -43,6 +44,7 @@ (define-module (gnu packages firmware) #:use-module (gnu packages admin) #:use-module (gnu packages autotools) #:use-module (gnu packages avr) + #:use-module (gnu packages avr-xyz) #:use-module (gnu packages assembly) #:use-module (gnu packages backup) #:use-module (gnu packages base) @@ -80,7 +82,10 @@ (define-module (gnu packages firmware) #:use-module (gnu packages tls) #:use-module (gnu packages version-control) #:use-module (gnu packages xml) - #:use-module (ice-9 match)) + #:use-module (ice-9 format) + #:use-module (ice-9 match) + + #:export (make-qmk-firmware)) (define-public ath9k-htc-firmware (package @@ -1308,3 +1313,122 @@ (define-public qmk install the udev rules provided by the @code{qmk-udev-rules} package to avoid having to run @command{qmk} as root when flashing the firmware.") (license license:expat))) + +(define* (make-qmk-firmware/implementation keyboard keymap + #:key (description "") + keymap-json + keymap-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." + (package + (name (string-append "qmk-firmware-" + (string-replace-substring keyboard "_" "-") "-" + (string-replace-substring keymap "_" "-"))) + ;; Note: When updating this package, make sure to also update the commit + ;; used for the LUFA submodule in the 'copy-lufa-source' phase below. + (version "0.22.3") + (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 + "0s1lcnv7cddpn768p7mrc5bkxhx0ba5p77ya007dnkbk36c33d0w")))) + (build-system gnu-build-system) + (arguments + (list + #:modules '((guix build gnu-build-system) + (guix build utils) + (ice-9 match) + (srfi srfi-26)) + ;; 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"))) + #: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-lufa-source + ;; QMK carries a custom fork of LUFA as a git submodule; make sure + ;; the same commit is used (see: + ;; https://github.com/qmk/qmk_firmware/tree/master/lib). + (lambda _ + (copy-recursively + #$(let ((commit "549b97320d515bfca2f95c145a67bd13be968faa")) + (origin + (inherit (package-source lufa)) + (uri (git-reference + (url "https://github.com/qmk/lufa") + (commit commit))) + (file-name (git-file-name "lufa" commit)) + (sha256 + (base32 + "1rmhm4rxvq8skxqn6vc4n4ly1ak6whj7c386zbsci4pxx548n9h4")))) + "lib/lufa"))) + #$@(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 (find-files ".build" "\\.hex$") + (() + (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))) + (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 make-qmk-firmware (memoize make-qmk-firmware/implementation)) + +(define-public qmk-firmware-ergodox-ez-default + (make-qmk-firmware + "ergodox_ez" "default" #:description + "This is the default keymap used on the ErgoDox EZ keyboard. It includes +the novel MEH and Hyper keys pioneered by the ErgoDox EZ, easy to reach +Control/Shift modifiers keys, and two-functions hold keys to access layer 1. +Layer 1 contains function keys, symbols, a numpad as well as brightness keys. +Layer 2 contains multimedia and mouse keys. See the +@file{keyboards/ergodox_ez/keymaps/default/keymap.c} source file for the +keymap definition, or the +@url{https://configure.ergodox-ez.com/ergodox-ez/layouts/JwwW/latest/0, +ErgoDox EZ Configurator} page."))