Nix flake with devShell providing qmk CLI for firmware development. Custom keymap (copy of default) symlinked into QMK tree on shell entry. Setup: nix develop, then qmk setup system76/qmk_firmware Build: qmk compile -kb system76/launch_3 -km custom Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
63 lines
1.6 KiB
Nix
63 lines
1.6 KiB
Nix
{
|
|
description = "System76 Launch 3 keyboard firmware";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
};
|
|
|
|
outputs = { self, nixpkgs }:
|
|
let
|
|
supportedSystems = [ "x86_64-linux" "aarch64-linux" ];
|
|
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
|
|
in {
|
|
devShells = forAllSystems (system:
|
|
let pkgs = nixpkgs.legacyPackages.${system};
|
|
in {
|
|
default = pkgs.mkShell {
|
|
name = "launch3-firmware";
|
|
|
|
packages = [
|
|
pkgs.qmk
|
|
pkgs.python3Packages.appdirs
|
|
];
|
|
|
|
shellHook = ''
|
|
export QMK_HOME="$PWD/qmk_firmware"
|
|
|
|
# Symlink tracked keymap into QMK tree
|
|
if [ -d "$QMK_HOME/keyboards/system76/launch_3" ]; then
|
|
ln -sfn "$PWD/keymaps/custom" "$QMK_HOME/keyboards/system76/launch_3/keymaps/custom"
|
|
fi
|
|
'';
|
|
};
|
|
});
|
|
|
|
packages = forAllSystems (system:
|
|
let pkgs = nixpkgs.legacyPackages.${system};
|
|
in {
|
|
firmware = pkgs.stdenv.mkDerivation {
|
|
pname = "launch3-firmware";
|
|
version = "0.1.0";
|
|
|
|
src = ./qmk_firmware;
|
|
|
|
nativeBuildInputs = [
|
|
pkgs.qmk
|
|
pkgs.python3Packages.appdirs
|
|
];
|
|
|
|
buildPhase = ''
|
|
export HOME=$(mktemp -d)
|
|
export QMK_HOME="$PWD"
|
|
qmk compile -kb system76/launch_3 -km custom
|
|
'';
|
|
|
|
installPhase = ''
|
|
mkdir -p $out
|
|
cp *.uf2 $out/ 2>/dev/null || cp .build/*.uf2 $out/
|
|
'';
|
|
};
|
|
});
|
|
};
|
|
}
|