restore-colemakdh #1

Open
dave wants to merge 41 commits from restore-colemakdh into main
9 changed files with 340 additions and 27 deletions

26
.github/workflows/docker-build.yml vendored Normal file
View File

@@ -0,0 +1,26 @@
name: Build QMK Firmware with Docker
on: [push, pull_request]
jobs:
build:
runs-on: local
container:
image: ubuntu
steps:
- name: Install packages
run: |
apt-get update && apt-get install -y nodejs git python3 python3-pip rsync apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
apt update
apt install -y docker-ce docker-ce-cli containerd.io
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Build Docker image
run: docker build --load -t qmk-builder .
- name: Tag Docker image
run: docker tag qmk-builder registry.home.dgvigil.dev/qmk-builder:v0.1
- name: Push Docker image
run: docker push registry.home.dgvigil.dev/qmk-builder:v0.1

View File

@@ -1,40 +1,33 @@
name: Compile my Keebs name: Compile my Keebs
on: [push] on: [pull_request]
jobs: jobs:
lint-and-compile: lint-and-compile:
runs-on: ubuntu-latest runs-on: local
container:
image: registry.home.dgvigil.dev/qmk-builder:v0.1
steps: steps:
- name: Check out repository code - name: Check out repository code
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Clone supercharge docs repository - name: Checkout submodules
uses: actions/checkout@v2
with:
repository: Homelab/qmk_firmware
path: qmk_firmware
ref: master
- name: Setup
run: | run: |
pwd git submodule update --init --recursive
python3 -m pip install --break-system-package --user qmk
python3 -m pip install --break-system-package -r /workspace/dave/dgvigil-keebs/qmk_firmware/requirements.txt
qmk setup -y
cd /workspace/dave/dgvigil-keebs/qmk_firmware/
make git-submodules
- name: Prep - name: Prep
run: | run: |
pwd
ls -la
cd /workspace/dave/dgvigil-keebs/ cd /workspace/dave/dgvigil-keebs/
rsync -avP $(pwd)/dgvigil/ qmk_firmware/users/dgvigil/ cp -a $(pwd)/dgvigil/ qmk_firmware/users/dgvigil/
rsync -avP $(pwd)/draculad/ qmk_firmware/keyboards/draculad/keymaps/dgvigil/ cp -a $(pwd)/draculad/ qmk_firmware/keyboards/draculad/keymaps/dgvigil/
rsync -avP $(pwd)/iris/ qmk_firmware/keyboards/keebio/iris/keymaps/dgvigil/ cp -a $(pwd)/iris/ qmk_firmware/keyboards/keebio/iris/keymaps/dgvigil/
rsync -avP $(pwd)/sweep/ qmk_firmware/keyboards/ferris/keymaps/dgvigil/ cp -a $(pwd)/sweep/ qmk_firmware/keyboards/ferris/keymaps/dgvigil/
rsync -avP $(pwd)/scottogame/ qmk_firmware/keyboards/handwired/scottokeebs/scottogame/keymaps/dgvigil/ cp -a $(pwd)/scottogame/ qmk_firmware/keyboards/handwired/scottokeebs/scottogame/keymaps/dgvigil/
rsync -avP $(pwd)/swoop/ qmk_firmware/keyboards/bluebell/swoop/keymaps/dgvigil/ cp -a $(pwd)/swoop/ qmk_firmware/keyboards/bluebell/swoop/keymaps/dgvigil/
rsync -avP $(pwd)/q8/ qmk_firmware/keyboards/keychron/q8/ansi_encoder/keymaps/dgvigil/ cp -a $(pwd)/q8/ qmk_firmware/keyboards/keychron/q8/ansi_encoder/keymaps/dgvigil/
- name: Build - name: Build
run: | run: |
cd /home/runner/work/dgvigil-keebs/dgvigil-keebs/qmk_firmware/ cd /workspace/dave/dgvigil-keebs/qmk_firmware/
echo "Building QMK for draculad" # echo "Building QMK for draculad"
qmk compile -kb draculad -km dgvigil -e CONVERT_TO=promicro_rp2040 # /root/.local/bin/qmk compile -kb draculad -km dgvigil -e CONVERT_TO=promicro_rp2040
# echo "Building QMK for handwired/scottokeebs/scottogame" # echo "Building QMK for handwired/scottokeebs/scottogame"
# qmk compile -kb handwired/scottokeebs/scottogame -km dgvigil # qmk compile -kb handwired/scottokeebs/scottogame -km dgvigil
# echo "Building QMK for Q8" # echo "Building QMK for Q8"
@@ -43,7 +36,7 @@ jobs:
# qmk compile -kb ferris/sweep -km dgvigil # qmk compile -kb ferris/sweep -km dgvigil
echo "Building QMK for keebio/iris/rev8" echo "Building QMK for keebio/iris/rev8"
qmk compile -kb keebio/iris/rev8 -km dgvigil qmk compile -kb keebio/iris/rev8 -km dgvigil
qmk compile -kb keebio/iris/rev8 -km via # /root/.local/bin/qmk compile -kb keebio/iris/rev8 -km via
# echo "Building QMK for bluebell/swoop" # echo "Building QMK for bluebell/swoop"
# qmk compile -kb bluebell/swoop -km dgvigil -e CONVERT_TO=promicro_rp2040 # qmk compile -kb bluebell/swoop -km dgvigil -e CONVERT_TO=promicro_rp2040
find -maxdepth 1 -name "*.hex" find -maxdepth 1 -name "*.hex"

