Skip to content

tamercuba/musubi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Musubi

A Clojure DSL that compiles to ZMK and QMK firmware. Write your keyboard layout once, build for anything.


The Problem

ZMK and QMK are powerful. Their configuration is not.

ZMK asks you to write devicetree. QMK asks you to write C. Both require learning a firmware-specific format before you can place a single key. Changing one behavior means understanding the internals of a specific ecosystem. Sharing a layout between two keyboards is copy-paste.

Musubi replaces all of that with a small set of Clojure macros. You describe what your keyboard does. Musubi handles the rest.


What It Looks Like

(ns my-keyboards.corne.keyboard
  (:require [musubi.dsl :refer [defproject deflayer defbehavior defkeymap]]))

(defproject my-corne
  :firmware :zmk
  :model    :corne)

(defbehavior thumb-spc
  :type   :hold-tap
  :tap    :kp/spc
  :hold   :kp/lshft
  :flavor :balanced)

(deflayer base
  [:kp/esc  :kp/q  :kp/w  :kp/e  :kp/r  :kp/t]   [:kp/y  :kp/u  :kp/i    :kp/o   :kp/p    :kp/bspc]
  [:kp/tab  :kp/a  :kp/s  :kp/d  :kp/f  :kp/g]   [:kp/h  :kp/j  :kp/k    :kp/l   :kp/semi :kp/ret]
  [:kp/lctl :kp/z  :kp/x  :kp/c  :kp/v  :kp/b]   [:kp/n  :kp/m  :kp/comm :kp/dot :kp/slsh :kp/lalt]
  [:kp/lgui :behavior/trans :behavior/thumb-spc]   [:kp/ret :kp/bspc :kp/del])

(deflayer nav
  [:behavior/trans :behavior/trans :behavior/trans :behavior/trans :behavior/trans :behavior/trans]   [:behavior/trans :kp/home :kp/pgup :kp/pgdn :kp/end  :behavior/trans]
  [:behavior/trans :behavior/trans :behavior/trans :behavior/trans :behavior/trans :behavior/trans]   [:behavior/trans :kp/left :kp/up   :kp/down :kp/rght :behavior/trans]
  [:behavior/trans :behavior/trans :behavior/trans :behavior/trans :behavior/trans :behavior/trans]   [:behavior/trans :behavior/trans :behavior/trans :behavior/trans :behavior/trans :behavior/trans]
  [:behavior/trans :behavior/trans :behavior/trans]                                                   [:behavior/trans :behavior/trans :behavior/trans])

(defkeymap my-corne
  :project my-corne
  :layers  [base nav])

That file compiles to a complete ZMK .keymap. Switch :firmware to :qmk and the same file produces keymap.c. No devicetree, no C, no firmware documentation required.

Every macro expands to a plain Clojure map. You can inspect, test, and validate your layout before it ever touches a compiler:

;; In the REPL
base
;; => {:name :base, :bindings [:kp/esc :kp/q :kp/w ...]}

thumb-spc
;; => {:name :thumb-spc, :type :hold-tap, :tap :kp/spc, :hold :kp/lshft, :flavor :balanced}

Your keyboard config is data. Write unit tests against it, diff two layouts programmatically, or build tooling on top. All before compiling a single line of firmware.


How It Works

[keyboard.clj] -> [parser] -> [universal IR] -> [ZMK backend] -> [.keymap + west build]
                                             -> [QMK backend] -> [keymap.c + qmk compile]

Musubi evaluates your keyboard file, validates the layout against a built-in registry of known keyboards, and dispatches to the correct backend. The firmware toolchain (ZMK's west, QMK's CLI) is installed and managed by Musubi. You never touch it directly.


Status

Early development. The DSL and IR are being built. Nothing compiles to firmware yet.

About

A Clojure DSL that compiles to ZMK and QMK firmware. Write your keyboard layout once, build for anything.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Contributors