-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
536 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Dim direnv status messages | ||
export DIRENV_LOG_FORMAT=$'\033[2mdirenv: %s\033[0m' | ||
|
||
# Use flake | ||
use flake | ||
|
||
# Watch additional files | ||
watch_file draw/default.nix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Highlight keymap files as C++, which is better than nothing. | ||
*.dtsi text linguist-language=C++ | ||
*.keymap text linguist-language=C++ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.build/ | ||
.direnv/ | ||
.venv/ | ||
.west/ | ||
modules/ | ||
firmware/ | ||
zephyr/ | ||
zmk/ | ||
# Ignore keymap-drawer output for now | ||
draw/skeletyl.svg | ||
draw/skeletyl.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
default: | ||
@just --list --unsorted | ||
|
||
config := absolute_path('config') | ||
build := absolute_path('.build') | ||
out := absolute_path('firmware') | ||
draw := absolute_path('draw') | ||
|
||
# parse build.yaml and filter targets by expression | ||
_parse_targets $expr: | ||
#!/usr/bin/env bash | ||
attrs="[.board, .shield]" | ||
filter="(($attrs | map(. // [.]) | combinations), ((.include // {})[] | $attrs)) | join(\",\")" | ||
echo "$(yq -r "$filter" build.yaml | grep -v "^," | grep -i "${expr/#all/.*}")" | ||
# build firmware for single board & shield combination | ||
_build_single $board $shield *west_args: | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
artifact="${shield:+${shield// /+}-}${board}" | ||
build_dir="{{ build / '$artifact' }}" | ||
echo "Building firmware for $artifact..." | ||
west build -s zmk/app -d "$build_dir" -b $board {{ west_args }} -- \ | ||
-DZMK_CONFIG="{{ config }}" ${shield:+-DSHIELD="$shield"} | ||
|
||
if [[ -f "$build_dir/zephyr/zmk.uf2" ]]; then | ||
mkdir -p "{{ out }}" && cp "$build_dir/zephyr/zmk.uf2" "{{ out }}/$artifact.uf2" | ||
else | ||
mkdir -p "{{ out }}" && cp "$build_dir/zephyr/zmk.bin" "{{ out }}/$artifact.bin" | ||
fi | ||
|
||
# build firmware for matching targets | ||
build expr *west_args: | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
targets=$(just _parse_targets {{ expr }}) | ||
[[ -z $targets ]] && echo "No matching targets found. Aborting..." >&2 && exit 1 | ||
echo "$targets" | while IFS=, read -r board shield; do | ||
just _build_single "$board" "$shield" {{ west_args }} | ||
done | ||
|
||
# clear build cache and artifacts | ||
clean: | ||
rm -rf {{ build }} {{ out }} | ||
|
||
# clear all automatically generated files | ||
clean-all: clean | ||
rm -rf .west zmk | ||
|
||
# clear nix cache | ||
clean-nix: | ||
nix-collect-garbage --delete-old | ||
|
||
# parse & plot keymap | ||
draw: | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
keymap -c "{{ draw }}/config.yaml" parse -z "{{ config }}/skeletyl.keymap" >"{{ draw }}/skeletyl.yaml" | ||
keymap -c "{{ draw }}/config.yaml" draw "{{ draw }}/skeletyl.yaml" -k "bastardkb/skeletyl" >"{{ draw }}/skeletyl.svg" | ||
# initialize west | ||
init: | ||
west init -l config | ||
west update | ||
west zephyr-export | ||
|
||
# list build targets | ||
list: | ||
@just _parse_targets all | sed 's/,$//' | sort | column | ||
|
||
# update west | ||
update: | ||
west update | ||
|
||
# upgrade zephyr-sdk and python dependencies | ||
upgrade-sdk: | ||
nix flake update --flake . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
proseWrap: "always" | ||
editorconfig: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
parse_config: | ||
zmk_preamble: "#include <zmk-helpers/key-labels/34.h>" | ||
zmk_additional_includes: | ||
- "modules/helpers/include" | ||
|
||
draw_config: | ||
footer_text: "0xcharly/zmk-config" | ||
dark_mode: auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
lib, | ||
buildPythonApplication, | ||
fetchPypi, | ||
poetry-core, | ||
pydantic, | ||
pcpp, | ||
pyparsing, | ||
pyyaml, | ||
platformdirs, | ||
pydantic-settings, | ||
}: | ||
buildPythonApplication rec { | ||
pname = "keymap-drawer"; | ||
version = "0.18.1"; | ||
pyproject = true; | ||
|
||
src = fetchPypi { | ||
pname = "keymap_drawer"; | ||
inherit version; | ||
hash = "sha256-MHjxsopXoYWZFuXUbeaI7BCSx3HkRaeVidY+mc8lj+s="; | ||
}; | ||
|
||
build-system = [poetry-core]; | ||
|
||
propagatedBuildInputs = [ | ||
pydantic | ||
pcpp | ||
pyparsing | ||
pyyaml | ||
platformdirs | ||
pydantic-settings | ||
]; | ||
|
||
doCheck = false; | ||
|
||
meta = { | ||
homepage = "https://github.com/caksoylar/keymap-drawer"; | ||
description = "Parse QMK & ZMK keymaps and draw them as vector graphics"; | ||
license = lib.licenses.mit; | ||
}; | ||
} |
Oops, something went wrong.