3
.gitmodules vendored
View File

@@ -0,0 +1,3 @@
[submodule "qmk_firmware"]
path = qmk_firmware
url = https://git.home.dgvigil.dev/Homelab/qmk_firmware.git

101
DOCKER_README.md Normal file
View File

@@ -0,0 +1,101 @@
# QMK Firmware Docker Build Environment
This repository includes a custom Docker setup for building QMK firmware in CI/CD environments.
## Files
- `Dockerfile` - Custom Docker image for QMK firmware builds
- `.dockerignore` - Excludes unnecessary files from Docker build context
- `build.sh` - Convenience script for building firmware locally
- `.github/workflows/docker-build.yml` - GitHub Actions workflow using the custom Docker image
## Features
- Based on Ubuntu 22.04 for stability
- Includes ARM and AVR toolchains
- Pre-installed QMK CLI and dependencies
- Automatic symlink setup for your keymaps
- Optimized for your specific keyboard configurations
## Local Usage
### Building the Docker Image
```bash
docker build --load -t qmk-builder .
```
**Note:** The `--load` flag is required to make the image available locally with newer Docker versions.
### Building Firmware
#### Using the build script:
```bash
# Build all keyboards
./build.sh
# Build specific keyboard
./build.sh iris
# Build with custom user
./build.sh iris myuser
```
#### Using Docker directly:
```bash
# Build all keyboards
docker run --rm \
-v "$(pwd):/workspace" \
-w /workspace \
-e USER=dgvigil \
qmk-builder \
bash -c "cd /qmk_firmware && qmk compile -kb keebio/iris/rev8 -km dgvigil"
```
## CI/CD Usage
The `.github/workflows/docker-build.yml` workflow demonstrates how to use this Docker setup in GitHub Actions:
1. Builds the Docker image
2. Builds each keyboard in parallel
3. Uploads firmware artifacts
4. Creates releases on main branch pushes
## Supported Keyboards
- `draculad``draculad`
- `iris``keebio/iris/rev8`
- `scottogame``handwired/scottokeebs/scottogame`
- `sweep``ferris/sweep`
- `swoop``bluebell/swoop`
## Environment Variables
- `USER` - The QMK user name (defaults to `dgvigil`)
- `QMK_HOME` - Path to QMK firmware (set to `/qmk_firmware`)
## Differences from qmkfm/qmk_cli
This custom Dockerfile provides:
1. **Faster builds** - Pre-installed toolchains and dependencies
2. **Better integration** - Automatic symlink setup for your keymaps
3. **Consistent environment** - Same setup across local and CI builds
4. **Optimized for your workflow** - Tailored to your specific keyboard configurations
## Troubleshooting
### Build fails with toolchain errors
Make sure the Docker image is built with the latest QMK firmware:
```bash
docker build --no-cache -t qmk-builder .
```
### Symlinks not working
The entrypoint script automatically sets up symlinks, but you can verify they exist:
```bash
docker run --rm -v "$(pwd):/workspace" qmk-builder ls -la /qmk_firmware/keyboards/keebio/iris/keymaps/
```
### Missing firmware files
Check that the build completed successfully and look for `.hex` and `.uf2` files in the QMK firmware directory.

109
Dockerfile Normal file
View File

