Add build-glove80 script

Instead of running NixOS in Docker, I can build the firmware natively as
I'm running NixOS.
This commit is contained in:
Oliver Davies 2024-11-21 13:19:21 +00:00
parent bebdfb82fd
commit 962e97f613
3 changed files with 44 additions and 0 deletions

View file

@ -51,6 +51,7 @@ in
with pkgs;
[
brave
build-glove80
discord
gimp
gscan2pdf

View file

@ -0,0 +1,41 @@
{ pkgs, ... }:
pkgs.writeShellApplication {
name = "build-glove80";
runtimeInputs = with pkgs; [
cachix
git
nix
];
text = ''
BRANCH="''${1:-main}"
SRC_DIR="''${PWD}/src"
CONFIG_DIR="''${PWD}/config"
NIX_FILE="''${CONFIG_DIR}/default.nix"
# Ensure cachix is configured
echo "Using moergo-glove80-zmk-dev cache"
cachix use moergo-glove80-zmk-dev
# Clone or update the ZMK repository
if [ ! -d "$SRC_DIR" ]; then
echo "Cloning ZMK repository into ./src..."
git clone https://github.com/moergo-sc/zmk "$SRC_DIR"
else
echo "Updating ZMK repository in ./src..."
git -C "$SRC_DIR" fetch --all
fi
# Checkout the specified branch or tag
echo "Checking out branch/tag: $BRANCH in ./src"
git -C "$SRC_DIR" checkout -q --detach "$BRANCH"
# Build firmware using Nix
echo "Building firmware from: $NIX_FILE"
nix-build "$NIX_FILE" --arg firmware "import ''${SRC_DIR}/default.nix {}" -j2 -o ./glove80.uf2 --show-trace
echo "Firmware built successfully: $(realpath ./glove80.uf2)"
'';
}

View file

@ -4,6 +4,8 @@ let
inherit (pkgs) callPackage;
in
{
build-glove80 = callPackage ./build-glove80.nix { };
vimPlugins = prev.vimPlugins // {
conf-vim = callPackage ./vim-plugins/conf-vim.nix { };
edit-alternate-vim = callPackage ./vim-plugins/edit-alternate-vim.nix { };