diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 0000000..e637f8c --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,146 @@ +name: Check code quality + +on: + push: + branches: [ main, develop ] + paths: + - 'keymap/**' + - 'QMK' + - 'shell.nix' + - '.github/workflows/check.yml' + workflow_dispatch: {} + +jobs: + check: + name: Check code quality + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + submodules: recursive + path: ./repo + + - name: Set up Nix + uses: cachix/install-nix-action@v15 + with: + nix_path: nixpkgs=channel:nixos-unstable + extra_nix_config: | + experimental-features = nix-command + + - name: Set up cache + uses: cachix/cachix-action@v10 + with: + name: kip93 + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + extraPullNames: nix-community + skipPush: true + + - name: Print nixpkgs version + run: | + nix-instantiate --eval -E '"nixpkgs version: ${(import {}).lib.version}"' + + - name: Shellcheck shell.nix + id: shellcheck + working-directory: ./repo + run: | + ( + printf '#!/bin/bash\n' ; + nix-shell --pure shell.nix --run : >/dev/null ; + nix-instantiate shell.nix 2>/dev/null | xargs -i sed '1,5d' {} ; + ) | nix-shell -p shellcheck --run 'shellcheck -' + continue-on-error: true + + - name: QMK Format + id: qmk-format + working-directory: ./repo + run: | + nix-shell --run format + git diff --exit-code --name-only + continue-on-error: true + + - name: QMK Lint + id: qmk-lint + working-directory: ./repo + run: | + nix-shell --run lint + continue-on-error: true + + - name: Check shell.nix format + id: nixpkgs-fmt + working-directory: ./repo + run: | + nix-shell -p nixpkgs-fmt --run 'nixpkgs-fmt --check shell.nix' + continue-on-error: true + + - name: Lint shell.nix + id: nix-linter + working-directory: ./repo + run: | + nix-shell -p nix-linter --run ' \ + nix-linter -W no-AlphabeticalArgs \ + -W no-AlphabeticalBindings \ + -W BetaReduction \ + -W DIYInherit \ + -W EmptyInherit \ + -W EmptyLet \ + -W no-EmptyVariadicParamSet \ + -W FreeLetInFunc \ + -W LetInInheritRecset \ + -W no-ListLiteralConcat \ + -W NegateAtom \ + -W SequentialLet \ + -W SetLiteralUpdate \ + -W UnfortunateArgName \ + -W no-UnneededAntiquote \ + -W UnneededRec \ + -W UnusedArg \ + -W UnusedLetBind \ + -W UpdateEmptySet \ + -v shell.nix \ + ' + continue-on-error: true + + - name: Check shell.nix for vulnerabilities + id: vulnix + working-directory: ./repo + run: | + nix-shell -p vulnix --run 'vulnix -f shell.nix' + continue-on-error: true + + - name: Validate shell.nix logic + id: validate + working-directory: . + run: | + ( + mkdir -p ./tmp ; + cp ./repo/shell.nix ./tmp/shell.nix ; + sed -i -E 's|\bKEYBOARD\b\s*=\s*".+?"\s*;|KEYBOARD = "ergodox_ez";|' ./tmp/shell.nix ; + cd ./tmp ; + MANPAGER=cat nix-shell --run help ; + nix-shell --pure --run init ; + # nix-shell --pure --run setup ; # No root access, but not needed since we won't be flashing + nix-shell --pure --run format ; + nix-shell --pure --run lint ; + nix-shell --pure --run compile ; + # nix-shell --pure --run flash ; # Can't flash since there is no keyboard attached + nix-shell --pure --run clean ; + ) + continue-on-error: true + + - name: Check for failures + if: | + steps.shellcheck.outcome != 'success' || + steps.qmk-format.outcome != 'success' || + steps.qmk-lint.outcome != 'success' || + steps.nixpkgs-fmt.outcome != 'success' || + steps.nix-linter.outcome != 'success' || + steps.vulnix.outcome != 'success' || + steps.validate.outcome != 'success' + run: exit 1 + + - name: Push to cache + working-directory: ./repo + run: | + nix-shell --pure shell.nix --run : + nix-store -qR --include-outputs $(nix-instantiate shell.nix 2>/dev/null) | cachix push kip93 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5b79d8c..b8f158b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,7 +1,13 @@ name: Release on: - push: { branches: [ main, develop ] } + push: + branches: [ main, develop ] + paths: + - 'keymap/**' + - 'QMK' + - 'shell.nix' + - '.github/workflows/release.yml' workflow_dispatch: {} concurrency: @@ -22,12 +28,22 @@ jobs: uses: cachix/install-nix-action@v15 with: nix_path: nixpkgs=channel:nixos-unstable + + - name: Set up cache + uses: cachix/cachix-action@v10 + with: + name: kip93 + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + extraPullNames: nix-community + skipPush: true + - name: Print nixpkgs version run: | nix-instantiate --eval -E '"nixpkgs version: ${(import {}).lib.version}"' - name: Compile - run: nix-shell --run compile + run: | + nix-shell --pure --run compile - name: Create tag id: tag @@ -35,45 +51,54 @@ jobs: TAG="$(date '+v%y.%m.%d.%H%M%S')${{ github.ref != 'refs/heads/main' && '-RC' || '' }}" git tag "${TAG}" git push --tags + printf 'Tagged: %s -> %s.\n\n' "$(git rev-parse HEAD)" "${TAG}" printf '::set-output name=tag::%s\n' "${TAG}" - name: Create changelog run: | - git fetch --tags + printf 'Reference:\n' + printf '%s.\n\n' "${GITHUB_REF}" - printf 'Branch:\n' - printf '%s\n\n' "${GITHUB_REF_NAME}" printf 'Latest tags:\n' - git tag -l --sort=version:refname | tail -10 + git fetch --tags + git tag -l --sort=-version:refname | head -10 printf '\n' printf 'Latest full release tags:\n' - git tag -l --sort=version:refname | grep -P '^v\\d{2}\\.\\d{2}\\.\\d{2}\\.\\d{6}$' | tail -10 + git tag -l --sort=-version:refname | grep -P '^v\d{2}\.\d{2}\.\d{2}\.\d{6}$' | head -10 printf '\n' - printf '[Commits to %s since this release]' "${GITHUB_REF_NAME}" >>'.build/CHANGELOG.md' - printf '(%s/%s/compare/' "${GITHUB_SERVER_URL}" "${GITHUB_REPOSITORY}" >>'.build/CHANGELOG.md' - printf '%s...%s)' "${{ steps.tag.outputs.tag }}" "${GITHUB_REF_NAME}" >>'.build/CHANGELOG.md' - printf '\n\n' >>'.build/CHANGELOG.md' + printf 'Changelog:\n' + if [ "${GITHUB_REF_NAME}" = 'main' ] && [ "$(git tag -l | grep -P '^v\d{2}\.\d{2}\.\d{2}\.\d{6}$' | wc -l)" -ge 2 ] ; then + LAST_TAG="$(git tag -l --sort=-version:refname | grep -P '^v\d{2}\.\d{2}\.\d{2}\.\d{6}$' | sed -n '2{p;q;}')" + elif [ "$(git tag -l | wc -l)" -ge 2 ] ; then + LAST_TAG="$(git tag -l --sort=-version:refname | sed -n '2{p;q;}')" + else + LAST_TAG="$(git rev-list --max-parents=0 HEAD)" + fi + printf '%s...%s\n\n' "${{ steps.tag.outputs.tag }}" "${LAST_TAG}" printf '[Full changelog]' >>'.build/CHANGELOG.md' printf '(%s/%s/compare/' "${GITHUB_SERVER_URL}" "${GITHUB_REPOSITORY}" >>'.build/CHANGELOG.md' - if [ "${GITHUB_REF_NAME}" = 'main' ] && [ "$(git tag -l | grep -P '^v\\d{2}\\.\\d{2}\\.\\d{2}\\.\\d{6}$' | wc -l)" -ge 2 ] ; then - printf '%s...%s)' "$(git tag -l --sort=version:refname | grep -P '^v\\d{2}\\.\\d{2}\\.\\d{2}\\.\\d{6}$' | tail -2 | head -1)" "${{ steps.tag.outputs.tag }}" >>'.build/CHANGELOG.md' - - elif [ "$(git tag -l | wc -l)" -ge 2 ] ; then - printf '%s...%s)' "$(git tag -l --sort=version:refname | tail -2 | head -1)" "${{ steps.tag.outputs.tag }}" >>'.build/CHANGELOG.md' + printf '%s...%s)\n\n' "${LAST_TAG}" "${{ steps.tag.outputs.tag }}" >>'.build/CHANGELOG.md' - else - printf '%s...%s)' "$(git rev-list --max-parents=0 HEAD)" "${{ steps.tag.outputs.tag }}" >>'.build/CHANGELOG.md' - fi - printf '\n\n' >>'.build/CHANGELOG.md' + printf '[Commits to %s since this release]' "${GITHUB_REF_NAME}" >>'.build/CHANGELOG.md' + printf '(%s/%s/compare/' "${GITHUB_SERVER_URL}" "${GITHUB_REPOSITORY}" >>'.build/CHANGELOG.md' + printf '%s...%s)\n\n' "${{ steps.tag.outputs.tag }}" "${GITHUB_REF_NAME}" >>'.build/CHANGELOG.md' - name: Publish release uses: softprops/action-gh-release@v1 with: files: | - .build/firmware.hex + ./.build/firmware.hex + fail_on_unmatched_files: true + name: ${{ steps.tag.outputs.tag }} tag_name: ${{ steps.tag.outputs.tag }} body_path: .build/CHANGELOG.md prerelease: ${{ github.ref != 'refs/heads/main' }} + + - name: Push to cache + run: | + nix-shell --pure shell.nix --run : + nix-shell --pure QMK/shell.nix --run : + nix-store -qR --include-outputs $(nix-instantiate shell.nix QMK/shell.nix 2>/dev/null) | cachix push kip93 diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index bc047dd..c8bc2c1 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -1,7 +1,7 @@ name: Update QMK on: - schedule: [ { cron: "42 */4 * * *" } ] + schedule: [ { cron: "42 * * * *" } ] # Every hour, past 42 minutes to avoid peak times. workflow_dispatch: {} concurrency: @@ -14,15 +14,46 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v3 - with: { ref: "develop" } + with: + ref: develop + submodules: recursive - name: Update run: | - git submodule update --init --remote QMK + nix-shell --pure --run update + + - name: Set up Nix + uses: cachix/install-nix-action@v15 + with: + nix_path: nixpkgs=channel:nixos-unstable + extra_nix_config: | + experimental-features = nix-command + + - name: Set up cache + uses: cachix/cachix-action@v10 + with: + name: kip93 + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + extraPullNames: nix-community + skipPush: true + + - name: Print nixpkgs version + run: | + nix-instantiate --eval -E '"nixpkgs version: ${(import {}).lib.version}"' + + - name: Validate + run: | + nix-shell --pure --run compile - name: Commit run: | git config --global user.name 'github-actions[bot]' git config --global user.email 'github-actions[bot]@users.noreply.github.com' - git remote set-url origin "https://x-access-token:${{ github.token }}@github.com/${{ github.repository }}" + git remote set-url origin \ + "https://x-access-token:${{ github.token }}@github.com/${{ github.repository }}" git commit -am "Update QMK - [GitHub Action]" && git push || true + + - name: Push to cache + run: | + nix-shell --pure QMK/shell.nix --run : + nix-store -qR --include-outputs $(nix-instantiate QMK/shell.nix 2>/dev/null) | cachix push kip93 diff --git a/.vscode/ltex.dictionary.en-GB.txt b/.vscode/ltex.dictionary.en-GB.txt index 88cd8d2..a6ac5c1 100644 --- a/.vscode/ltex.dictionary.en-GB.txt +++ b/.vscode/ltex.dictionary.en-GB.txt @@ -1,7 +1,13 @@ +cachix Corne +github keycaps Keyhive keymap keymaps MCUs +nix +nixos +nixpkgs ortholinear +QMK diff --git a/QMK b/QMK index 29ab430..84c9d6f 160000 --- a/QMK +++ b/QMK @@ -1 +1 @@ -Subproject commit 29ab430f1f302bc64ad1549147f24235ba230a9c +Subproject commit 84c9d6ff39b92892c385c320f3d36145d71c9095 diff --git a/keymap/config.h b/keymap/config.h index 801b369..df40ce4 100644 --- a/keymap/config.h +++ b/keymap/config.h @@ -15,38 +15,52 @@ * . * \***************************************************************************************************************/ -# pragma once +#pragma once - -// ------------------------------------------------ Handiness ------------------------------------------------ // +/////////////////////////////////////////////////// Handiness /////////////////////////////////////////////////// // https://docs.qmk.fm/#/config_options?id=setting-handedness -# define MASTER_LEFT +#define MASTER_LEFT -// --------------------------------------------------- RGB --------------------------------------------------- // +////////////////////////////////////////////////////// RGB ////////////////////////////////////////////////////// // https://docs.qmk.fm/#/feature_rgb_matrix // https://github.com/qmk/qmk_firmware/tree/master/quantum/rgb_matrix_animations/ -# ifdef RGB_MATRIX_ENABLE +#ifdef RGB_MATRIX_ENABLE + +////////////// +// Settings // +////////////// + +// Disable lighting when suspended. +# define RGB_DISABLE_WHEN_USB_SUSPENDED true +// 24 FPS animations. +# define RGB_MATRIX_LED_FLUSH_LIMIT (1000 / 24) +// Limit LED effects' overhead. +# define RGB_MATRIX_LED_PROCESS_LIMIT (DRIVER_LED_TOTAL / 9) +// Max brightness (uint8_t, best if <= 150). +# define RGB_MATRIX_MAXIMUM_BRIGHTNESS 140 +// Disable default RGB controls. +# define RGB_MATRIX_DISABLE_KEYCODES + +///////////// +// Effects // +///////////// -// Global settings. -# define RGB_DISABLE_WHEN_USB_SUSPENDED true // Disable lighting when suspended. -# define RGB_MATRIX_LED_FLUSH_LIMIT (1000 / 24) // 24 FPS animations. -# define RGB_MATRIX_LED_PROCESS_LIMIT (DRIVER_LED_TOTAL / 9) // Limit LED effects' overhead. -# define RGB_MATRIX_MAXIMUM_BRIGHTNESS 140 // Max brightness (uint8_t, best if <= 150). -# define RGB_MATRIX_DISABLE_KEYCODES // Disable default RGB controls. +// React to keypresses. +# define RGB_MATRIX_KEYPRESSES +# define RGB_MATRIX_KEYRELEASES -// RGB effects. -# define RGB_MATRIX_KEYPRESSES -# define RGB_MATRIX_KEYRELEASES +// Light up pressed key momentarily. +# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE -# define ENABLE_RGB_MATRIX_SOLID_COLOR -# define ENABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE +// Simple solid colour lighting. +# define ENABLE_RGB_MATRIX_SOLID_COLOR -# endif // RGB_MATRIX_ENABLE +#endif // RGB_MATRIX_ENABLE -// -------------------------------------------------- Others ------------------------------------------------- // +//////////////////////////////////////////////////// Others ///////////////////////////////////////////////////// -# define TAPPING_TERM 150 +#define TAPPING_TERM 150 -# define PERMISSIVE_HOLD +#define PERMISSIVE_HOLD diff --git a/keymap/keymap.c b/keymap/keymap.c index a193c96..00d78b8 100644 --- a/keymap/keymap.c +++ b/keymap/keymap.c @@ -18,13 +18,13 @@ // https://docs.qmk.fm/#/keymap // https://docs.qmk.fm/#/keycodes -# include QMK_KEYBOARD_H - -# include "layers.h" -# include "macros.h" -# include "rgb_macros.h" +#include QMK_KEYBOARD_H +#include "layers.h" +#include "macros.h" +#include "rgb_macros.h" +// clang-format off const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { ///////////////////////////////////////////////////// Typing //////////////////////////////////////////////////// @@ -32,15 +32,15 @@ const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { // ------------------------------------------------- 0: Text ------------------------------------------------- // [TYPING_0] = LAYOUT_split_3x6_3( -// +--------+--------+--------+--------+--------+--------+ +--------+--------+--------+--------+--------+--------+ - KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSDL, -// +--------+--------+--------+--------+--------+--------+ +--------+--------+--------+--------+--------+--------+ - KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, -// +--------+--------+--------+--------+--------+--------+ +--------+--------+--------+--------+--------+--------+ - KC_APP, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_BSLS, -// +--------+--------+--------+--------+--------+--------+ +--------+--------+--------+--------+--------+--------+ - KC_LSFT, LT(T1,KC_SPC), KC_LALT, KC_LGUI, LT(T2,KC_ENT), KC_LCTL -// +--------+--------------+--------+ +--------+--------------+--------+ +// +--------+--------+--------+--------+--------+--------++--------+--------+--------+--------+--------+--------+ + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSDL, +// +--------+--------+--------+--------+--------+--------++--------+--------+--------+--------+--------+--------+ + KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, +// +--------+--------+--------+--------+--------+--------++--------+--------+--------+--------+--------+--------+ + KC_APP, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_BSLS, +// +--------+--------+--------+--------+--------+--------++--------+--------+--------+--------+--------+--------+ + KC_LSFT, LT(T1,KC_SPC), KC_LALT, KC_LGUI, LT(T2,KC_ENT), KC_LCTL +// +--------+--------------+--------++--------+--------------+--------+ ), // ----------------------------------------------- 1: Others #1 ---------------------------------------------- // @@ -48,15 +48,15 @@ const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { // - - - - - - - - - - - - - - - Functions - - - - - - - - - - - - - - - Numpad - - - - - - - - - - - - - - - // [TYPING_1] = LAYOUT_split_3x6_3( -// +--------+--------+--------+--------+--------+--------+ +--------+--------+--------+--------+--------+--------+ - KC_F1, KC_F4, KC_F7, KC_F10, KC_PSCR, KC_INS, KC_NLCK, KC_P7, KC_P8, KC_P9, KC_PMNS, KC_PSLS, -// +--------+--------+--------+--------+--------+--------+ +--------+--------+--------+--------+--------+--------+ - KC_F2, KC_F5, KC_F8, KC_F11, KC_HOME, KC_PGUP, KC_PDOT, KC_P4, KC_P5, KC_P6, KC_PPLS, KC_PAST, -// +--------+--------+--------+--------+--------+--------+ +--------+--------+--------+--------+--------+--------+ - KC_F3, KC_F6, KC_F9, KC_F12, KC_END, KC_PGDN, KC_P0, KC_P1, KC_P2, KC_P3, KC_PENT, KC_BSES, -// +--------+--------+--------+--------+--------+--------+ +--------+--------+--------+--------+--------+--------+ - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, TO(G0), KC_TRNS -// +--------+--------+--------+ +--------+--------+--------+ +// +--------+--------+--------+--------+--------+--------++--------+--------+--------+--------+--------+--------+ + KC_F1, KC_F4, KC_F7, KC_F10, KC_PSCR, KC_INS, KC_NLCK, KC_P7, KC_P8, KC_P9, KC_PMNS, KC_PSLS, +// +--------+--------+--------+--------+--------+--------++--------+--------+--------+--------+--------+--------+ + KC_F2, KC_F5, KC_F8, KC_F11, KC_HOME, KC_PGUP, KC_PDOT, KC_P4, KC_P5, KC_P6, KC_PPLS, KC_PAST, +// +--------+--------+--------+--------+--------+--------++--------+--------+--------+--------+--------+--------+ + KC_F3, KC_F6, KC_F9, KC_F12, KC_END, KC_PGDN, KC_P0, KC_P1, KC_P2, KC_P3, KC_PENT, KC_BSES, +// +--------+--------+--------+--------+--------+--------++--------+--------+--------+--------+--------+--------+ + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, TO(G0), KC_TRNS +// +--------+--------+--------++--------+--------+--------+ ), // ----------------------------------------------- 2: Others #2 ---------------------------------------------- // @@ -64,15 +64,15 @@ const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { // - - - - - - - - - - - - - Numbers & symbols - - - - - - - - - - - - - - Specials - - - - - - - - - - - - - // [TYPING_2] = LAYOUT_split_3x6_3( -// +--------+--------+--------+--------+--------+--------+ +--------+--------+--------+--------+--------+--------+ - KC_1, KC_2, KC_3, KC_4, KC_5, KC_GRV, KC_MPRV, KC_VOLD, KC_VOLU, KC_MNXT, KC_MSTP, KC_CAPS, -// +--------+--------+--------+--------+--------+--------+ +--------+--------+--------+--------+--------+--------+ - KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_MPLY, KC_BRIU, -// +--------+--------+--------+--------+--------+--------+ +--------+--------+--------+--------+--------+--------+ - KC_CUT, KC_COPY, KC_PSTE, KC_LBRC, KC_RBRC, KC_EQL, KC_RGBM, KC_RGBC, KC_UNDO, KC_AGIN, KC_MUTE, KC_BRID, -// +--------+--------+--------+--------+--------+--------+ +--------+--------+--------+--------+--------+--------+ - KC_TRNS, TO(G0), KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS -// +--------+--------+--------+ +--------+--------+--------+ +// +--------+--------+--------+--------+--------+--------++--------+--------+--------+--------+--------+--------+ + KC_1, KC_2, KC_3, KC_4, KC_5, KC_GRV, KC_MPRV, KC_VOLD, KC_VOLU, KC_MNXT, KC_MSTP, KC_CAPS, +// +--------+--------+--------+--------+--------+--------++--------+--------+--------+--------+--------+--------+ + KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_MPLY, KC_BRIU, +// +--------+--------+--------+--------+--------+--------++--------+--------+--------+--------+--------+--------+ + KC_CUT, KC_COPY, KC_PSTE, KC_LBRC, KC_RBRC, KC_EQL, KC_RGBM, KC_RGBC, KC_UNDO, KC_AGIN, KC_MUTE, KC_BRID, +// +--------+--------+--------+--------+--------+--------++--------+--------+--------+--------+--------+--------+ + KC_TRNS, TO(G0), KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS +// +--------+--------+--------++--------+--------+--------+ ), ///////////////////////////////////////////////////// Gaming //////////////////////////////////////////////////// @@ -82,15 +82,15 @@ const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { // - - - - - - - - - - WASD & other basics - - - - - - - - - - - - Extended #1 (optional) - - - - - - - - - - // [GAMING_0] = LAYOUT_split_3x6_3( -// +--------+--------+--------+--------+--------+--------+ +--------+--------+--------+--------+--------+--------+ - KC_ESC, KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_1, KC_2, KC_3, KC_4, KC_5, KC_PGUP, -// +--------+--------+--------+--------+--------+--------+ +--------+--------+--------+--------+--------+--------+ - KC_J, KC_LSFT, KC_A, KC_S, KC_D, KC_F, KC_6, KC_7, KC_8, KC_9, KC_0, KC_PGDN, -// +--------+--------+--------+--------+--------+--------+ +--------+--------+--------+--------+--------+--------+ - KC_M, KC_LCTL, KC_Z, KC_X, KC_C, KC_V, KC_MINS, KC_COMM, KC_DOT, KC_SCLN, KC_SLSH, KC_BSLS, -// +--------+--------+--------+--------+--------+--------+ +--------+--------+--------+--------+--------+--------+ - MO(G1), KC_LALT, KC_SPC, KC_ENT, KC_RALT, KC_RSFT -// +--------+--------+--------+ +--------+--------+--------+ +// +--------+--------+--------+--------+--------+--------++--------+--------+--------+--------+--------+--------+ + KC_ESC, KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_1, KC_2, KC_3, KC_4, KC_5, KC_PGUP, +// +--------+--------+--------+--------+--------+--------++--------+--------+--------+--------+--------+--------+ + KC_J, KC_LSFT, KC_A, KC_S, KC_D, KC_F, KC_6, KC_7, KC_8, KC_9, KC_0, KC_PGDN, +// +--------+--------+--------+--------+--------+--------++--------+--------+--------+--------+--------+--------+ + KC_M, KC_LCTL, KC_Z, KC_X, KC_C, KC_V, KC_MINS, KC_COMM, KC_DOT, KC_SCLN, KC_SLSH, KC_BSLS, +// +--------+--------+--------+--------+--------+--------++--------+--------+--------+--------+--------+--------+ + MO(G1), KC_LALT, KC_SPC, KC_ENT, KC_RALT, KC_RSFT +// +--------+--------+--------++--------+--------+--------+ ), // ------------------------------------------------ 1: Extras ------------------------------------------------ // @@ -98,22 +98,23 @@ const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { // - - - - - - - - - - - More keybindings - - - - - - - - - - - Extended #2 (optional) - - - - - - - - - - - // [GAMING_1] = LAYOUT_split_3x6_3( -// +--------+--------+--------+--------+--------+--------+ +--------+--------+--------+--------+--------+--------+ - KC_TRNS, KC_TRNS, KC_L, KC_TRNS, KC_T, KC_O, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, -// +--------+--------+--------+--------+--------+--------+ +--------+--------+--------+--------+--------+--------+ - KC_P, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_G, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_HOME, KC_END, -// +--------+--------+--------+--------+--------+--------+ +--------+--------+--------+--------+--------+--------+ - KC_I, KC_TRNS, KC_B, KC_N, KC_H, KC_K, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, -// +--------+--------+--------+--------+--------+--------+ +--------+--------+--------+--------+--------+--------+ - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, TO(T0) -// +--------+--------+--------+ +--------+--------+--------+ +// +--------+--------+--------+--------+--------+--------++--------+--------+--------+--------+--------+--------+ + KC_TRNS, KC_TRNS, KC_L, KC_TRNS, KC_T, KC_O, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, +// +--------+--------+--------+--------+--------+--------++--------+--------+--------+--------+--------+--------+ + KC_P, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_G, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, KC_HOME, KC_END, +// +--------+--------+--------+--------+--------+--------++--------+--------+--------+--------+--------+--------+ + KC_I, KC_TRNS, KC_B, KC_N, KC_H, KC_K, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, +// +--------+--------+--------+--------+--------+--------++--------+--------+--------+--------+--------+--------+ + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, TO(T0) +// +--------+--------+--------++--------+--------+--------+ ), }; +// clang-format on -void keyboard_post_init_user (void) { - rgblight_enable_noeeprom(); // Enable LEDs. - rgb_next_colour(); // Set colour - rgb_next_mode(); // Set effect. +void keyboard_post_init_user(void) { + rgblight_enable_noeeprom(); // Enable LEDs. + rgb_next_colour(); // Set colour + rgb_next_mode(); // Set effect. - rgblight_set_speed_noeeprom(0x40); // Set speed (~1.5s). + rgblight_set_speed_noeeprom(0x40); // Set speed (~1.5s). } diff --git a/keymap/layers.h b/keymap/layers.h index 77bcbea..b645bc3 100644 --- a/keymap/layers.h +++ b/keymap/layers.h @@ -15,10 +15,10 @@ * . * \***************************************************************************************************************/ -# pragma once +#pragma once +////////////////////////////////////////////// Layer declarations /////////////////////////////////////////////// -// Layer declarations. enum { // MODE 1: Typing TYPING_0 = 0, @@ -30,7 +30,9 @@ enum { GAMING_1, }; -// Aliases. +//////////////////////////////////////////////////// Aliases //////////////////////////////////////////////////// +// Easier to put in the keymap + enum { T0 = TYPING_0, T1 = TYPING_1, diff --git a/keymap/macros.h b/keymap/macros.h index b9437f2..e1f5421 100644 --- a/keymap/macros.h +++ b/keymap/macros.h @@ -17,14 +17,13 @@ // https://docs.qmk.fm/#/feature_macros -# pragma once +#pragma once -# include QMK_KEYBOARD_H +#include QMK_KEYBOARD_H +#include "rgb_macros.h" -# include "rgb_macros.h" +////////////////////////////////////////////// Macro declarations /////////////////////////////////////////////// - -// Macro declarations. enum { BACKSPACE_DELETE = SAFE_RANGE, BACKSPACE_ESCAPE, @@ -32,7 +31,9 @@ enum { RGB_COLOUR, }; -// Aliases. +//////////////////////////////////////////////////// Aliases //////////////////////////////////////////////////// +// Easier to put in the keymap + enum { KC_BSDL = BACKSPACE_DELETE, KC_BSES = BACKSPACE_ESCAPE, @@ -40,10 +41,11 @@ enum { KC_RGBC = RGB_COLOUR, }; +/////////////////////////////////////////////// Macro definitions /////////////////////////////////////////////// void custom_modifier(keyrecord_t *record, uint8_t mask, uint16_t kc1, uint16_t kc2) { static bool modifiers = false; - if (record -> event.pressed) { + if (record->event.pressed) { modifiers = get_mods() & mask; register_code(modifiers ? kc2 : kc1); @@ -52,7 +54,6 @@ void custom_modifier(keyrecord_t *record, uint8_t mask, uint16_t kc1, uint16_t k } } -// Macro definitions. bool process_record_user(uint16_t keycode, keyrecord_t *record) { switch (keycode) { case BACKSPACE_DELETE: { @@ -68,7 +69,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { } case RGB_MODE: { - if (record -> event.pressed) { + if (record->event.pressed) { rgb_next_mode(); } @@ -76,7 +77,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { } case RGB_COLOUR: { - if (record -> event.pressed) { + if (record->event.pressed) { rgb_next_colour(); } diff --git a/keymap/rgb_macros.h b/keymap/rgb_macros.h index bba5235..28752c2 100644 --- a/keymap/rgb_macros.h +++ b/keymap/rgb_macros.h @@ -18,31 +18,30 @@ // https://docs.qmk.fm/#/feature_macros // https://docs.qmk.fm/#/feature_rgb_matrix -# pragma once +#pragma once -# include QMK_KEYBOARD_H +#include QMK_KEYBOARD_H - -void rgb_next_colour (void) { - static uint8_t colour = 0; +void rgb_next_colour(void) { + static uint8_t colour = 0; static const uint8_t hues[] = { - 0x80, // Cyan. - 0xEB, // Magenta. - 0x03, // Orange. + 0x80, // Cyan. + 0xEB, // Magenta. + 0x03, // Orange. 0x00, // White. }; - uint8_t hue = hues[colour]; + uint8_t hue = hues[colour]; uint8_t saturation = colour < sizeof(hues) - 1 ? 0xFF : 0x00; - uint8_t value = 0xFF; + uint8_t value = 0xFF; rgblight_sethsv_noeeprom(hue, saturation, value); colour = (colour + 1) % sizeof(hues); } -void rgb_next_mode (void) { - static uint8_t mode = 0; +void rgb_next_mode(void) { + static uint8_t mode = 0; static const uint8_t modes[] = { RGB_MATRIX_SOLID_REACTIVE_SIMPLE, RGB_MATRIX_SOLID_COLOR, diff --git a/keymap/rgb_matrix_user.inc b/keymap/rgb_matrix_user.inc index 26bc22c..e1c0d7f 100644 --- a/keymap/rgb_matrix_user.inc +++ b/keymap/rgb_matrix_user.inc @@ -17,15 +17,14 @@ // https://docs.qmk.fm/#/feature_rgb_matrix?id=custom-rgb-matrix-effects - RGB_MATRIX_EFFECT(OFF) -# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS - static bool OFF(effect_params_t *params) { - RGB_MATRIX_USE_LIMITS(led_min, led_max); - for (uint8_t i = led_min; i < led_max; ++i) { - rgb_matrix_set_color(i, 0x00, 0x00, 0x00); - } - - return led_max < DRIVER_LED_TOTAL; +#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS +static bool OFF(effect_params_t *params) { + RGB_MATRIX_USE_LIMITS(led_min, led_max); + for (uint8_t i = led_min; i < led_max; ++i) { + rgb_matrix_set_color(i, 0x00, 0x00, 0x00); } -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS + + return led_max < DRIVER_LED_TOTAL; +} +#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS diff --git a/shell.nix b/shell.nix index a8b7228..51519e4 100644 --- a/shell.nix +++ b/shell.nix @@ -15,7 +15,8 @@ # . # ################################################################################################################# -{ pkgs ? import {} }: let +{ pkgs ? import { }, ... }: +let ################# # Configuration # ################# @@ -27,12 +28,16 @@ # Number of threads to be used when compiling. PARALLEL = 16; -in pkgs.mkShell { +in +pkgs.mkShell { nativeBuildInputs = with pkgs; [ - cacert git nix openssh + cacert + git + nix + openssh ]; - shellHook = '' + shellHook = with pkgs; '' # Bash configs ################################################################# shopt -s histappend shopt -s cmdhist @@ -45,11 +50,11 @@ in pkgs.mkShell { HISTFILESIZE=2000 # Extra bling for some commands ################################################ - eval "$(SHELL='${pkgs.bashInteractive}/bin/bash' '${pkgs.lesspipe}/bin/lesspipe.sh')" - eval "$('${pkgs.coreutils}/bin/dircolors' -b)" + eval "$(SHELL='${bashInteractive}/bin/bash' '${lesspipe}/bin/lesspipe.sh')" + eval "$('${coreutils}/bin/dircolors' -b)" # Globals ###################################################################### - _ROOT_DIR="$('${pkgs.coreutils}/bin/pwd' -P)" + _ROOT_DIR='${toString ./.}' # Create a dynamic CLI prompt ################################################## _compute_prompt() { @@ -57,172 +62,184 @@ in pkgs.mkShell { local XC=$? local XC_colour="$( if [ "''${XC}" -eq 0 ] ; then - '${pkgs.coreutils}/bin/printf' 10 ; + '${coreutils}/bin/printf' 10 ; elif [ "''${XC}" -lt 128 ] ; then - '${pkgs.coreutils}/bin/printf' 9 ; + '${coreutils}/bin/printf' 9 ; else - '${pkgs.coreutils}/bin/printf' 11 ; + '${coreutils}/bin/printf' 11 ; fi ; )" - local XC_PS1="\[\033[38;5;''${XC_colour}m\]$('${pkgs.coreutils}/bin/printf' '0x%02X' "''${XC}")\[\033[1m\]\[$('${pkgs.ncurses}/bin/tput' sgr0)\]" + local XC_PS1="\[\033[38;5;''${XC_colour}m\]$('${coreutils}/bin/printf' '0x%02X' "''${XC}")\[\033[1m\]\[$('${ncurses}/bin/tput' sgr0)\]" # Compute the path relative to the root of the project (or absolute path if outside of said folder). local path="$( - '${pkgs.coreutils}/bin/realpath' -m --relative-to="''${_ROOT_DIR}" "$('${pkgs.coreutils}/bin/pwd')" + '${coreutils}/bin/realpath' -m --relative-to="''${_ROOT_DIR}" "$('${coreutils}/bin/pwd')" )/" - [[ "''${path}" =~ ^\.\..+$ ]] && path="$('${pkgs.coreutils}/bin/pwd')" + [[ "''${path}" =~ ^\.\..+$ ]] && path="$('${coreutils}/bin/pwd')" [[ "''${path}" =~ ^/.+$|^\./$ ]] || path="./''${path}" - local path_PS1="\[\033[1;38;5;12m\]''${path}\[$('${pkgs.ncurses}/bin/tput' sgr0)\]" + local path_PS1="\[\033[1;38;5;12m\]''${path}\[$('${ncurses}/bin/tput' sgr0)\]" # Check the branch of the repo and its status. local is_git="$( - '${pkgs.git}/bin/git' -C "''${_ROOT_DIR}" rev-parse --git-dir >/dev/null 2>&1 && \ - [[ "$('${pkgs.git}/bin/git' -C "''${_ROOT_DIR}" rev-parse --show-toplevel)" -ef "''${_ROOT_DIR}" ]] && \ - printf true ; + '${git}/bin/git' -C "''${_ROOT_DIR}" rev-parse --git-dir >/dev/null 2>&1 && + [ "$('${git}/bin/git' -C "''${_ROOT_DIR}" rev-parse --show-toplevel)" -ef "''${_ROOT_DIR}" ] && + '${coreutils}/bin/printf' true ; )" local git_status="$( - [[ ! -z "''${is_git}" ]] && \ - '${pkgs.git}/bin/git' -C "''${_ROOT_DIR}" status --porcelain ; + [ ! -z "''${is_git}" ] && + '${git}/bin/git' -C "''${_ROOT_DIR}" status --porcelain ; )" local ref="$( if [ ! -z "''${is_git}" ] ; then - '${pkgs.git}/bin/git' -C "''${_ROOT_DIR}" rev-parse --abbrev-ref HEAD 2>/dev/null || true ; + '${git}/bin/git' -C "''${_ROOT_DIR}" rev-parse --abbrev-ref HEAD 2>/dev/null || true ; else - '${pkgs.coreutils}/bin/printf' '' ; + '${coreutils}/bin/printf' '' ; fi ; )" - [[ "''${ref}" = "HEAD" ]] && ref="$( - '${pkgs.git}/bin/git' -C "''${_ROOT_DIR}" rev-parse --short HEAD 2>/dev/null || \ - '${pkgs.git}/bin/git' -C "''${_ROOT_DIR}" branch --show-current ; + [ "''${ref}" = "HEAD" ] && ref="$( + '${git}/bin/git' -C "''${_ROOT_DIR}" rev-parse --short HEAD 2>/dev/null || + '${git}/bin/git' -C "''${_ROOT_DIR}" branch --show-current ; )" local ref_colour="$( if [ -z "''${is_git}" ] ; then - '${pkgs.coreutils}/bin/printf' 9 ; + '${coreutils}/bin/printf' 9 ; elif [ \ "$( - '${pkgs.coreutils}/bin/printf' '%s\n' "''${git_status}" | \ - '${pkgs.gnused}/bin/sed' '/^\s*$/d' | \ - '${pkgs.coreutils}/bin/wc' -l ; + '${coreutils}/bin/printf' '%s\n' "''${git_status}" | + '${gnused}/bin/sed' '/^\s*$/d' | + '${coreutils}/bin/wc' -l ; )" -eq 0 \ ] ; then - '${pkgs.coreutils}/bin/printf' 10 ; + '${coreutils}/bin/printf' 10 ; elif - '${pkgs.coreutils}/bin/printf' '%s\n' "''${git_status}" | \ - '${pkgs.gnugrep}/bin/grep' -q '^.\S' ; then - '${pkgs.coreutils}/bin/printf' 9 ; + '${coreutils}/bin/printf' '%s\n' "''${git_status}" | + '${gnugrep}/bin/grep' -q '^.\S' ; then + '${coreutils}/bin/printf' 9 ; else - '${pkgs.coreutils}/bin/printf' 11 ; + '${coreutils}/bin/printf' 11 ; fi ; )" - local ref_PS1="\[\033[1;38;5;''${ref_colour}m\]$ref\[$('${pkgs.ncurses}/bin/tput' sgr0)\]" + local ref_PS1="\[\033[1;38;5;''${ref_colour}m\]$ref\[$('${ncurses}/bin/tput' sgr0)\]" # Nix shell hint. - local nix_PS1='\[\033[1;38;5;13m\]NIX+QMK\[$('${pkgs.ncurses}/bin/tput' sgr0)\]' + local nix_PS1='\[\033[1;38;5;13m\]NIX+QMK\[$('${ncurses}/bin/tput' sgr0)\]' # Colour CLI prompt. - PS1="\[$('${pkgs.ncurses}/bin/tput' sgr0)\][ ''${nix_PS1} @ ''${ref_PS1} : ''${path_PS1} ] ''${XC_PS1} > \[$('${pkgs.ncurses}/bin/tput' sgr0)\]" + PS1="\[$('${ncurses}/bin/tput' sgr0)\][ ''${nix_PS1} @ ''${ref_PS1} : ''${path_PS1} ] ''${XC_PS1} > \[$('${ncurses}/bin/tput' sgr0)\]" return "''${XC}" # Restore the original exit code } PROMPT_COMMAND=_compute_prompt # Aliases ###################################################################### - alias ls="'${pkgs.coreutils}/bin/ls' --color=auto" - alias ll="'${pkgs.coreutils}/bin/ls' --color=auto -lAh" + alias ls="'${coreutils}/bin/ls' --color=auto" + alias ll="'${coreutils}/bin/ls' --color=auto -lAh" # Commands ##################################################################### - setup() { + init() { local XC=0 ( - '${pkgs.git}/bin/git' -C "''${_ROOT_DIR}" rev-parse --git-dir >/dev/null 2>&1 && \ - [[ "$('${pkgs.git}/bin/git' -C "''${_ROOT_DIR}" rev-parse --show-toplevel)" -ef "''${_ROOT_DIR}" ]] ; + '${git}/bin/git' -C "''${_ROOT_DIR}" rev-parse --git-dir >/dev/null 2>&1 && \ + [ "$('${git}/bin/git' -C "''${_ROOT_DIR}" rev-parse --show-toplevel)" -ef "''${_ROOT_DIR}" ] ; ) || ( - '${pkgs.coreutils}/bin/printf' \ + '${coreutils}/bin/printf' \ '# \033[3mInitialise repo\033[0m ------------------------------------------------------------------------------------- #\n' ; ( - '${pkgs.git}/bin/git' -C "''${_ROOT_DIR}" init -b main + '${git}/bin/git' -C "''${_ROOT_DIR}" init -b main ) || XC="$(( "''${XC}" + 0x01 ))" ; - '${pkgs.coreutils}/bin/printf' '\n' ; + '${coreutils}/bin/printf' '\n' ; ) - [[ -d "''${_ROOT_DIR}/QMK/" ]] && ( - '${pkgs.coreutils}/bin/printf' \ + [ -d "''${_ROOT_DIR}/QMK/" ] && ( + '${coreutils}/bin/printf' \ '# \033[3mClean up submodule\033[0m ---------------------------------------------------------------------------------- #\n' ; ( - '${pkgs.coreutils}/bin/rm' -rf -- "''${_ROOT_DIR}/QMK/" && \ - '${pkgs.coreutils}/bin/printf' "Submodule path 'QMK': deleted\n" ; + '${coreutils}/bin/rm' -rf -- "''${_ROOT_DIR}/QMK/" && + '${coreutils}/bin/printf' "Submodule path 'QMK': deleted\n" ; ) || XC="$(( "''${XC}" + 0x02 ))" ; - '${pkgs.coreutils}/bin/printf' '\n' ; + '${coreutils}/bin/printf' '\n' ; ) ( - '${pkgs.git}/bin/git' -C "''${_ROOT_DIR}" config --file .gitmodules --get-regexp path | \ - '${pkgs.gawk}/bin/awk' '{ print $2 }' | \ - grep -q '^QMK$' ; + '${git}/bin/git' -C "''${_ROOT_DIR}" config --file .gitmodules --get-regexp path | + '${gawk}/bin/awk' '{ print $2 }' | + '${gnugrep}/bin/grep' -q '^QMK$' ; ) || ( - '${pkgs.coreutils}/bin/printf' \ + '${coreutils}/bin/printf' \ '# \033[3mAdd QMK submodule\033[0m ----------------------------------------------------------------------------------- #\n' ; ( - '${pkgs.git}/bin/git' -C "''${_ROOT_DIR}" submodule add --branch master -- 'https://github.com/qmk/qmk_firmware/' QMK ; + '${git}/bin/git' -C "''${_ROOT_DIR}" submodule add --branch master -- 'https://github.com/qmk/qmk_firmware/' QMK ; ) || XC="$(( "''${XC}" + 0x04 ))" ; - '${pkgs.coreutils}/bin/printf' '\n' ; + '${coreutils}/bin/printf' '\n' ; ) - [[ "''${XC}" -ne 0 ]] || ( - '${pkgs.coreutils}/bin/printf' \ + if [ "''${XC}" -eq 0 ] ; then + '${coreutils}/bin/printf' \ '# \033[3mInit submodule\033[0m -------------------------------------------------------------------------------------- #\n' ; ( - '${pkgs.git}/bin/git' -C "''${_ROOT_DIR}" submodule update --init --recursive --progress ; + '${git}/bin/git' -C "''${_ROOT_DIR}" submodule update --init --recursive --progress ; ) || XC="$(( "''${XC}" + 0x08 ))" ; - '${pkgs.coreutils}/bin/printf' '\n' ; - ) + '${coreutils}/bin/printf' '\n' ; + fi - [[ "''${XC}" -ne 0 ]] || ( - '${pkgs.coreutils}/bin/printf' \ - '# \033[3mSet up udev rules\033[0m ----------------------------------------------------------------------------------- #\n' ; - ( - '${pkgs.coreutils}/bin/printf' 'Set up /etc/udev/rules.d/\n' && \ - su -c " - '${pkgs.coreutils}/bin/mkdir' -p '/etc/udev/rules.d/' && - '${pkgs.coreutils}/bin/cp' -rf \"''${_ROOT_DIR}/QMK/util/udev/\"* '/etc/udev/rules.d/' - " && '${pkgs.coreutils}/bin/printf' '\n/etc/udev/rules.d/ set up successfully\n' ; - ) || XC="$(( "''${XC}" + 0x10 ))" ; - '${pkgs.coreutils}/bin/printf' '\n' ; - ) + '${coreutils}/bin/printf' \ + '# \033[3mClean up workspace\033[0m ---------------------------------------------------------------------------------- #\n' ; + ( + '${coreutils}/bin/rm' -rf -- "''${_ROOT_DIR}/keymap/" ; + ) || XC="$(( "''${XC}" + 0x10 ))" ; + '${coreutils}/bin/printf' '\n' ; - '${pkgs.coreutils}/bin/printf' \ - '# \033[3mResize /run/user/$UID\033[0m ------------------------------------------------------------------------------- #\n' ; + '${coreutils}/bin/printf' \ + '# \033[3mCopy default keymap\033[0m --------------------------------------------------------------------------------- #\n' ; ( - '${pkgs.coreutils}/bin/printf' 'Set up /etc/udev/rules.d/\n' && \ - su -c " - '${pkgs.coreutils}/bin/mkdir' -p '/etc/systemd/logind.conf.d/' && - '${pkgs.coreutils}/bin/printf' '[Login]\nRuntimeDirectorySize=99%%\n' >'/etc/systemd/logind.conf.d/runtime_directory_size.conf' - " && '${pkgs.coreutils}/bin/printf' '\n/run/user/$UID resized successfully\n' ; + '${coreutils}/bin/cp' -rf -- "''${_ROOT_DIR}/QMK/keyboards/${KEYBOARD}/keymaps/default" "''${_ROOT_DIR}/keymap" ; ) || XC="$(( "''${XC}" + 0x20 ))" ; - '${pkgs.coreutils}/bin/printf' '\n' ; - - '${pkgs.coreutils}/bin/printf' '\033[3mSet up complete.\nPlease reboot your system to ensure that changes take effect.\033[0m\n' + '${coreutils}/bin/printf' '\n' ; return "''${XC}" } - init() { + setup() { local XC=0 - '${pkgs.coreutils}/bin/printf' \ - '# \033[3mClean up workspace\033[0m ---------------------------------------------------------------------------------- #\n' ; + '${coreutils}/bin/printf' \ + '# \033[3mSet up udev rules\033[0m ----------------------------------------------------------------------------------- #\n' ; ( - '${pkgs.coreutils}/bin/rm' -rf -- "''${_ROOT_DIR}/keymap/" ; + '${coreutils}/bin/printf' 'Set up /etc/udev/rules.d/\n' && + $( + (${which}/bin/which doas >/dev/null 2>/dev/null && ${coreutils}/bin/printf 'doas bash') || + (${which}/bin/which sudo >/dev/null 2>/dev/null && ${coreutils}/bin/printf 'sudo bash') || + (${coreutils}/bin/printf 'su') + ) -c " + '${coreutils}/bin/mkdir' -p '/etc/udev/rules.d/' && + '${coreutils}/bin/cp' -rf \"''${_ROOT_DIR}/QMK/util/udev/\"* '/etc/udev/rules.d/' + " && + '${coreutils}/bin/printf' '/etc/udev/rules.d/ set up successfully\n' ; ) || XC="$(( "''${XC}" + 0x01 ))" ; - '${pkgs.coreutils}/bin/printf' '\n' ; + '${coreutils}/bin/printf' '\n' ; - '${pkgs.coreutils}/bin/printf' \ - '# \033[3mCopy default keymap\033[0m --------------------------------------------------------------------------------- #\n' ; + '${coreutils}/bin/printf' \ + '# \033[3mResize /run/user/$UID\033[0m ------------------------------------------------------------------------------- #\n' ; ( - '${pkgs.coreutils}/bin/cp' -rf -- "''${_ROOT_DIR}/QMK/keyboards/crkbd/keymaps/default" "''${_ROOT_DIR}/keymap"; + '${coreutils}/bin/printf' 'Set up /etc/udev/rules.d/\n' && + $( + (${which}/bin/which doas >/dev/null 2>/dev/null && ${coreutils}/bin/printf 'doas sh') || + (${which}/bin/which sudo >/dev/null 2>/dev/null && ${coreutils}/bin/printf 'sudo sh') || + (${coreutils}/bin/printf 'su') + ) -c " + '${coreutils}/bin/mkdir' -p '/etc/systemd/logind.conf.d/' && + '${coreutils}/bin/printf' '[Login]\nRuntimeDirectorySize=99%%\n' >'/etc/systemd/logind.conf.d/runtime_directory_size.conf' + " && + '${coreutils}/bin/printf' '/run/user/$UID resized successfully\n' ; ) || XC="$(( "''${XC}" + 0x02 ))" ; - '${pkgs.coreutils}/bin/printf' '\n' ; + '${coreutils}/bin/printf' '\n' ; + + if [ "''${XC}" -eq 0 ] ; then + '${coreutils}/bin/printf' \ + '# \033[3mFinish\033[0m ---------------------------------------------------------------------------------------------- #\n' ; + '${coreutils}/bin/printf' '\033[3mSet up complete.\nPlease reboot your system to ensure that changes take effect.\033[0m\n\n' + fi return "''${XC}" } @@ -230,12 +247,12 @@ in pkgs.mkShell { update() { local XC=0 - '${pkgs.coreutils}/bin/printf' \ - '# \033[3mUpdate submodule\033[0m ------------------------------------------------------------------------------------ #\n' ; + '${coreutils}/bin/printf' \ + '# \033[3mUpdate submodules\033[0m ----------------------------------------------------------------------------------- #\n' ; ( - '${pkgs.git}/bin/git' -C "''${_ROOT_DIR}" submodule update --remote --progress ; + '${git}/bin/git' -C "''${_ROOT_DIR}" submodule update --remote --progress ; ) || XC="$(( "''${XC}" + 0x01 ))" ; - '${pkgs.coreutils}/bin/printf' '\n' ; + '${coreutils}/bin/printf' '\n' ; return "''${XC}" } @@ -243,13 +260,13 @@ in pkgs.mkShell { clean() { local XC=0 - '${pkgs.coreutils}/bin/printf' \ + '${coreutils}/bin/printf' \ '# \033[3mClean workspace\033[0m ------------------------------------------------------------------------------------- #\n' ; ( - '${pkgs.git}/bin/git' -C "''${_ROOT_DIR}/QMK" clean -df && \ - '${pkgs.git}/bin/git' -C "''${_ROOT_DIR}" clean -dfX ; + '${git}/bin/git' -C "''${_ROOT_DIR}/QMK" clean -df && + '${git}/bin/git' -C "''${_ROOT_DIR}" clean -dfX ; ) || XC="$(( "''${XC}" + 0x01 ))" ; - '${pkgs.coreutils}/bin/printf' '\n' ; + '${coreutils}/bin/printf' '\n' ; return "''${XC}" } @@ -257,33 +274,69 @@ in pkgs.mkShell { lint() { local XC=0 - local KEYMAP_ID="$('${pkgs.coreutils}/bin/cat' /proc/sys/kernel/random/uuid)" + local KEYMAP_ID="$('${coreutils}/bin/cat' /proc/sys/kernel/random/uuid)" - '${pkgs.coreutils}/bin/printf' \ + '${coreutils}/bin/printf' \ '# \033[3mLink keymap\033[0m ----------------------------------------------------------------------------------------- #\n' ; ( - '${pkgs.coreutils}/bin/rm' -f -- "''${_ROOT_DIR}"/'QMK/keyboards/${KEYBOARD}/keymaps'/"''${KEYMAP_ID}" && \ - '${pkgs.coreutils}/bin/ln' -sf "''${_ROOT_DIR}/keymap" "''${_ROOT_DIR}"/'QMK/keyboards/${KEYBOARD}/keymaps'/"''${KEYMAP_ID}" && \ - '${pkgs.coreutils}/bin/printf' 'Linked QMK/keyboards/${KEYBOARD}/keymaps/%s\n' "''${KEYMAP_ID}" ; + '${coreutils}/bin/rm' -f -- "''${_ROOT_DIR}"/'QMK/keyboards/${KEYBOARD}/keymaps'/"''${KEYMAP_ID}" && + '${coreutils}/bin/ln' -sf "''${_ROOT_DIR}/keymap" "''${_ROOT_DIR}"/'QMK/keyboards/${KEYBOARD}/keymaps'/"''${KEYMAP_ID}" && + '${coreutils}/bin/printf' 'Linked QMK/keyboards/${KEYBOARD}/keymaps/%s\n' "''${KEYMAP_ID}" ; ) || XC="$(( "''${XC}" + 0x01 ))" ; - '${pkgs.coreutils}/bin/printf' '\n' ; + '${coreutils}/bin/printf' '\n' ; - [[ "''${XC}" -ne 0 ]] || ( - '${pkgs.coreutils}/bin/printf' \ + if [ "''${XC}" -eq 0 ] ; then + '${coreutils}/bin/printf' \ '# \033[3mQMK linting\033[0m ----------------------------------------------------------------------------------------- #\n' ; ( - cd "''${_ROOT_DIR}/QMK" && \ - '${pkgs.nix}/bin/nix-shell' --pure --run "qmk lint -kb '${KEYBOARD}' -km ''\'''${KEYMAP_ID}'" ; + cd "''${_ROOT_DIR}/QMK" && + '${nix}/bin/nix-shell' --pure --run "qmk lint --strict -kb '${KEYBOARD}' -km ''\'''${KEYMAP_ID}'" ; ) || XC="$(( "''${XC}" + 0x02 ))" ; - '${pkgs.coreutils}/bin/printf' '\n' ; - ) + '${coreutils}/bin/printf' '\n' ; + fi - '${pkgs.coreutils}/bin/printf' \ + '${coreutils}/bin/printf' \ '# \033[3mUnlink keymap\033[0m --------------------------------------------------------------------------------------- #\n' ; ( - '${pkgs.git}/bin/git' -C "''${_ROOT_DIR}/QMK" clean -df ; + '${git}/bin/git' -C "''${_ROOT_DIR}/QMK" clean -df ; ) || XC="$(( "''${XC}" + 0x04 ))" ; - '${pkgs.coreutils}/bin/printf' '\n' ; + '${coreutils}/bin/printf' '\n' ; + + return "''${XC}" + } + + format() { + local XC=0 + + local KEYMAP_ID="$('${coreutils}/bin/cat' /proc/sys/kernel/random/uuid)" + + '${coreutils}/bin/printf' \ + '# \033[3mLink keymap\033[0m ----------------------------------------------------------------------------------------- #\n' ; + ( + '${coreutils}/bin/rm' -f -- "''${_ROOT_DIR}"/'QMK/keyboards/${KEYBOARD}/keymaps'/"''${KEYMAP_ID}" && + '${coreutils}/bin/ln' -sf "''${_ROOT_DIR}/keymap" "''${_ROOT_DIR}"/'QMK/keyboards/${KEYBOARD}/keymaps'/"''${KEYMAP_ID}" && + '${coreutils}/bin/printf' 'Linked QMK/keyboards/${KEYBOARD}/keymaps/%s\n' "''${KEYMAP_ID}" ; + ) || XC="$(( "''${XC}" + 0x01 ))" ; + '${coreutils}/bin/printf' '\n' ; + + if [ "''${XC}" -eq 0 ] ; then + '${coreutils}/bin/printf' \ + '# \033[3mFormat code\033[0m ----------------------------------------------------------------------------------------- #\n' ; + ( + cd "''${_ROOT_DIR}/QMK" && + '${nix}/bin/nix-shell' --pure --run "${clang-tools}/bin/clang-format -i --verbose \$( + ${findutils}/bin/find -L 'keyboards/${KEYBOARD}/keymaps'/"''${KEYMAP_ID}" -type f -regextype awk -regex '.+\.(h|hpp|c|cpp|inc)' + )" ; + ) || XC="$(( "''${XC}" + 0x02 ))" ; + '${coreutils}/bin/printf' '\n' ; + fi + + '${coreutils}/bin/printf' \ + '# \033[3mUnlink keymap\033[0m --------------------------------------------------------------------------------------- #\n' ; + ( + '${git}/bin/git' -C "''${_ROOT_DIR}/QMK" clean -df ; + ) || XC="$(( "''${XC}" + 0x04 ))" ; + '${coreutils}/bin/printf' '\n' ; return "''${XC}" } @@ -291,53 +344,55 @@ in pkgs.mkShell { compile() { local XC=0 - local KEYMAP_ID="$('${pkgs.coreutils}/bin/cat' /proc/sys/kernel/random/uuid)" + local KEYMAP_ID="$('${coreutils}/bin/cat' /proc/sys/kernel/random/uuid)" - '${pkgs.coreutils}/bin/printf' \ + '${coreutils}/bin/printf' \ '# \033[3mClean up old builds\033[0m --------------------------------------------------------------------------------- #\n' ; ( - cd "''${_ROOT_DIR}/QMK" && \ - '${pkgs.nix}/bin/nix-shell' --pure --run 'qmk clean' && \ - '${pkgs.coreutils}/bin/printf' 'Cleaned QMK/.build\n' ; + cd "''${_ROOT_DIR}/QMK" && + '${nix}/bin/nix-shell' --pure --run 'qmk clean' && + '${coreutils}/bin/printf' 'Cleaned QMK/.build\n' ; ) || XC="$(( "''${XC}" + 0x01 ))" ; - '${pkgs.coreutils}/bin/printf' '\n' ; + '${coreutils}/bin/printf' '\n' ; - '${pkgs.coreutils}/bin/printf' \ + '${coreutils}/bin/printf' \ '# \033[3mLink keymap\033[0m ----------------------------------------------------------------------------------------- #\n' ; ( - '${pkgs.coreutils}/bin/rm' -f -- "''${_ROOT_DIR}"/'QMK/keyboards/${KEYBOARD}/keymaps'/"''${KEYMAP_ID}" && \ - '${pkgs.coreutils}/bin/ln' -sf "''${_ROOT_DIR}/keymap" "''${_ROOT_DIR}"/'QMK/keyboards/${KEYBOARD}/keymaps'/"''${KEYMAP_ID}" && \ - '${pkgs.coreutils}/bin/printf' 'Linked QMK/keyboards/${KEYBOARD}/keymaps/%s\n' "''${KEYMAP_ID}" ; + '${coreutils}/bin/rm' -f -- "''${_ROOT_DIR}"/'QMK/keyboards/${KEYBOARD}/keymaps'/"''${KEYMAP_ID}" && + '${coreutils}/bin/ln' -sf "''${_ROOT_DIR}/keymap" "''${_ROOT_DIR}"/'QMK/keyboards/${KEYBOARD}/keymaps'/"''${KEYMAP_ID}" && + '${coreutils}/bin/printf' 'Linked QMK/keyboards/${KEYBOARD}/keymaps/%s\n' "''${KEYMAP_ID}" ; ) || XC="$(( "''${XC}" + 0x02 ))" ; - '${pkgs.coreutils}/bin/printf' '\n' ; + '${coreutils}/bin/printf' '\n' ; - [[ "''${XC}" -ne 0 ]] || ( - '${pkgs.coreutils}/bin/printf' \ + if [ "''${XC}" -eq 0 ] ; then + '${coreutils}/bin/printf' \ '# \033[3mCompile\033[0m --------------------------------------------------------------------------------------------- #\n' ; ( - cd "''${_ROOT_DIR}/QMK" && \ - '${pkgs.nix}/bin/nix-shell' --pure --run "qmk compile -j '${builtins.toString PARALLEL}' -kb '${KEYBOARD}' -km ''\'''${KEYMAP_ID}'" ; + cd "''${_ROOT_DIR}/QMK" && + '${nix}/bin/nix-shell' --pure --run "qmk compile -j '${builtins.toString PARALLEL}' -kb '${KEYBOARD}' -km ''\'''${KEYMAP_ID}'" ; ) || XC="$(( "''${XC}" + 0x04 ))" ; - '${pkgs.coreutils}/bin/printf' '\n' ; - ) + '${coreutils}/bin/printf' '\n' ; + fi - [[ "''${XC}" -ne 0 ]] || ( - '${pkgs.coreutils}/bin/printf' \ + if [ "''${XC}" -eq 0 ] ; then + '${coreutils}/bin/printf' \ '# \033[3mExtract HEX file\033[0m ------------------------------------------------------------------------------------ #\n' ; ( - '${pkgs.coreutils}/bin/mkdir' -p "''${_ROOT_DIR}/.build" && \ - '${pkgs.coreutils}/bin/ls' "''${_ROOT_DIR}/QMK/.build"/*.hex | head -1 | xargs -i cp -f -- '{}' "''${_ROOT_DIR}/.build/firmware.hex" && \ - '${pkgs.coreutils}/bin/printf' 'Extracted .build/firmware.hex\n' ; + '${coreutils}/bin/mkdir' -p "''${_ROOT_DIR}/.build" && + '${coreutils}/bin/ls' "''${_ROOT_DIR}/QMK/.build"/*.hex | + '${coreutils}/bin/head' -1 | + '${findutils}/bin/xargs' -i cp -f -- '{}' "''${_ROOT_DIR}/.build/firmware.hex" && + '${coreutils}/bin/printf' 'Extracted .build/firmware.hex\n' ; ) || XC="$(( "''${XC}" + 0x08 ))" ; - '${pkgs.coreutils}/bin/printf' '\n' - ) + '${coreutils}/bin/printf' '\n' + fi - '${pkgs.coreutils}/bin/printf' \ + '${coreutils}/bin/printf' \ '# \033[3mUnlink keymap\033[0m --------------------------------------------------------------------------------------- #\n' ; ( - '${pkgs.git}/bin/git' -C "''${_ROOT_DIR}/QMK" clean -df ; + '${git}/bin/git' -C "''${_ROOT_DIR}/QMK" clean -df ; ) || XC="$(( "''${XC}" + 0x10 ))" ; - '${pkgs.coreutils}/bin/printf' '\n' ; + '${coreutils}/bin/printf' '\n' ; return "''${XC}" } @@ -345,196 +400,200 @@ in pkgs.mkShell { flash() { local XC=0 - local KEYMAP_ID="$('${pkgs.coreutils}/bin/cat' /proc/sys/kernel/random/uuid)" + local KEYMAP_ID="$('${coreutils}/bin/cat' /proc/sys/kernel/random/uuid)" - '${pkgs.coreutils}/bin/printf' \ + '${coreutils}/bin/printf' \ '# \033[3mClean up old builds\033[0m --------------------------------------------------------------------------------- #\n' ; ( - cd "''${_ROOT_DIR}/QMK" && \ - '${pkgs.nix}/bin/nix-shell' --pure --run 'qmk clean' && \ - '${pkgs.coreutils}/bin/printf' 'Cleaned QMK/.build\n' ; + cd "''${_ROOT_DIR}/QMK" && + '${nix}/bin/nix-shell' --pure --run 'qmk clean' && + '${coreutils}/bin/printf' 'Cleaned QMK/.build\n' ; ) || XC="$(( "''${XC}" + 0x01 ))" ; - '${pkgs.coreutils}/bin/printf' '\n' ; + '${coreutils}/bin/printf' '\n' ; - '${pkgs.coreutils}/bin/printf' \ + '${coreutils}/bin/printf' \ '# \033[3mLink keymap\033[0m ----------------------------------------------------------------------------------------- #\n' ; ( - '${pkgs.coreutils}/bin/rm' -f -- "''${_ROOT_DIR}"/'QMK/keyboards/${KEYBOARD}/keymaps'/"''${KEYMAP_ID}" && \ - '${pkgs.coreutils}/bin/ln' -sf "''${_ROOT_DIR}/keymap" "''${_ROOT_DIR}"/'QMK/keyboards/${KEYBOARD}/keymaps'/"''${KEYMAP_ID}" && \ - '${pkgs.coreutils}/bin/printf' 'Linked QMK/keyboards/${KEYBOARD}/keymaps/%s\n' "''${KEYMAP_ID}" ; + '${coreutils}/bin/rm' -f -- "''${_ROOT_DIR}"/'QMK/keyboards/${KEYBOARD}/keymaps'/"''${KEYMAP_ID}" && + '${coreutils}/bin/ln' -sf "''${_ROOT_DIR}/keymap" "''${_ROOT_DIR}"/'QMK/keyboards/${KEYBOARD}/keymaps'/"''${KEYMAP_ID}" && + '${coreutils}/bin/printf' 'Linked QMK/keyboards/${KEYBOARD}/keymaps/%s\n' "''${KEYMAP_ID}" ; ) || XC="$(( "''${XC}" + 0x02 ))" ; - '${pkgs.coreutils}/bin/printf' '\n' ; + '${coreutils}/bin/printf' '\n' ; - [[ "''${XC}" -ne 0 ]] || ( - '${pkgs.coreutils}/bin/printf' \ + if [ "''${XC}" -eq 0 ] ; then + '${coreutils}/bin/printf' \ '# \033[3mCompile\033[0m --------------------------------------------------------------------------------------------- #\n' ; ( - cd "''${_ROOT_DIR}/QMK" && \ - '${pkgs.nix}/bin/nix-shell' --pure --run "qmk compile -j '${builtins.toString PARALLEL}' -kb '${KEYBOARD}' -km ''\'''${KEYMAP_ID}'" ; + cd "''${_ROOT_DIR}/QMK" && + '${nix}/bin/nix-shell' --pure --run "qmk compile -j '${builtins.toString PARALLEL}' -kb '${KEYBOARD}' -km ''\'''${KEYMAP_ID}'" ; ) || XC="$(( "''${XC}" + 0x04 ))" ; - '${pkgs.coreutils}/bin/printf' '\n' ; - ) + '${coreutils}/bin/printf' '\n' ; + fi - [[ "''${XC}" -ne 0 ]] || ( - '${pkgs.coreutils}/bin/printf' \ + if [ "''${XC}" -eq 0 ] ; then + '${coreutils}/bin/printf' \ '# \033[3mFlash\033[0m ----------------------------------------------------------------------------------------------- #\n' ; ( - cd "''${_ROOT_DIR}/QMK" && \ - '${pkgs.nix}/bin/nix-shell' --pure --run "qmk flash -j '${builtins.toString PARALLEL}' -kb '${KEYBOARD}' -km ''\'''${KEYMAP_ID}'" ; + cd "''${_ROOT_DIR}/QMK" && + '${nix}/bin/nix-shell' --pure --run "qmk flash -j '${builtins.toString PARALLEL}' -kb '${KEYBOARD}' -km ''\'''${KEYMAP_ID}'" ; ) || XC="$(( "''${XC}" + 0x08 ))" ; - '${pkgs.coreutils}/bin/printf' '\n' ; - ) + '${coreutils}/bin/printf' '\n' ; + fi - '${pkgs.coreutils}/bin/printf' \ + '${coreutils}/bin/printf' \ '# \033[3mUnlink keymap\033[0m --------------------------------------------------------------------------------------- #\n' ; ( - '${pkgs.git}/bin/git' -C "''${_ROOT_DIR}/QMK" clean -df ; + '${git}/bin/git' -C "''${_ROOT_DIR}/QMK" clean -df ; ) || XC="$(( "''${XC}" + 0x10 ))" ; - '${pkgs.coreutils}/bin/printf' '\n' ; + '${coreutils}/bin/printf' '\n' ; return "''${XC}" } help() { - '${pkgs.coreutils}/bin/cat' </dev/null -.TH "NIX+QMK" "1" "" "" "Nix+QMK toolbox" -.\----------------------------------------------------------------------------\. -.SH NAME -.IP clean .9i -- Clean workdir. -.IP compile -- Build the keymap into a flashable .hex file. -.IP flash -- Burn the firmware onto a keyboard. -.IP help -- Show help info on available commands. -.IP init -- Copy the default keymap to the workdir. -.IP lint -- Run a simple lint on the keymap source code. -.IP setup -- Configure the work environment. -.IP update -- Update QMK to latest version. -.IP welcome -- Show the welcome screen. -.\----------------------------------------------------------------------------\. -.SH DESCRIPTION -Set of scripts to handle out of tree QMK keymaps. The intended purpose of these -is to both decluter QMK itself and to allow versioning of QMK to mitigate the -effects of breaking changes. -.PP -NOTE: None of these commands take any arguments. -.\----------------------------------------------------------------------------\. -.SH EXAMPLES -Usual development goes something along the lines: -.PP -.nf -.RS -# Install Nix -sh <(curl -L 'https://nixos.org/nix/install') --no-daemon -# Clone keymap repo -# If you don't clone, an empty repo will be initialised later on -git clone 'https://github.com///' '' -cd '' -# Enter Nix+QMK toolbox -nix-shell -# Set up environment -setup -# Reboot to make setup changes take effect -sudo reboot now - -# After reboot, move back to workdir -cd '' -# Enter back into Nix+QMK toolbox -nix-shell -# Copy the default keymap to workdir -init -# Edit the keymap -vim ./keymap.c -# Check code -lint -# Once done editing, compile the code -compile -# After the code compiled successfully, flash it -# (Put the keyboard into bootloader mode when prompted) -flash -# Clean up build files -clean - -# When there is an update to QMK -update -# You may need to set up the environment again -setup -# Reboot to make setup changes take effect -sudo reboot now -.RE -.fi -.\----------------------------------------------------------------------------\. -.SH PROMPT EXPLAINED -The CLI tool has a custom prompt, which shows some non essential but nice to -have info. -.PP -.nf - - +-------------------------- A simple hardcoded value, to serve as a - | hint that we are currently inside the - | toolbox environment. - | - | +------------------ The current ref of the repo. May be a - | | branch name, a commit hash, or , - | | depending of the current status of the - | | repo (or lack thereof). It also sports - | | a colour code: - | | * Green for clean repos. - | | * Yellow for a repo with staged but - | | uncommitted changes. - | | * Red if there are unstaged changes. - | | - | | +---------- The current directory, relative to the - | | | root of the project. - | | | - | | | +-- The exit code of the last command, - | | | | formatted in HEX and colour coded. - | | | | * Green for success (0x00). - | | | | * Red for errors (0x01-0x7F). - | | | | * Yellow for signals (0x80-0xFF). - V V V V -[ NIX+QMK @ main : ./foo/ ] 0x00 > - -.fi -.\----------------------------------------------------------------------------\. -.SH TROUBLESHOOTING -If something is not working as expected, the first step to check is the exit -code itself. I've wrote the scripts in such a way that each bit in the exit code -corresponds to a specific section of said script. e.g., if the code is 5, then -the sections 1 and 3 failed ( 2^(1-1) + 2^(3-1) = 5 ). -.PP -From the exit code you may be able to inspect the shell.nix file to determine -the source of the issue (the entirety of the relevant code is in there in a -monolithic file). -.PP -If you want to open an issue or a PR feel free to do so @ -.br -https://github.com/kip93/qmk-crkbd/ -EOF + '${coreutils}/bin/cat' </dev/null + .TH "NIX+QMK" "1" "" "" "Nix+QMK toolbox" + .\----------------------------------------------------------------------------\. + .SH NAME + .IP clean .9i + - Clean workdir. + .IP compile + - Build the keymap into a flashable .hex file. + .IP flash + - Burn the firmware onto a keyboard. + .IP format + - Formats the keymap code. + .IP help + - Show help info on available commands. + .IP init + - Setup your workspace. + .IP lint + - Run a simple lint on the keymap source code. + .IP setup + - Configure the work environment. + .IP update + - Update QMK to latest version. + .IP welcome + - Show the welcome screen. + .\----------------------------------------------------------------------------\. + .SH DESCRIPTION + Set of scripts to handle out of tree QMK keymaps. The intended purpose of these + is to both decluter QMK itself and to allow versioning of QMK to mitigate the + effects of breaking changes. + .PP + NOTE: None of these commands take any arguments. + .\----------------------------------------------------------------------------\. + .SH EXAMPLES + Usual development goes something along the lines: + .PP + .nf + .RS + # Install Nix + sh <(curl -L 'https://nixos.org/nix/install') --no-daemon + # Clone keymap repo + # If you don't clone, an empty repo will be initialised later on + git clone 'https://github.com///' '' + cd '' + # Enter Nix+QMK toolbox + nix-shell + # Initialise your workspace, including a default keymap + init + # Set up environment + setup + # Reboot to make environment setup changes take effect + sudo reboot now + + # After reboot, move back to workdir + cd '' + # Enter back into Nix+QMK toolbox + nix-shell + # Edit the keymap + vim ./keymap/keymap.c + # Format code + format + # Check code + lint + # Once done editing, compile the code + compile + # After the code compiled successfully, flash it + # (Put the keyboard into bootloader mode when prompted) + flash + # Clean up build files + clean + + # When there is an update to QMK + update + # You may need to set up the environment again + setup + # Reboot to make setup changes take effect + sudo reboot now + .RE + .fi + .\----------------------------------------------------------------------------\. + .SH PROMPT EXPLAINED + The CLI tool has a custom prompt, which shows some non essential but nice to + have info. + .PP + .nf + + +-------------------------- A simple hardcoded value, to serve as a + | hint that we are currently inside the + | toolbox environment. + | + | +------------------ The current ref of the repo. May be a + | | branch name, a commit hash, or , + | | depending of the current status of the + | | repo (or lack thereof). It also sports + | | a colour code: + | | * Green for clean repos. + | | * Yellow for a repo with staged but + | | uncommitted changes. + | | * Red if there are unstaged changes. + | | + | | +---------- The current directory, relative to the + | | | root of the project. + | | | + | | | +-- The exit code of the last command, + | | | | formatted in HEX and colour coded. + | | | | * Green for success (0x00). + | | | | * Red for errors (0x01-0x7F). + | | | | * Yellow for signals (0x80-0xFF). + V V V V + [ NIX+QMK @ main : ./foo/ ] 0x00 > + + .fi + .\----------------------------------------------------------------------------\. + .SH TROUBLESHOOTING + If something is not working as expected, the first step to check is the exit + code itself. I've wrote the scripts in such a way that each bit in the exit code + corresponds to a specific section of said script. e.g., if the code is 5, then + the sections 1 and 3 failed ( 2^(1-1) + 2^(3-1) = 5 ). + .PP + From the exit code you may be able to inspect the shell.nix file to determine + the source of the issue (the entirety of the relevant code is in there in a + monolithic file). + .PP + If you want to open an issue or a PR feel free to do so @ + .br + https://github.com/kip93/qmk-crkbd/ + EOF return 0 } welcome() { - '${pkgs.coreutils}/bin/printf' '\033[0m , , , , , ,\n' - '${pkgs.coreutils}/bin/printf' '\033[0m \033[1;30m.-------------.\033[0m\n' - '${pkgs.coreutils}/bin/printf' '\033[0m - \033[1;30m| | \033[0m- \033[3mWelcome to this (unofficial) \033[1mNix+QMK toolbox\033[0;3m.\033[0m\n' - '${pkgs.coreutils}/bin/printf' '\033[0m - \033[1;30m| \033[0;1m| | |\033[0;1;30m | \033[0m-\n' - '${pkgs.coreutils}/bin/printf' '\033[0m - \033[1;30m| \033[0;1m| | |\033[0;1;30m | \033[0m- \033[3mAn opinionated set of scripts for standalone QMK keymaps\033[0m\n' - '${pkgs.coreutils}/bin/printf' '\033[0m - \033[1;30m| \033[0;1m|__|__|\033[0;1;30m | \033[0m-\n' - '${pkgs.coreutils}/bin/printf' '\033[0m - \033[1;30m| \033[0;1m|\033[0;1;30m | \033[0m-\n' - '${pkgs.coreutils}/bin/printf' '\033[0m - \033[1;30m|_____________| \033[0m-\n' - '${pkgs.coreutils}/bin/printf' '\033[0m , , , , , ,\n' - '${pkgs.coreutils}/bin/printf' '\n' - '${pkgs.coreutils}/bin/printf' '\033[0m\033[3mType `help` to get info on available commands.\033[0m\n' - '${pkgs.coreutils}/bin/printf' '\n' + '${coreutils}/bin/printf' '\033[0m , , , , , ,\n' + '${coreutils}/bin/printf' '\033[0m \033[1;30m.-------------.\033[0m\n' + '${coreutils}/bin/printf' '\033[0m - \033[1;30m| | \033[0m- \033[3mWelcome to this (unofficial) \033[1mNix+QMK toolbox\033[0;3m.\033[0m\n' + '${coreutils}/bin/printf' '\033[0m - \033[1;30m| \033[0;1m| | |\033[0;1;30m | \033[0m-\n' + '${coreutils}/bin/printf' '\033[0m - \033[1;30m| \033[0;1m| | |\033[0;1;30m | \033[0m- \033[3mAn opinionated set of scripts for standalone QMK keymaps\033[0m\n' + '${coreutils}/bin/printf' '\033[0m - \033[1;30m| \033[0;1m|__|__|\033[0;1;30m | \033[0m-\n' + '${coreutils}/bin/printf' '\033[0m - \033[1;30m| \033[0;1m|\033[0;1;30m | \033[0m-\n' + '${coreutils}/bin/printf' '\033[0m - \033[1;30m|_____________| \033[0m-\n' + '${coreutils}/bin/printf' '\033[0m , , , , , ,\n' + '${coreutils}/bin/printf' '\n' + '${coreutils}/bin/printf' '\033[0m\033[3mType `help` to get info on available commands.\033[0m\n' + '${coreutils}/bin/printf' '\n' return 0 }