From 4a01d4e4fc3c5d14cc9e9d248e51cf5f937ee1b0 Mon Sep 17 00:00:00 2001 From: Richard Goulter Date: Tue, 11 Jun 2024 19:06:52 +0700 Subject: [PATCH 1/2] flake.nix: reduce copy-paste for qmk packages --- flake.nix | 67 +++++++++++++++++++++++++------------------------------ 1 file changed, 31 insertions(+), 36 deletions(-) diff --git a/flake.nix b/flake.nix index 25dd3d5..6f36e2a 100644 --- a/flake.nix +++ b/flake.nix @@ -98,6 +98,7 @@ perSystem = { config, + lib, pkgs, system, ... @@ -170,43 +171,37 @@ bootloaders = import ./nix/pkgs/bootloaders { inherit pkgs; }; - qmk = pkgs.callPackage ./nix/pkgs/qmk {}; + qmk = + lib.attrsets.mapAttrs' (name: p: lib.attrsets.nameValuePair "qmk-${name}" p) + (lib.attrsets.filterAttrs (_: p: lib.attrsets.isDerivation p) (pkgs.callPackage ./nix/pkgs/qmk {})); pcb = pkgs.callPackage ./pcb {}; - in { - bootloader-stm32f103-stm32duino = bootloaders.stm32duino.stm32f103; - bootloader-stm32f401-tinyuf2 = bootloaders.tinyuf2.stm32f401; - bootloader-stm32f411-tinyuf2 = bootloaders.tinyuf2.stm32f411; - qmk-bm40hsrgb-rgoulter = qmk.bm40hsrgb-rgoulter; - qmk-minif4_36-rev2021_5-blackpill_f401-rgoulter = qmk.minif4_36-rev2021_5-blackpill_f401-rgoulter; - qmk-pico42-rgoulter-basic = qmk.pico42-rgoulter-basic; - qmk-pico42-manna-harbour_miryoku = qmk.pico42-manna-harbour_miryoku; - qmk-pico42-vial = qmk.pico42-vial; - qmk-pykey40-lite-rgoulter = qmk.pykey40-lite-rgoulter; - qmk-pykey40-lite-rgoulter-pinkieoutercolumn = qmk.pykey40-lite-rgoulter-pinkieoutercolumn; - qmk-pykey40-lite-vial = qmk.pykey40-lite-vial; - qmk-x_2-rev2021_1-bluepill = qmk.x_2-rev2021_1-bluepill; - qmk-x_2-rev2021_1-blackpill_f401 = qmk.x_2-rev2021_1-blackpill_f401; - - pcb-keyboard-100x100-minif4-dual-rgb-reversible = pcb.keyboard-100x100-minif4-dual-rgb-reversible; - pcb-keyboard-ch552-36-lhs = pcb.keyboard-ch552-36-lhs; - pcb-keyboard-ch552-36-rhs = pcb.keyboard-ch552-36-rhs; - pcb-keyboard-ch552-44 = pcb.keyboard-ch552-44; - pcb-keyboard-ch552-48 = pcb.keyboard-ch552-48; - pcb-keyboard-ch552-48-lpr = pcb.keyboard-ch552-48-lpr; - pcb-keyboard-pico42 = pcb.keyboard-pico42; - pcb-keyboard-pykey40-hsrgb = pcb.keyboard-pykey40-hsrgb; - pcb-keyboard-pykey40-lite = pcb.keyboard-pykey40-lite; - pcb-keyboard-x2-lumberjack-arm-hsrgb = pcb.keyboard-x2-lumberjack-arm-hsrgb; - pcb-keyboard-x2-lumberjack-arm = pcb.keyboard-x2-lumberjack-arm; - - uf2conv = pkgs.callPackage ./nix/pkgs/uf2conv {}; - wchisp = pkgs.callPackage ./nix/pkgs/wchisp {}; - - docker-kibot-kicad = import ./scripts/docker-kibot.nix { - pkgs = pkgs; - tag = "kicad-7"; - }; - }; + in + { + bootloader-stm32f103-stm32duino = bootloaders.stm32duino.stm32f103; + bootloader-stm32f401-tinyuf2 = bootloaders.tinyuf2.stm32f401; + bootloader-stm32f411-tinyuf2 = bootloaders.tinyuf2.stm32f411; + + pcb-keyboard-100x100-minif4-dual-rgb-reversible = pcb.keyboard-100x100-minif4-dual-rgb-reversible; + pcb-keyboard-ch552-36-lhs = pcb.keyboard-ch552-36-lhs; + pcb-keyboard-ch552-36-rhs = pcb.keyboard-ch552-36-rhs; + pcb-keyboard-ch552-44 = pcb.keyboard-ch552-44; + pcb-keyboard-ch552-48 = pcb.keyboard-ch552-48; + pcb-keyboard-ch552-48-lpr = pcb.keyboard-ch552-48-lpr; + pcb-keyboard-pico42 = pcb.keyboard-pico42; + pcb-keyboard-pykey40-hsrgb = pcb.keyboard-pykey40-hsrgb; + pcb-keyboard-pykey40-lite = pcb.keyboard-pykey40-lite; + pcb-keyboard-x2-lumberjack-arm-hsrgb = pcb.keyboard-x2-lumberjack-arm-hsrgb; + pcb-keyboard-x2-lumberjack-arm = pcb.keyboard-x2-lumberjack-arm; + + uf2conv = pkgs.callPackage ./nix/pkgs/uf2conv {}; + wchisp = pkgs.callPackage ./nix/pkgs/wchisp {}; + + docker-kibot-kicad = import ./scripts/docker-kibot.nix { + pkgs = pkgs; + tag = "kicad-7"; + }; + } + // qmk; treefmt = import ./treefmt.nix; }; From ce1b76f00d0642a90ce2cf47aabf03b3b5ef0954 Mon Sep 17 00:00:00 2001 From: Richard Goulter Date: Tue, 11 Jun 2024 19:09:21 +0700 Subject: [PATCH 2/2] flake.nix: factor out copy-paste of pcb packages --- flake.nix | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/flake.nix b/flake.nix index 6f36e2a..c43271f 100644 --- a/flake.nix +++ b/flake.nix @@ -174,25 +174,15 @@ qmk = lib.attrsets.mapAttrs' (name: p: lib.attrsets.nameValuePair "qmk-${name}" p) (lib.attrsets.filterAttrs (_: p: lib.attrsets.isDerivation p) (pkgs.callPackage ./nix/pkgs/qmk {})); - pcb = pkgs.callPackage ./pcb {}; + pcb = + lib.attrsets.mapAttrs' (name: p: lib.attrsets.nameValuePair "pcb-${name}" p) + (lib.attrsets.filterAttrs (_: p: lib.attrsets.isDerivation p) (pkgs.callPackage ./pcb {})); in { bootloader-stm32f103-stm32duino = bootloaders.stm32duino.stm32f103; bootloader-stm32f401-tinyuf2 = bootloaders.tinyuf2.stm32f401; bootloader-stm32f411-tinyuf2 = bootloaders.tinyuf2.stm32f411; - pcb-keyboard-100x100-minif4-dual-rgb-reversible = pcb.keyboard-100x100-minif4-dual-rgb-reversible; - pcb-keyboard-ch552-36-lhs = pcb.keyboard-ch552-36-lhs; - pcb-keyboard-ch552-36-rhs = pcb.keyboard-ch552-36-rhs; - pcb-keyboard-ch552-44 = pcb.keyboard-ch552-44; - pcb-keyboard-ch552-48 = pcb.keyboard-ch552-48; - pcb-keyboard-ch552-48-lpr = pcb.keyboard-ch552-48-lpr; - pcb-keyboard-pico42 = pcb.keyboard-pico42; - pcb-keyboard-pykey40-hsrgb = pcb.keyboard-pykey40-hsrgb; - pcb-keyboard-pykey40-lite = pcb.keyboard-pykey40-lite; - pcb-keyboard-x2-lumberjack-arm-hsrgb = pcb.keyboard-x2-lumberjack-arm-hsrgb; - pcb-keyboard-x2-lumberjack-arm = pcb.keyboard-x2-lumberjack-arm; - uf2conv = pkgs.callPackage ./nix/pkgs/uf2conv {}; wchisp = pkgs.callPackage ./nix/pkgs/wchisp {}; @@ -201,6 +191,7 @@ tag = "kicad-7"; }; } + // pcb // qmk; treefmt = import ./treefmt.nix;