diff options
| author | Chris Wells <chris@mathematicaster.org> | 2025-10-21 10:38:26 -0500 |
|---|---|---|
| committer | Chris Wells <chris@mathematicaster.org> | 2025-10-21 10:38:26 -0500 |
| commit | 7aa390883104725c64c65d20a0713cfcd654f637 (patch) | |
| tree | a3a33e5423e9136ad064b48aee0e41966329c1f0 /modules | |
| parent | e3343bc80dc54416d4e8ee6a60a8e92b630810de (diff) | |
| download | fw-manager-7aa390883104725c64c65d20a0713cfcd654f637.tar fw-manager-7aa390883104725c64c65d20a0713cfcd654f637.tar.gz fw-manager-7aa390883104725c64c65d20a0713cfcd654f637.tar.bz2 fw-manager-7aa390883104725c64c65d20a0713cfcd654f637.tar.lz fw-manager-7aa390883104725c64c65d20a0713cfcd654f637.tar.xz fw-manager-7aa390883104725c64c65d20a0713cfcd654f637.tar.zst fw-manager-7aa390883104725c64c65d20a0713cfcd654f637.zip | |
More correct dfu-util flash script + rearranged personal devices
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/default.nix | 2 | ||||
| -rw-r--r-- | modules/klipper.nix | 42 | ||||
| -rw-r--r-- | modules/pinecil.nix | 10 | ||||
| -rw-r--r-- | modules/qmk.nix | 32 |
4 files changed, 69 insertions, 17 deletions
diff --git a/modules/default.nix b/modules/default.nix index dea6fb3..fbed630 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -48,6 +48,8 @@ in { }) ./qmk.nix + ./pinecil.nix + ./klipper.nix ]; }; diff --git a/modules/klipper.nix b/modules/klipper.nix new file mode 100644 index 0000000..2782bcd --- /dev/null +++ b/modules/klipper.nix @@ -0,0 +1,42 @@ +{ + lib, + pkgs, + config, + ... +}: +let + inherit (lib) mkOption mkIf mkPackageOption types; +in { + options = { + type = mkOption { + type = types.enum [ "klipper" ]; + }; + + klipper = { + klipper-firmware = mkPackageOption pkgs "klipper-firmware" {}; + + mcu = mkOption { + type = types.str; + }; + + firmwareConfig = mkOption { + type = types.path; + }; + + build = { + bin = mkOption { + type = types.path; + default = "${config.klipper.klipper-firmware.override { + inherit (config.klipper) mcu firmwareConfig; + }}/klipper.bin"; + }; + flash = mkOption { + type = types.functionTo <| types.either types.str types.package; + }; + }; + }; + }; + + config = mkIf (config.type == "klipper") { + }; +} diff --git a/modules/pinecil.nix b/modules/pinecil.nix index d59c37d..137de94 100644 --- a/modules/pinecil.nix +++ b/modules/pinecil.nix @@ -2,7 +2,9 @@ inherit (lib) mkOption mkPackageOption mkIf types; in { options = { - type = types.enum [ "pinecil" ]; + type = mkOption { + type = types.enum [ "pinecil" ]; + }; pinecil = { version = mkOption { @@ -36,7 +38,7 @@ in { '' else '' cp ${iron}/Pinecilv2_EN.bin $out - ''; + '' ); }; @@ -48,10 +50,10 @@ in { build.flash = let flasher = if config.pinecil.version == "v1" then { pkg = config.pinecil.dfu-util; - tool = "dfu-util"; + tool = "dfu-util -D"; } else { pkg = config.pinecil.blisp; - tool = "blisp" + tool = "blisp write -c bl70x --reset"; }; in pkgs.writeShellApplication { name = "flash"; diff --git a/modules/qmk.nix b/modules/qmk.nix index c083b06..3834369 100644 --- a/modules/qmk.nix +++ b/modules/qmk.nix @@ -73,6 +73,8 @@ in { name = "qmk:${config.qmk.keyboard._path}:${config.qmk.keymap.name}"; src = config.qmk.qmk_firmware; + allowSubstitutes = false; + # hardeningDisable = [ "pic" "pie" ]; nativeBuildInputs = [ @@ -81,22 +83,23 @@ in { # dontFixup = true; - preBuild = lib.optionalString (ksrc != null) '' + postPatch = lib.optionalString (ksrc != null) /* bash */ '' mkdir -pv "${config.qmk.keymap._path}" cp -v "${ksrc}"/* "${config.qmk.keymap._path}" ''; - buildPhase = '' - # SKIP_GIT=true BUILD_DIR=build \ - # make "${config.qmk.keyboard._path}:${config.qmk.keymap.name}" - qmk compile \ - --env SKIP_GIT=yes \ - --env BUILD_DIR=build \ - --env SKIP_VERSION=yes \ - --env VERBOSE=true \ - --env ALLOW_WARNINGS=yes \ - --keyboard "${config.qmk.keyboard._path}" \ - --keymap "${config.qmk.keymap.name}" + buildPhase = /* bash */ '' + runHook preBuild + + qmk compile \ + --env SKIP_GIT=yes \ + --env BUILD_DIR=build \ + --env SKIP_VERSION=yes \ + --env VERBOSE=true \ + --keyboard "${config.qmk.keyboard._path}" \ + --keymap "${config.qmk.keymap.name}" + + runHook postBuild ''; installPhase = '' @@ -108,7 +111,10 @@ in { }; }; flash = mkOption { - type = types.functionTo (types.either types.package types.str); + type = types.functionTo <| types.either types.package types.str; + default = hex: '' + "${pkgs.dfu-util}/bin/dfu-util" --alt 0 --dfuse-address 0x08000000:leave -D "${hex}.hex" + ''; }; }; |
