How to build ZMK firmwares with custom shields locally

  • 2 min read

I want to move away from microslops github and want to build ZMK-firmwares for my keyboards locally. As I found it confusing to add custom shields to the local toolchain, I wrote the following tutorial.

  1. Install urobs ZMK toolchain
  2. make sure to use bash, for me the direnv did not work with zsh
  3. for me nix-direnv gave permission errors so I chowned the /nix/var/nix to my username recursively.
  4. there are multiple options to add custom shields
    1. Put everything in your local tree (Not reccomended, but the easiest)
      1. put all the shield defining files (.overlay, etc) in zmk/app/boards/shields/$YOURSHIELD
      2. build with just build $SHIELDNAME.
      3. However this has the disadvantage, that your files will be overwritten when you do a just update
    2. Manage your shield as an external west module (Recommended but more annoying)
      1. create your zmk files from the unified zmk config template into a directory $DIR
      2. build your firmware with west build -p -s zmk/app -b $BOARD_NAME -- -DZMK_EXTRA_MODULES="$ABSOLUTE_PATH_TO_$DIR" -DSHIELD=$SHIELD_NAME, where in my case $BOARD_NAME is nice_nano_v2 and $SHIELD_NAME is endgame