about summary refs log tree commit diff
path: root/users/flokli/keyboards/default.nix
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2024-11-14T23·31+0200
committerclbot <clbot@tvl.fyi>2024-11-15T00·00+0000
commitc4459708697a85475a8ed4d03afdac565486c720 (patch)
treebff81656b30a620252b3fba94d0abf456dd9afbb /users/flokli/keyboards/default.nix
parent7a54360a39f4c5649a48fc6be919085170c4294c (diff)
feat(users/flokli/kb): add chocofi r/8922
`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 <flokli@flokli.de>
Autosubmit: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
Diffstat (limited to 'users/flokli/keyboards/default.nix')
-rw-r--r--users/flokli/keyboards/default.nix53
1 files changed, 53 insertions, 0 deletions
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;
+}