mirror of
https://git.sr.ht/~magic_rb/dotfiles
synced 2024-12-03 05:26:18 +01:00
dd19ecbece
Signed-off-by: magic_rb <magic_rb@redalder.org>
153 lines
3.9 KiB
Nix
153 lines
3.9 KiB
Nix
# SPDX-FileCopyrightText: 2022 Richard Brežák <richard@brezak.sk>
|
|
#
|
|
# SPDX-License-Identifier: LGPL-3.0-or-later
|
|
{inputs, ...}: {
|
|
perSystem = {
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}: let
|
|
avrlibc = pkgs.pkgsCross.avr.libcCross;
|
|
avrBinutils = pkgs.pkgsCross.avr.buildPackages.binutils;
|
|
avrGcc = pkgs.pkgsCross.avr.buildPackages.gcc8;
|
|
|
|
bootloadHID =
|
|
(inputs.self.overlays.bootloadHID
|
|
null
|
|
pkgs)
|
|
.bootloadHID;
|
|
|
|
avr_incflags = [
|
|
"-isystem ${avrlibc}/avr/include"
|
|
"-B${avrlibc}/avr/lib/avr5"
|
|
"-L${avrlibc}/avr/lib/avr5"
|
|
"-B${avrlibc}/avr/lib/avr35"
|
|
"-L${avrlibc}/avr/lib/avr35"
|
|
"-B${avrlibc}/avr/lib/avr51"
|
|
"-L${avrlibc}/avr/lib/avr51"
|
|
];
|
|
# pythonEnv = with pkgs;
|
|
# poetry2nix.mkPoetryEnv {
|
|
# projectDir = "${inputs.qmk}/util/nix";
|
|
# overrides = poetry2nix.overrides.withDefaults (self: super: {
|
|
# qmk = super.qmk.overridePythonAttrs (old: {
|
|
# # Allow QMK CLI to run "bin/qmk" as a subprocess (the wrapper changes
|
|
# # $PATH and breaks these invocations).
|
|
# dontWrapPythonPrograms = true;
|
|
# });
|
|
# });
|
|
# };
|
|
|
|
v-usb = pkgs.stdenv.mkDerivation {
|
|
pname = "v-usb";
|
|
version = "unstable";
|
|
|
|
src = pkgs.fetchFromGitHub {
|
|
owner = "qmk";
|
|
repo = "v-usb";
|
|
rev = "819dbc1e5d5926b17e27e00ca6d3d2988adae04e";
|
|
hash = "sha256-9w70OMxUoltjuxuIyzrO6g0P45iTWOt+Yh95WI5H6B4=";
|
|
};
|
|
|
|
phases = [
|
|
"unpackPhase"
|
|
"installPhase"
|
|
];
|
|
|
|
installPhase = ''
|
|
mkdir -p $out/{include/usbdrv,src}
|
|
find ./usbdrv -name '*.c' -exec cp {} $out/src \;
|
|
find ./usbdrv \( -name '*.h' -or -name '*.inc' \) -exec cp {} $out/include/usbdrv \;
|
|
'';
|
|
};
|
|
in {
|
|
devShells.qmk = pkgs.mkShell {
|
|
name = "qmk-devshell";
|
|
|
|
buildInputs = with pkgs; [
|
|
clang-tools
|
|
dfu-programmer
|
|
dfu-util
|
|
diffutils
|
|
git
|
|
# pythonEnv
|
|
bootloadHID
|
|
qmk
|
|
avrBinutils
|
|
avrGcc
|
|
avrlibc
|
|
avrdude
|
|
gcc-arm-embedded
|
|
teensy-loader-cli
|
|
];
|
|
|
|
env.AVR_CFLAGS = lib.concatStringsSep " " avr_incflags;
|
|
env.AVR_ASFLAGS = lib.concatStringsSep " " avr_incflags;
|
|
shellHook = ''
|
|
# Prevent the avr-gcc wrapper from picking up host GCC flags
|
|
# like -iframework, which is problematic on Darwin
|
|
unset NIX_CFLAGS_COMPILE_FOR_TARGET
|
|
'';
|
|
};
|
|
|
|
packages.v-usb = v-usb;
|
|
packages.qmk = pkgs.stdenv.mkDerivation {
|
|
name = "qmk-firmware";
|
|
|
|
src = inputs.qmk;
|
|
|
|
env.V_USB = pkgs.fetchFromGitHub {
|
|
owner = "qmk";
|
|
repo = "v-usb";
|
|
rev = "819dbc1e5d5926b17e27e00ca6d3d2988adae04e";
|
|
hash = "sha256-9w70OMxUoltjuxuIyzrO6g0P45iTWOt+Yh95WI5H6B4=";
|
|
};
|
|
|
|
configurePhase = ''
|
|
rm -d lib/vusb
|
|
ln -s $V_USB lib/vusb
|
|
|
|
mkdir -p keyboards/mt/split75/keymaps/custom
|
|
cp ${./keymap.c} keyboards/mt/split75/keymaps/custom/keymap.c
|
|
cp ${./rules.mk} keyboards/mt/split75/rules.mk
|
|
cp ${./config.h} keyboards/mt/split75/keymaps/custom/config.h
|
|
'';
|
|
|
|
buildPhase = ''
|
|
qmk setup
|
|
make mt/split75:custom
|
|
'';
|
|
|
|
nativeBuildInputs = with pkgs; [
|
|
clang-tools
|
|
dfu-programmer
|
|
dfu-util
|
|
diffutils
|
|
git
|
|
# pythonEnv
|
|
bootloadHID
|
|
which
|
|
qmk
|
|
v-usb
|
|
avrBinutils
|
|
avrGcc
|
|
avrlibc
|
|
avrdude
|
|
gcc-arm-embedded
|
|
teensy-loader-cli
|
|
];
|
|
AVR_CFLAGS = avr_incflags;
|
|
AVR_ASFLAGS = avr_incflags;
|
|
shellHook = ''
|
|
# Prevent the avr-gcc wrapper from picking up host GCC flags
|
|
# like -iframework, which is problematic on Darwin
|
|
unset NIX_CFLAGS_COMPILE_FOR_TARGET
|
|
'';
|
|
|
|
installPhase = ''
|
|
cp mt_split75_custom.hex $out
|
|
'';
|
|
};
|
|
};
|
|
}
|