diff --git a/.github/workflows/draw.yaml b/.github/workflows/draw.yaml new file mode 100644 index 0000000..ac8a077 --- /dev/null +++ b/.github/workflows/draw.yaml @@ -0,0 +1,54 @@ +name: Draw keymaps +on: + workflow_dispatch: + push: + paths: + - "**.lock" + - "glove80.keymap" + +jobs: + draw: + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + # Set to 2 if amending, or 1 if creating a new commit + fetch-depth: 1 + submodules: recursive + + - name: Install nix + uses: cachix/install-nix-action@v25 + - name: Setup nix cache + uses: DeterminateSystems/magic-nix-cache-action@main + + - name: Draw keymaps + run: | + nix build .#visual + cp result/layout.svg img/layout.svg + + - name: Commit changes + id: commit + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: "[Draw] ${{ github.event.head_commit.message || '(Manually triggered)' }}" + file_pattern: img/** + + - name: Summarize + run: | + sha="${{ steps.commit.outputs.commit_hash }}" + url="${{ github.server_url }}/${{ github.repository }}/commit/$sha" + + echo "## Summary" >> $GITHUB_STEP_SUMMARY + + if [[ -z "$sha" ]]; then + echo "Nothing to commit!" >> $GITHUB_STEP_SUMMARY + else + echo "[\`${sha:0:6}\`]($url) pushed to \`${{ github.ref_name }}\`." >> $GITHUB_STEP_SUMMARY + fi + + echo >> $GITHUB_STEP_SUMMARY + diff --git a/flake.lock b/flake.lock index ba7cee9..29c619b 100644 --- a/flake.lock +++ b/flake.lock @@ -63,6 +63,24 @@ "type": "github" } }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1726560853, + "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "glove80-zmk": { "flake": false, "locked": { @@ -80,6 +98,43 @@ "type": "github" } }, + "keymap-drawer": { + "flake": false, + "locked": { + "lastModified": 1728409735, + "narHash": "sha256-hVoA4ITBqlB+TqvI/qf23L6KFLPLFGRsdYwy6IOPk/k=", + "owner": "caksoylar", + "repo": "keymap-drawer", + "rev": "8e773126a80cd140eb059ee77300208e1941c6b1", + "type": "github" + }, + "original": { + "owner": "caksoylar", + "repo": "keymap-drawer", + "type": "github" + } + }, + "nix-github-actions": { + "inputs": { + "nixpkgs": [ + "poetry2nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1720066371, + "narHash": "sha256-uPlLYH2S0ACj0IcgaK9Lsf4spmJoGejR9DotXiXSBZQ=", + "owner": "nix-community", + "repo": "nix-github-actions", + "rev": "622f829f5fe69310a866c8a6cd07e747c44ef820", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nix-github-actions", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1727634051, @@ -96,12 +151,38 @@ "type": "github" } }, + "poetry2nix": { + "inputs": { + "flake-utils": "flake-utils", + "nix-github-actions": "nix-github-actions", + "nixpkgs": [ + "nixpkgs" + ], + "systems": "systems_2", + "treefmt-nix": "treefmt-nix" + }, + "locked": { + "lastModified": 1728564116, + "narHash": "sha256-BkEqM5zUrYAwRKrfqi7hPOqjgD6+N0NCJvooaY8aQoE=", + "owner": "nix-community", + "repo": "poetry2nix", + "rev": "8a18db56dd62edd26458a87e4d335b7df84c3f3f", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "poetry2nix", + "type": "github" + } + }, "root": { "inputs": { "firmware-loader": "firmware-loader", "flake-parts": "flake-parts_2", "glove80-zmk": "glove80-zmk", - "nixpkgs": "nixpkgs" + "keymap-drawer": "keymap-drawer", + "nixpkgs": "nixpkgs", + "poetry2nix": "poetry2nix" } }, "rust-overlay": { @@ -124,6 +205,56 @@ "repo": "rust-overlay", "type": "github" } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "id": "systems", + "type": "indirect" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "poetry2nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1727984844, + "narHash": "sha256-xpRqITAoD8rHlXQafYZOLvUXCF6cnZkPfoq67ThN0Hc=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "4446c7a6fc0775df028c5a3f6727945ba8400e64", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 209419e..697c9c5 100644 --- a/flake.nix +++ b/flake.nix @@ -14,6 +14,15 @@ url = "github:juliamertz/glove80-firmware-updater"; inputs.nixpkgs.follows = "nixpkgs"; }; + + keymap-drawer = { + url = "github:caksoylar/keymap-drawer"; + flake = false; + }; + poetry2nix = { + url = "github:nix-community/poetry2nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = @@ -35,13 +44,14 @@ ... }: let - inherit (pkgs) callPackage; + inherit (pkgs) callPackage writeShellScriptBin; inherit (config) packages; firmwareLoader = firmware-loader.packages.${system}.default; in { - packages.firmware = callPackage ./firmware.nix { inherit inputs; }; - packages.flash = pkgs.writeShellScriptBin "flash" '' + packages.firmware = callPackage ./packages/firmware.nix { inherit inputs; }; + packages.visual = callPackage ./packages/visual.nix { inherit inputs; }; + packages.flash = writeShellScriptBin "flash" '' ${lib.getExe firmwareLoader} --file ${packages.firmware}/glove80.uf2 ''; diff --git a/img/layout.svg b/img/layout.svg new file mode 100644 index 0000000..64d87e3 --- /dev/null +++ b/img/layout.svg @@ -0,0 +1,1459 @@ + + + +Base: + + + +F1 + + + +F2 + + + +F3 + + + +F4 + + + +F5 + + + +F6 + + + +F7 + + + +F8 + + + +F9 + + + +F10 + + + += + + + +1 + + + +2 + + + +3 + + + +4 + + + +5 + + + +6 + + + +7 + + + +8 + + + +9 + + + +0 + + + +- + + + +TAB + + + +Q + + + +W + + + +E + + + +R + + + +T + + + +Y + + + +U + + + +I + + + +O + + + +P + + + +\ + + + +ESC + + + +A + + + +S + + + +D + + + +F + + + +G + + + +H + + + +J + + + +K + + + +L + + + +; + + + +' + + + +` + + + +Z + + + +X + + + +C + + + +V + + + +B + + + +LSHFT + + + +LCTRL + + + +&lower + + + +RALT + + + +RCTRL + + + +RSHFT + + + +N + + + +M + + + +, + + + +. + + + +/ + + + + +PGUP + + + + +&rgb_ug_st… + +Magic + + + + +Gaming +toggle + + + +END + + + +LEFT + + + +RIGHT + + + +SPACE + + + +LGUI + + + +RET + + + +RGUI + + + +RET + + + +BSPC + + + +UP + + + +DOWN + + + +[ + + + +] + + + + +PGDN + + + + + +Lower: + + + + +BRIDN + + + + + +BRIUP + + + + +PREV + + + +NEXT + + + +PP + + + +MUTE + + + + +VOLDN + + + + + +VOLUP + + + + + + + + +PAUSEBREAK + + + + +F11 + + + +DEL + + + + + + + + + + + + +HOME + + + +( + + + + +KPNUM + + + + + +KPEQUAL + + + + + +KPSLASH + + + + + +KPMULTIPLY + + + + +PRINTSCREEN + + + + + + + + + + + + + + +UPARROW + + + + + + + +END + + + +) + + + + +KP7 + + + + + +KP8 + + + + + +KP9 + + + + + +KPMINUS + + + + +SCROLLLOCK + + + + + + + + + + + +LEFTARROW + + + + + +DOWNARROW + + + + + +RIGHTARROW + + + + + +PGUP + + + + +% + + + + +KP4 + + + + + +KP5 + + + + + +KP6 + + + + + +KPPLUS + + + + + + + + + + + +APP + + + + + + +F11 + + + +F12 + + + + +PGDN + + + + + + + + + + + + + +Base +toggle + + + + + + + + + + + + + + + +, + + + + +KP1 + + + + + +KP2 + + + + + +KP3 + + + + + +KPENTER + + + + + + + + +&rgb_ug_st… + +Magic + + + +CAPS + + + +INS + + + +F11 + + + +F12 + + + + + + + + + + + + + + + + + + + + + + + + + + + + +KP0 + + + + + +KP0 + + + + + +KPDOT + + + + + +KPENTER + + + + + + + + + +Magic: + + + + +BTCLR + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +BTCLRALL + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +RGBSPI + + + + + +RGBSAI + + + + + +RGBHUI + + + + + +RGBBRI + + + + + +RGBTOG + + + + + + + + + + + + + + + + + + + + + + +&bootloader + + + + +RGBSPD + + + + + +RGBSAD + + + + + +RGBHUD + + + + + +RGBBRD + + + + + +RGBEFF + + + + + + + + + + + + + + + + + + + +&bootloader + + + +&sys_reset + + + + + + + + + + + + + + + + + + +&bt_2 + + + +&bt_3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +&sys_reset + + + + + + + + + + + + + + + + + + +&bt_0 + + + +&bt_1 + + + + +OUTUSB + + + + + + + + + + + + + + + + + + + + + + + + + + +Magic +toggle + + + + +Gaming: + + + +F1 + + + +F2 + + + +F3 + + + +F4 + + + +F5 + + + +F6 + + + +F7 + + + +F8 + + + +F9 + + + +F10 + + + += + + + +1 + + + +2 + + + +3 + + + +4 + + + +5 + + + +6 + + + +7 + + + +8 + + + +9 + + + +0 + + + +- + + + +TAB + + + + + + + +Q + + + +W + + + +E + + + +R + + + +T + + + +Y + + + +U + + + +I + + + +O + + + +P + + + +ESC + + + +LSHFT + + + +A + + + +S + + + +D + + + +F + + + +G + + + +H + + + +J + + + +K + + + +L + + + +; + + + +` + + + +Z + + + +X + + + +C + + + +V + + + +B + + + +LSHFT + + + +LGUI + + + + +Gaming +toggle + + + +RALT + + + +RCTRL + + + +RSHFT + + + +N + + + +M + + + +, + + + +. + + + +/ + + + + +PGUP + + + + + + + + +HOME + + + +END + + + +LEFT + + + +RIGHT + + + +SPACE + + + +LCTRL + + + +RET + + + +RGUI + + + +RET + + + +BSPC + + + +UP + + + +DOWN + + + +[ + + + +] + + + + +PGDN + + + + + diff --git a/firmware.nix b/packages/firmware.nix similarity index 83% rename from firmware.nix rename to packages/firmware.nix index 198f179..c5c5751 100644 --- a/firmware.nix +++ b/packages/firmware.nix @@ -2,8 +2,8 @@ let firmware = import inputs.glove80-zmk { inherit pkgs; }; - keymap = ./glove80.keymap; - kconfig = ./glove80.conf; + keymap = ../glove80.keymap; + kconfig = ../glove80.conf; left = firmware.zmk.override { inherit keymap kconfig; diff --git a/packages/visual.nix b/packages/visual.nix new file mode 100644 index 0000000..a595a4b --- /dev/null +++ b/packages/visual.nix @@ -0,0 +1,26 @@ +{ + pkgs, + lib, + stdenvNoCC, + inputs, +}: +let + poetry2nix = inputs.poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }; + keymapDrawer = lib.getExe ( + poetry2nix.mkPoetryApplication { + projectDir = inputs.keymap-drawer; + preferWheels = true; + meta.mainProgram = "keymap"; + } + ); +in +stdenvNoCC.mkDerivation { + name = "layout-visualization"; + src = ../.; + + buildPhase = '' + mkdir -p $out + ${keymapDrawer} parse -c 10 -z glove80.keymap > $out/layout.yaml + ${keymapDrawer} draw $out/layout.yaml > $out/layout.svg + ''; +}