diff --git a/nix/home/opdavies/default.nix b/nix/home/opdavies/default.nix index 1ef9542..f2c0370 100644 --- a/nix/home/opdavies/default.nix +++ b/nix/home/opdavies/default.nix @@ -51,6 +51,7 @@ in with pkgs; [ brave + build-glove80 discord gimp gscan2pdf diff --git a/nix/pkgs/build-glove80.nix b/nix/pkgs/build-glove80.nix new file mode 100644 index 0000000..9c66874 --- /dev/null +++ b/nix/pkgs/build-glove80.nix @@ -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)" + ''; +} diff --git a/nix/pkgs/default.nix b/nix/pkgs/default.nix index 3d2be89..d8cb037 100644 --- a/nix/pkgs/default.nix +++ b/nix/pkgs/default.nix @@ -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 { };