From c4459708697a85475a8ed4d03afdac565486c720 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Fri, 15 Nov 2024 01:31:55 +0200 Subject: feat(users/flokli/kb): add chocofi `buildSplitKeyboard`, as well as all the patching of `miryoku_zmk` is independent of the specific keyboard used, so it can be moved one layer up. `config-flat` is now provided through a helper function, accepting the name of the keymap to use when rendering the config. This all makes the amount of code added for the new keyboard itself pleasantly small. Change-Id: I2216aa246502eddaf9bc4f4d126b0639d574ad87 Reviewed-on: https://cl.tvl.fyi/c/depot/+/12787 Reviewed-by: flokli Autosubmit: flokli Tested-by: BuildkiteCI --- ...aviors-add-quick-tap-ms-require-prior-idl.patch | 25 ++++++++++ ...er_alternatives.h-expose-alt-gr-on-G-and-.patch | 25 ++++++++++ users/flokli/keyboards/chocofi/default.nix | 25 ++++++++++ ...aviors-add-quick-tap-ms-require-prior-idl.patch | 25 ---------- ...er_alternatives.h-expose-alt-gr-on-G-and-.patch | 25 ---------- users/flokli/keyboards/corneish_zen/default.nix | 58 ++++------------------ users/flokli/keyboards/corneish_zen/west.yml | 34 ------------- users/flokli/keyboards/default.nix | 53 ++++++++++++++++++++ users/flokli/keyboards/west.yml | 34 +++++++++++++ 9 files changed, 172 insertions(+), 132 deletions(-) create mode 100644 users/flokli/keyboards/0001-miryoku_behaviors-add-quick-tap-ms-require-prior-idl.patch create mode 100644 users/flokli/keyboards/0001-miryoku_layer_alternatives.h-expose-alt-gr-on-G-and-.patch create mode 100644 users/flokli/keyboards/chocofi/default.nix delete mode 100644 users/flokli/keyboards/corneish_zen/0001-miryoku_behaviors-add-quick-tap-ms-require-prior-idl.patch delete mode 100644 users/flokli/keyboards/corneish_zen/0001-miryoku_layer_alternatives.h-expose-alt-gr-on-G-and-.patch delete mode 100644 users/flokli/keyboards/corneish_zen/west.yml create mode 100644 users/flokli/keyboards/default.nix create mode 100644 users/flokli/keyboards/west.yml diff --git a/users/flokli/keyboards/0001-miryoku_behaviors-add-quick-tap-ms-require-prior-idl.patch b/users/flokli/keyboards/0001-miryoku_behaviors-add-quick-tap-ms-require-prior-idl.patch new file mode 100644 index 000000000000..fc86c0627ddc --- /dev/null +++ b/users/flokli/keyboards/0001-miryoku_behaviors-add-quick-tap-ms-require-prior-idl.patch @@ -0,0 +1,25 @@ +From 9ed3e8ee2aad704fcfef2490617e2fd22902b2c4 Mon Sep 17 00:00:00 2001 +From: Florian Klink +Date: Sun, 27 Oct 2024 12:01:13 +0100 +Subject: [PATCH] miryoku_behaviors: add quick-tap-ms, require-prior-idle-ms + +--- + miryoku/miryoku_behaviors.dtsi | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/miryoku/miryoku_behaviors.dtsi b/miryoku/miryoku_behaviors.dtsi +index 473df49..73211da 100644 +--- a/miryoku/miryoku_behaviors.dtsi ++++ b/miryoku/miryoku_behaviors.dtsi +@@ -14,6 +14,8 @@ + compatible = "zmk,behavior-hold-tap"; + #binding-cells = <2>; + tapping-term-ms = ; ++ quick-tap-ms = <200>; ++ require-prior-idle-ms = <125>; + flavor = "tap-preferred"; + bindings = <&mo>, <&kp>; + }; +-- +2.46.1 + diff --git a/users/flokli/keyboards/0001-miryoku_layer_alternatives.h-expose-alt-gr-on-G-and-.patch b/users/flokli/keyboards/0001-miryoku_layer_alternatives.h-expose-alt-gr-on-G-and-.patch new file mode 100644 index 000000000000..540ecb162e2d --- /dev/null +++ b/users/flokli/keyboards/0001-miryoku_layer_alternatives.h-expose-alt-gr-on-G-and-.patch @@ -0,0 +1,25 @@ +From a852a9738cc7510f6d3b80d1befb3c88ef8f08f7 Mon Sep 17 00:00:00 2001 +From: Florian Klink +Date: Sun, 27 Oct 2024 11:14:30 +0100 +Subject: [PATCH] miryoku_layer_alternatives.h: expose alt-gr on G and M + +--- + miryoku/miryoku_babel/miryoku_layer_alternatives.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/miryoku/miryoku_babel/miryoku_layer_alternatives.h b/miryoku/miryoku_babel/miryoku_layer_alternatives.h +index 8044fdd..07ed9b6 100644 +--- a/miryoku/miryoku_babel/miryoku_layer_alternatives.h ++++ b/miryoku/miryoku_babel/miryoku_layer_alternatives.h +@@ -86,7 +86,7 @@ U_NP, U_NP, U_LT(U_MEDIA, ESC),U_LT(U_NAV, SPACE),U_LT + + #define MIRYOKU_ALTERNATIVES_BASE_COLEMAKDH \ + &kp Q, &kp W, &kp F, &kp P, &kp B, &kp J, &kp L, &kp U, &kp Y, &kp SQT, \ +-U_MT(LGUI, A), U_MT(LALT, R), U_MT(LCTRL, S), U_MT(LSHFT, T), &kp G, &kp M, U_MT(LSHFT, N), U_MT(LCTRL, E), U_MT(LALT, I), U_MT(LGUI, O), \ ++U_MT(LGUI, A), U_MT(LALT, R), U_MT(LCTRL, S), U_MT(LSHFT, T), U_MT(RALT, G), U_MT(RALT, M), U_MT(LSHFT, N), U_MT(LCTRL, E), U_MT(LALT, I), U_MT(LGUI, O), \ + U_LT(U_BUTTON, Z), U_MT(RALT, X), &kp C, &kp D, &kp V, &kp K, &kp H, &kp COMMA, U_MT(RALT, DOT), U_LT(U_BUTTON, SLASH),\ + U_NP, U_NP, U_LT(U_MEDIA, ESC),U_LT(U_NAV, SPACE),U_LT(U_MOUSE, TAB),U_LT(U_SYM, RET), U_LT(U_NUM, BSPC), U_LT(U_FUN, DEL), U_NP, U_NP + +-- +2.46.1 + diff --git a/users/flokli/keyboards/chocofi/default.nix b/users/flokli/keyboards/chocofi/default.nix new file mode 100644 index 000000000000..b8343f9592cc --- /dev/null +++ b/users/flokli/keyboards/chocofi/default.nix @@ -0,0 +1,25 @@ +{ pkgs, depot, ... }: +rec { + firmware = depot.users.flokli.keyboards.buildSplitKeyboard { + name = "nice_nano_v2"; + board = "nice_nano_v2"; + shield = "corne_%PART% nice_view_adapter nice_view"; + zephyrDepsHash = "sha256-D5CAlrO/E6DPbtUJyh/ec8ACpo1XM1jx2gLS2TpklBQ="; + src = depot.users.flokli.keyboards.miryoku_config; + }; + + config-flat = depot.users.flokli.keyboards.mkFlatConfig "corne"; + + flash-left = pkgs.writeShellScript "flash.sh" '' + cp ${firmware}/zmk_left.uf2 /run/media/$USER/NICENANO/ + ''; + + flash-right = pkgs.writeShellScript "flash.sh" '' + cp ${firmware}/zmk_right.uf2 /run/media/$USER/NICENANO/ + ''; + + meta.ci.targets = [ + "config-flat" + "firmware" + ]; +} diff --git a/users/flokli/keyboards/corneish_zen/0001-miryoku_behaviors-add-quick-tap-ms-require-prior-idl.patch b/users/flokli/keyboards/corneish_zen/0001-miryoku_behaviors-add-quick-tap-ms-require-prior-idl.patch deleted file mode 100644 index fc86c0627ddc..000000000000 --- a/users/flokli/keyboards/corneish_zen/0001-miryoku_behaviors-add-quick-tap-ms-require-prior-idl.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 9ed3e8ee2aad704fcfef2490617e2fd22902b2c4 Mon Sep 17 00:00:00 2001 -From: Florian Klink -Date: Sun, 27 Oct 2024 12:01:13 +0100 -Subject: [PATCH] miryoku_behaviors: add quick-tap-ms, require-prior-idle-ms - ---- - miryoku/miryoku_behaviors.dtsi | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/miryoku/miryoku_behaviors.dtsi b/miryoku/miryoku_behaviors.dtsi -index 473df49..73211da 100644 ---- a/miryoku/miryoku_behaviors.dtsi -+++ b/miryoku/miryoku_behaviors.dtsi -@@ -14,6 +14,8 @@ - compatible = "zmk,behavior-hold-tap"; - #binding-cells = <2>; - tapping-term-ms = ; -+ quick-tap-ms = <200>; -+ require-prior-idle-ms = <125>; - flavor = "tap-preferred"; - bindings = <&mo>, <&kp>; - }; --- -2.46.1 - diff --git a/users/flokli/keyboards/corneish_zen/0001-miryoku_layer_alternatives.h-expose-alt-gr-on-G-and-.patch b/users/flokli/keyboards/corneish_zen/0001-miryoku_layer_alternatives.h-expose-alt-gr-on-G-and-.patch deleted file mode 100644 index 540ecb162e2d..000000000000 --- a/users/flokli/keyboards/corneish_zen/0001-miryoku_layer_alternatives.h-expose-alt-gr-on-G-and-.patch +++ /dev/null @@ -1,25 +0,0 @@ -From a852a9738cc7510f6d3b80d1befb3c88ef8f08f7 Mon Sep 17 00:00:00 2001 -From: Florian Klink -Date: Sun, 27 Oct 2024 11:14:30 +0100 -Subject: [PATCH] miryoku_layer_alternatives.h: expose alt-gr on G and M - ---- - miryoku/miryoku_babel/miryoku_layer_alternatives.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/miryoku/miryoku_babel/miryoku_layer_alternatives.h b/miryoku/miryoku_babel/miryoku_layer_alternatives.h -index 8044fdd..07ed9b6 100644 ---- a/miryoku/miryoku_babel/miryoku_layer_alternatives.h -+++ b/miryoku/miryoku_babel/miryoku_layer_alternatives.h -@@ -86,7 +86,7 @@ U_NP, U_NP, U_LT(U_MEDIA, ESC),U_LT(U_NAV, SPACE),U_LT - - #define MIRYOKU_ALTERNATIVES_BASE_COLEMAKDH \ - &kp Q, &kp W, &kp F, &kp P, &kp B, &kp J, &kp L, &kp U, &kp Y, &kp SQT, \ --U_MT(LGUI, A), U_MT(LALT, R), U_MT(LCTRL, S), U_MT(LSHFT, T), &kp G, &kp M, U_MT(LSHFT, N), U_MT(LCTRL, E), U_MT(LALT, I), U_MT(LGUI, O), \ -+U_MT(LGUI, A), U_MT(LALT, R), U_MT(LCTRL, S), U_MT(LSHFT, T), U_MT(RALT, G), U_MT(RALT, M), U_MT(LSHFT, N), U_MT(LCTRL, E), U_MT(LALT, I), U_MT(LGUI, O), \ - U_LT(U_BUTTON, Z), U_MT(RALT, X), &kp C, &kp D, &kp V, &kp K, &kp H, &kp COMMA, U_MT(RALT, DOT), U_LT(U_BUTTON, SLASH),\ - U_NP, U_NP, U_LT(U_MEDIA, ESC),U_LT(U_NAV, SPACE),U_LT(U_MOUSE, TAB),U_LT(U_SYM, RET), U_LT(U_NUM, BSPC), U_LT(U_FUN, DEL), U_NP, U_NP - --- -2.46.1 - diff --git a/users/flokli/keyboards/corneish_zen/default.nix b/users/flokli/keyboards/corneish_zen/default.nix index f570fc0bc003..5583cc929ee4 100644 --- a/users/flokli/keyboards/corneish_zen/default.nix +++ b/users/flokli/keyboards/corneish_zen/default.nix @@ -1,57 +1,14 @@ -{ pkgs, lib, ... }: -let - zmk-nix = pkgs.fetchFromGitHub { - owner = "lilyinstarlight"; - repo = "zmk-nix"; - rev = "d72e94ab94b2bceb60a29a2a8c2e1d304a4e922e"; - hash = "sha256-3WXPPBJ2u8rMxejPhUahSiqOBr1BOfTgDa7oQDPtw54="; - }; - - builders = pkgs.callPackage (import (zmk-nix + "/nix/builders.nix")) { }; - - miryoku_zmk = pkgs.fetchFromGitHub { - owner = "manna-harbour"; - repo = "miryoku_zmk"; - rev = "e6683e9f8b6c199b339208b1b501e88a7308ed48"; - hash = "sha256-GjTbAoyhr557Tn4JaWsA3Po5KxMsQXrpKc9H+PU3T8A="; - }; - - miryoku_zmk_patched = pkgs.runCommand "miryoku_zmk_patched" { } '' - mkdir -p $out - cp -r ${miryoku_zmk}/. $out/ - cd $out - chmod -R +w $out - patch -p1 < ${./0001-miryoku_layer_alternatives.h-expose-alt-gr-on-G-and-.patch} - patch -p1 < ${./0001-miryoku_behaviors-add-quick-tap-ms-require-prior-idl.patch} - ''; - -in - +{ pkgs, depot, ... }: rec { - config = pkgs.runCommand "config" { } '' - mkdir -p $out/config - cp -r ${miryoku_zmk_patched}/miryoku $out/ - cp ${./west.yml} $out/config/west.yml - cp ${miryoku_zmk_patched}/config/corneish_zen.keymap $out/config/ - ''; - - # helpful for debugging the resulting keymap - config-flat = pkgs.runCommand "config-flat" - { - nativeBuildInputs = [ pkgs.python3.pkgs.pcpp ]; - } '' - mkdir -p $out/config - cp ${./west.yml} $out/config/west.yml - pcpp --passthru-unfound-includes -o $out/config/corneish_zen.keymap ${miryoku_zmk_patched}/config/corneish_zen.keymap - ''; - - firmware = builders.buildSplitKeyboard { + firmware = depot.users.flokli.keyboards.buildSplitKeyboard { name = "corneish_zen_v1"; board = "corneish_zen_v1_%PART%"; zephyrDepsHash = "sha256-D5CAlrO/E6DPbtUJyh/ec8ACpo1XM1jx2gLS2TpklBQ="; - src = config; + src = depot.users.flokli.keyboards.miryoku_config; }; + config-flat = depot.users.flokli.keyboards.mkFlatConfig "corneish_zen"; + flash-left = pkgs.writeShellScript "flash.sh" '' cp ${firmware}/zmk_left.uf2 /run/media/$USER/CORNEISHZEN/ ''; @@ -59,4 +16,9 @@ rec { flash-right = pkgs.writeShellScript "flash.sh" '' cp ${firmware}/zmk_right.uf2 /run/media/$USER/CORNEISHZEN/ ''; + + meta.ci.targets = [ + "config-flat" + "firmware" + ]; } diff --git a/users/flokli/keyboards/corneish_zen/west.yml b/users/flokli/keyboards/corneish_zen/west.yml deleted file mode 100644 index b48d4a66e986..000000000000 --- a/users/flokli/keyboards/corneish_zen/west.yml +++ /dev/null @@ -1,34 +0,0 @@ -manifest: - remotes: - - name: zmkfirmware - url-base: https://github.com/zmkfirmware - projects: - - name: zephyr - remote: zmkfirmware - revision: f8e4d15791602c67405c0fd2651167a895939565 # v3.5.0+zmk-fixes - import: - name-blocklist: - - ci-tools - - hal_altera - - hal_cypress - - hal_infineon - - hal_microchip - - hal_nxp - - hal_openisa - - hal_silabs - - hal_xtensa - - hal_st - - hal_ti - - loramac-node - - mcuboot - - mcumgr - - net-tools - - openthread - - edtt - - trusted-firmware-m - - name: zmk - remote: zmkfirmware - revision: 7f1ee320ab638245bbdae9b1cda5d5c50e2cb16e # main - import: app/west.yml - self: - path: config diff --git a/users/flokli/keyboards/default.nix b/users/flokli/keyboards/default.nix new file mode 100644 index 000000000000..d843d541df53 --- /dev/null +++ b/users/flokli/keyboards/default.nix @@ -0,0 +1,53 @@ +{ pkgs, ... }: + + +let + zmk-nix = pkgs.fetchFromGitHub { + owner = "lilyinstarlight"; + repo = "zmk-nix"; + rev = "d72e94ab94b2bceb60a29a2a8c2e1d304a4e922e"; + hash = "sha256-3WXPPBJ2u8rMxejPhUahSiqOBr1BOfTgDa7oQDPtw54="; + }; + + zmk_builders = pkgs.callPackage (import (zmk-nix + "/nix/builders.nix")) { }; + + miryoku_zmk = pkgs.fetchFromGitHub { + owner = "manna-harbour"; + repo = "miryoku_zmk"; + rev = "e6683e9f8b6c199b339208b1b501e88a7308ed48"; + hash = "sha256-GjTbAoyhr557Tn4JaWsA3Po5KxMsQXrpKc9H+PU3T8A="; + }; + + miryoku_zmk_patched = pkgs.runCommand "miryoku_zmk_patched" { } '' + mkdir -p $out + cp -r ${miryoku_zmk}/. $out/ + cd $out + chmod -R +w $out + patch -p1 < ${./0001-miryoku_layer_alternatives.h-expose-alt-gr-on-G-and-.patch} + patch -p1 < ${./0001-miryoku_behaviors-add-quick-tap-ms-require-prior-idl.patch} + ''; + + miryoku_config = pkgs.runCommand "config" { } '' + mkdir -p $out/config + cp -r ${miryoku_zmk_patched}/miryoku $out/ + cp ${./west.yml} $out/config/west.yml + cp ${miryoku_zmk_patched}/config/*.keymap $out/config/ + ''; + + # helpful for debugging a resulting keymap config + mkFlatConfig = name: pkgs.runCommand "config-flat" + { + nativeBuildInputs = [ pkgs.python3.pkgs.pcpp ]; + } '' + mkdir -p $out/config + cp ${./west.yml} $out/config/west.yml + pcpp --passthru-unfound-includes -o $out/config/${name}.keymap ${miryoku_zmk_patched}/config/${name}.keymap + ''; + +in + +{ + miryoku_zmk = miryoku_zmk_patched; + inherit (zmk_builders) buildSplitKeyboard; + inherit miryoku_config mkFlatConfig; +} diff --git a/users/flokli/keyboards/west.yml b/users/flokli/keyboards/west.yml new file mode 100644 index 000000000000..b48d4a66e986 --- /dev/null +++ b/users/flokli/keyboards/west.yml @@ -0,0 +1,34 @@ +manifest: + remotes: + - name: zmkfirmware + url-base: https://github.com/zmkfirmware + projects: + - name: zephyr + remote: zmkfirmware + revision: f8e4d15791602c67405c0fd2651167a895939565 # v3.5.0+zmk-fixes + import: + name-blocklist: + - ci-tools + - hal_altera + - hal_cypress + - hal_infineon + - hal_microchip + - hal_nxp + - hal_openisa + - hal_silabs + - hal_xtensa + - hal_st + - hal_ti + - loramac-node + - mcuboot + - mcumgr + - net-tools + - openthread + - edtt + - trusted-firmware-m + - name: zmk + remote: zmkfirmware + revision: 7f1ee320ab638245bbdae9b1cda5d5c50e2cb16e # main + import: app/west.yml + self: + path: config -- cgit 1.4.1