@@ -0,0 +1,109 @@
# QMK Firmware Build Environment
# Based on Ubuntu 22.04 for stability and compatibility
FROM ubuntu:22.04
# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive
ENV QMK_HOME=/qmk_firmware
ENV PATH="/root/.local/bin:$PATH"
# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
clang-format \
dfu-programmer \
dfu-util \
git \
libnewlib-arm-none-eabi \
nodejs \
python3 \
python3-pip \
python3-setuptools \
python3-wheel \
wget \
unzip \
&& rm -rf /var/lib/apt/lists/*
# Install ARM toolchain
RUN wget -qO- https://developer.arm.com/-/media/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2 | tar xj -C /opt \
&& ln -s /opt/gcc-arm-none-eabi-10.3-2021.10/bin/* /usr/local/bin/
# Install AVR toolchain
RUN wget -qO- https://downloads.arduino.cc/arduino-1.8.19-linux64.tar.xz | tar xJ -C /opt \
&& ln -s /opt/arduino-1.8.19/hardware/tools/avr/bin/* /usr/local/bin/
# Set up QMK environment
WORKDIR /workspace
RUN git clone --depth 1 https://github.com/qmk/qmk_firmware.git $QMK_HOME
# Install QMK CLI and Python dependencies
RUN pip3 install --user qmk
RUN pip3 install --user -r $QMK_HOME/requirements.txt
# Set up QMK
RUN qmk setup --yes
# Create build directory
RUN mkdir -p /workspace/build
# Set working directory
WORKDIR /workspace
# Copy entrypoint script
COPY <<EOF /usr/local/bin/entrypoint.sh
#!/bin/bash
set -e
# Initialize git submodules if they exist
if [ -f ".gitmodules" ]; then
git submodule update --init --recursive
fi
# Set up user keymaps
USER=\${USER:-dgvigil}
# Clean up old symlinks
rm -rf $QMK_HOME/keyboards/draculad/keymaps/\$USER 2>/dev/null || true
rm -rf $QMK_HOME/keyboards/keebio/iris/keymaps/\$USER 2>/dev/null || true
rm -rf $QMK_HOME/keyboards/handwired/scottokeebs/scottogame/keymaps/\$USER 2>/dev/null || true
rm -rf $QMK_HOME/keyboards/bluebell/swoop/keymaps/\$USER 2>/dev/null || true
rm -rf $QMK_HOME/keyboards/ferris/keymaps/\$USER 2>/dev/null || true
rm -rf $QMK_HOME/users/\$USER 2>/dev/null || true
# Create symlinks for keymaps
if [ -d "draculad" ]; then
ln -s /workspace/draculad/ $QMK_HOME/keyboards/draculad/keymaps/\$USER
fi
if [ -d "iris" ]; then
ln -s /workspace/iris/ $QMK_HOME/keyboards/keebio/iris/keymaps/\$USER
fi
if [ -d "sweep" ]; then
ln -s /workspace/sweep/ $QMK_HOME/keyboards/ferris/keymaps/\$USER
fi
if [ -d "scottogame" ]; then
ln -s /workspace/scottogame/ $QMK_HOME/keyboards/handwired/scottokeebs/scottogame/keymaps/\$USER
fi
if [ -d "swoop" ]; then
ln -s /workspace/swoop/ $QMK_HOME/keyboards/bluebell/swoop/keymaps/\$USER
fi
if [ -d "user" ]; then
ln -s /workspace/user/ $QMK_HOME/users/\$USER
fi
# Execute the command passed to the container
exec "\$@"
EOF
RUN chmod +x /usr/local/bin/entrypoint.sh
# Set entrypoint
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
# Default command
CMD ["bash"]

71
build.sh Executable file
View File

@@ -0,0 +1,71 @@
#!/bin/bash
set -e
# Build script for QMK firmware using Docker
# Usage: ./build.sh [keyboard] [user]
KEYBOARD=${1:-all}
USER=${2:-dgvigil}
echo "Building QMK firmware for user: $USER"
# Build the Docker image if it doesn't exist
if [[ "$(docker images -q qmk-builder 2> /dev/null)" == "" ]]; then
echo "Building Docker image..."
docker build --load -t qmk-builder .
fi
# Function to build a specific keyboard
build_keyboard() {
local kb=$1
local user=$2
echo "Building $kb for user $user..."
# Map keyboard names to QMK paths
case $kb in
"draculad")
qmk_path="draculad"
;;
"iris")
qmk_path="keebio/iris/rev8"
;;
"scottogame")
qmk_path="handwired/scottokeebs/scottogame"
;;
"sweep")
qmk_path="ferris/sweep"
;;
"swoop")
qmk_path="bluebell/swoop"
;;
*)
echo "Unknown keyboard: $kb"
exit 1
;;
esac
# Run the build in Docker
docker run --rm \
-v "$(pwd):/workspace" \
-w /workspace \
-e USER=$user \
qmk-builder \
bash -c "
cd $QMK_HOME
qmk compile -kb $qmk_path -km $user
"
}
# Build all keyboards or specific one
if [ "$KEYBOARD" = "all" ]; then
echo "Building all keyboards..."
for kb in draculad iris scottogame sweep swoop; do
build_keyboard $kb $USER
done
else
build_keyboard $KEYBOARD $USER
fi
echo "Build complete!"
echo "Firmware files should be in the qmk_firmware directory"

View File

@@ -3,7 +3,9 @@
#include "features/taphold.h" #include "features/taphold.h"
#include "features/tapdance.h" #include "features/tapdance.h"
#include "features/macros.h" #include "features/macros.h"
#include "features/combo.h"
#include "features/tap_dance.h"
#include "definitions/layers.h" #include "definitions/layers.h"
#include "definitions/process_record.h" #include "definitions/process_record.h"
#include "definitions/keycodes.h" #include "definitions/keycodes.h"
#include "definitions/keymap_blocks.h" #include "definitions/keymap_blocks.h"

View File

@@ -3,3 +3,10 @@ AUTO_SHIFT_ENABLE = yes
ENCODER_ENABLE = yes ENCODER_ENABLE = yes
ENCODER_MAP_ENABLE = yes ENCODER_MAP_ENABLE = yes
COMBO_ENABLE = yes
TAP_DANCE_ENABLE = yes
VIA_ENABLE = no
KEYMAP_INTROSPECTION_ENABLE := no
COMMUNITY_LAYOUT = no

1
qmk_firmware Submodule

Submodule qmk_firmware added at 86badb394e