Files
keyboard/flake.nix

79 lines
2.2 KiB
Nix

{
description = "System76 Launch 3 keyboard firmware";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
self.submodules = true;
};
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"
ln -sfn "$PWD/keymaps/custom" "$QMK_HOME/keyboards/system76/launch_3/keymaps/custom"
git -C "$QMK_HOME" checkout -- .
for p in "$PWD"/patches/*.patch; do
[ -f "$p" ] && patch -d "$QMK_HOME" -p1 < "$p"
done
'';
};
});
packages = forAllSystems (system:
let pkgs = nixpkgs.legacyPackages.${system};
in {
default = self.packages.${system}.firmware;
firmware = pkgs.stdenv.mkDerivation {
pname = "launch3-firmware";
version = "0.1.0";
src = ./qmk_firmware;
patches = builtins.map (f: ./patches + "/${f}")
(builtins.attrNames (builtins.readDir ./patches));
postUnpack = ''
cp -r ${./keymaps/custom} $sourceRoot/keyboards/system76/launch_3/keymaps/custom
'';
postPatch = ''
patchShebangs util/uf2conv.py
'';
nativeBuildInputs = [
pkgs.qmk
pkgs.python3Packages.appdirs
pkgs.python3
];
buildPhase = ''
export HOME=$(mktemp -d)
export QMK_HOME="$PWD"
export SKIP_GIT=true
qmk compile -kb system76/launch_3 -km custom
'';
installPhase = ''
mkdir -p $out
cp *.uf2 $out/ 2>/dev/null || cp .build/*.uf2 $out/
'';
};
});
};
}