generated from moergo-sc/glove80-zmk-config
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: remove devshell & rewrite scripts
- Use `pkgs.writeShellApplication` instead of devshell commands - Rewrite `flash` script to be more robust - Tweak `draw` script so unrelated SVGs aren't removed
- Loading branch information
1 parent
b74ccad
commit a1e6f1a
Showing
5 changed files
with
151 additions
and
146 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
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
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 |
---|---|---|
@@ -1,66 +1,69 @@ | ||
{ | ||
inputs, | ||
lib, | ||
... | ||
}: let | ||
in { | ||
perSystem = { | ||
config, | ||
pkgs, | ||
system, | ||
... | ||
}: let | ||
inherit (inputs.poetry2nix.lib.mkPoetry2Nix {inherit pkgs;}) mkPoetryApplication; | ||
|
||
exe = lib.getExe config.packages.keymap-drawer; | ||
yq = lib.getExe pkgs.yq-go; | ||
in { | ||
packages = { | ||
keymap-drawer = mkPoetryApplication { | ||
projectDir = inputs.keymap-drawer; | ||
preferWheels = true; | ||
meta = { | ||
mainProgram = "keymap"; | ||
homepage = "https://github.com/caksoylar/keymap-drawer"; | ||
}; | ||
}: { | ||
perSystem = { | ||
config, | ||
pkgs, | ||
system, | ||
... | ||
}: let | ||
inherit (inputs.poetry2nix.lib.mkPoetry2Nix {inherit pkgs;}) mkPoetryApplication; | ||
in { | ||
packages = { | ||
keymap-drawer = mkPoetryApplication { | ||
projectDir = inputs.keymap-drawer; | ||
preferWheels = true; | ||
meta = { | ||
mainProgram = "keymap"; | ||
homepage = "https://github.com/caksoylar/keymap-drawer"; | ||
}; | ||
}; | ||
}; | ||
|
||
devshells.default.commands = [ | ||
{ | ||
name = "draw"; | ||
command = /*bash*/ '' | ||
set +e | ||
|
||
out="$PRJ_ROOT"/img | ||
keymap_dir="$PRJ_ROOT"/config | ||
cmd="${exe} --config $keymap_dir/keymap_drawer.yaml" | ||
# Draw SVG images of the keymap | ||
draw = pkgs.writeShellApplication { | ||
name = "draw"; | ||
runtimeInputs = [ | ||
pkgs.yq-go | ||
config.packages.keymap-drawer | ||
]; | ||
text = '' | ||
set +e | ||
echo "Removing previous images" | ||
rm "$out"/*.{yaml,svg} | ||
out=./img | ||
keymap_dir=./config | ||
for file in "$keymap_dir"/*.keymap | ||
do | ||
name="$(basename --suffix=".keymap" "$file")" | ||
config="$out/$name.yaml" | ||
echo "Found $name keymap" | ||
cmd() { | ||
keymap --config "$keymap_dir"/keymap_drawer.yaml "$@" | ||
} | ||
for file in "$keymap_dir"/*.keymap | ||
do | ||
name="$(basename --suffix=".keymap" "$file")" | ||
config="$out/$name.yaml" | ||
echo "Found $name keymap" | ||
echo "- Parsing keymap-drawer" | ||
$cmd parse --zmk-keymap "$file" > "$config" | ||
echo "- Removing old images" | ||
rm "$out"/"$name".yaml | ||
rm "$out"/"$name".svg | ||
rm "$out"/"$name"_*.svg | ||
echo "- Drawing all layers" | ||
$cmd draw "$config" > "$out"/"$name".svg | ||
echo "- Parsing keymap-drawer" | ||
cmd parse --zmk-keymap "$file" > "$config" | ||
layers=$(${yq} '.layers | keys | .[]' "$config") | ||
for layer in $layers | ||
do | ||
echo "- Drawing $layer layer" | ||
$cmd draw "$config" --select-layers "$layer" > "$out"/"$name"_"$layer".svg | ||
done | ||
echo "- Drawing all layers" | ||
cmd draw "$config" > "$out"/"$name".svg | ||
layers=$(yq '.layers | keys | .[]' "$config") | ||
for layer in $layers | ||
do | ||
echo "- Drawing $layer layer" | ||
cmd draw "$config" --select-layers "$layer" > "$out"/"$name"_"$layer".svg | ||
done | ||
''; | ||
help = "Draw SVG images of the keymap"; | ||
} | ||
]; | ||
done | ||
''; | ||
}; | ||
}; | ||
}; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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