You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
5.4 KiB

  1. # External QMK Userspace
  2. QMK Firmware now officially supports storing user keymaps outside of the normal QMK Firmware repository, allowing users to maintain their own keymaps without having to fork, modify, and maintain a copy of QMK Firmware themselves.
  3. External Userspace mirrors the structure of the main QMK Firmware repository, but only contains the keymaps that you wish to build. You can still use `keyboards/<my keyboard>/keymaps/<my keymap>` to store your keymaps, or you can use the `layouts/<my layout>/<my keymap>` system as before -- they're just stored external to QMK Firmware.
  4. The build system will still honor the use of `users/<my keymap>` if you rely on the traditional QMK Firmware [userspace feature](feature_userspace.md) -- it's now supported externally too, using the same location inside the External Userspace directory.
  5. Additionally, there is first-class support for using GitHub Actions to build your keymaps, allowing you to automatically compile your keymaps whenever you push changes to your External Userspace repository.
  6. !> External Userspace is new functionality and may have issues. Tighter integration with the `qmk` command will occur over time.
  7. ?> Historical keymap.json and GitHub-based firmware build instructions can be found [here](newbs_building_firmware_workflow.md). This document supersedes those instructions, but they should still function correctly.
  8. ## Setting up QMK Locally
  9. If you wish to build on your local machine, you will need to set up QMK locally. This is a one-time process, and is documented in the [newbs setup guide](https://docs.qmk.fm/#/newbs).
  10. !> If you wish to use any QMK CLI commands related to manipulating External Userspace definitions, you will currently need a copy of QMK Firmware as well.
  11. !> Building locally has a much shorter turnaround time than waiting for GitHub Actions to complete.
  12. ## External Userspace Repository Setup (forked on GitHub)
  13. A basic skeleton External Userspace repository can be found [here](https://github.com/qmk/qmk_userspace). If you wish to keep your keymaps on GitHub (strongly recommended!), you can fork the repository and use it as a base:
  14. ![Userspace Fork](https://i.imgur.com/hcegguh.png)
  15. Going ahead with your fork will copy it to your account, at which point you can clone it to your local machine and begin adding your keymaps:
  16. ![Userspace Clone](https://i.imgur.com/CWYmsk8.png)
  17. ```sh
  18. cd $HOME
  19. git clone https://github.com/{myusername}/qmk_userspace.git
  20. qmk config user.overlay_dir="$(realpath qmk_userspace)"
  21. ```
  22. ## External Userspace Setup (locally stored only)
  23. If you don't want to use GitHub and prefer to keep everything local, you can clone a copy of the default External Userspace locally instead:
  24. ```sh
  25. cd $HOME
  26. git clone https://github.com/qmk/qmk_userspace.git
  27. qmk config user.overlay_dir="$(realpath qmk_userspace)"
  28. ```
  29. ## Adding a Keymap
  30. _These instructions assume you have already set up QMK locally, and have a copy of the QMK Firmware repository on your machine._
  31. Keymaps within External Userspace are defined in the same way as they are in the main QMK repository. You can either use the `qmk new-keymap` command to create a new keymap, or manually create a new directory in the `keyboards` directory.
  32. Alternatively, you can use the `layouts` directory to store your keymaps, using the same layout system as the main QMK repository -- if you choose to do so you'll want to use the path `layouts/<layout name>/<keymap name>/keymap.*` to store your keymap files, where `layout name` matches an existing layout in QMK, such as `tkl_ansi`.
  33. After creating your new keymap, building the keymap matches normal QMK usage:
  34. ```sh
  35. qmk compile -kb <keyboard> -km <keymap>
  36. ```
  37. !> The `qmk config user.overlay_dir=...` command must have been run when cloning the External Userspace repository for this to work correctly.
  38. ## Adding the keymap to External Userspace build targets
  39. Once you have created your keymap, if you want to use GitHub Actions to build your firmware, you will need to add it to the External Userspace build targets. This is done using the `qmk userspace-add` command:
  40. ```sh
  41. # for a keyboard/keymap combo:
  42. qmk userspace-add -kb <keyboard> -km <keymap>
  43. # or, for a json-based keymap (if kept "loose"):
  44. qmk userspace-add <relative/path/to/my/keymap.json>
  45. ```
  46. This updates the `qmk.json` file in the root of your External Userspace directory. If you're using a git repository to store your keymaps, now is a great time to commit and push to your own fork.
  47. ## Compiling External Userspace build targets
  48. Once you have added your keymaps to the External Userspace build targets, you can compile all of them at once using the `qmk userspace-compile` command:
  49. ```sh
  50. qmk userspace-compile
  51. ```
  52. All firmware builds you've added to the External Userspace build targets will be built, and the resulting firmware files will be placed in the root of your External Userspace directory.
  53. ## Using GitHub Actions
  54. GitHub Actions can be used to automatically build your keymaps whenever you push changes to your External Userspace repository. If you have set up your list of build targets, this is as simple as enabling workflows in the GitHub repository settings:
  55. ![Repo Settings](https://i.imgur.com/EVkxOt1.png)
  56. Any push will result in compilation of all configured builds, and once completed a new release containing the newly-minted firmware files will be created on GitHub, which you can subsequently download and flash to your keyboard:
  57. ![Releases](https://i.imgur.com/zmwOL5P.png)