Skip to content

Commit

Permalink
refactor: port to flake
Browse files Browse the repository at this point in the history
  • Loading branch information
MattSturgeon committed Mar 24, 2024
1 parent 557a297 commit b1b8e2b
Show file tree
Hide file tree
Showing 5 changed files with 214 additions and 30 deletions.
32 changes: 12 additions & 20 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,19 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- id: date
run: |
date=$(date +'%Y-%m-%d')
echo "Date: $date"
echo "date=$date" >> $GITHUB_OUTPUT
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/checkout@v4
with:
repository: moergo-sc/zmk
ref: main
path: src
- uses: cachix/install-nix-action@v25
with:
nix_path: nixpkgs=channel:nixos-22.05
- uses: cachix/cachix-action@v14
with:
name: moergo-glove80-zmk-dev
skipPush: true
- name: Build Glove80 combined firmware
run: nix-build config -o combined
- name: Copy result out of nix store
run: cp combined/glove80.uf2 glove80.uf2
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- uses: DeterminateSystems/flake-checker-action@main
- name: Build Glove80 firmware
run: nix build
- name: Upload result
uses: actions/upload-artifact@v4
with:
name: glove80.uf2
path: glove80.uf2
name: glove80-${{ steps.date.outputs.date }}.uf2
path: result/glove80.uf2
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*~
env/
result
10 changes: 0 additions & 10 deletions config/default.nix

This file was deleted.

120 changes: 120 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

81 changes: 81 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
glove80-zmk = {
url = "github:moergo-sc/zmk";
flake = false;
};
flake-parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
};
devshell = {
url = "github:numtide/devshell";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = {
self,
nixpkgs,
glove80-zmk,
flake-parts,
devshell,
} @ inputs:
flake-parts.lib.mkFlake {inherit inputs;} {
systems = nixpkgs.lib.systems.flakeExposed;
imports = [
inputs.devshell.flakeModule
];

perSystem = {
config,
pkgs,
system,
...
}: {
packages.default = let
firmware = import glove80-zmk {inherit pkgs;};

keymap = ./config/glove80.keymap;
kconfig = ./config/glove80.conf;

glove80_left = firmware.zmk.override {
inherit keymap kconfig;
board = "glove80_lh";
};

glove80_right = firmware.zmk.override {
inherit keymap kconfig;
board = "glove80_rh";
};
in
firmware.combine_uf2 glove80_left glove80_right;

devshells.default.commands = [
{
name = "flash";
command = /*bash*/ ''
set +e
root="/run/media/$(whoami)"
dest_folder_name=$(ls $root | grep GLV80)
dest="$root"/"$dest_folder_name"
if [[ -n "$dest_folder_name" && -d "$dest" ]]; then
echo Flashing to "$dest"
cp ${config.packages.default}/glove80.uf2 "$dest"/CURRENT.UF2
exit 0
else
echo "Error: Glove80 keyboard is not plugged-in"
exit 1
fi
'';
help = "builds the firmware and copies it to the plugged-in keybaord half";
}
];

formatter = pkgs.alejandra;
};
};
}

0 comments on commit b1b8e2b

Please sign in to comment.