From 081e373782cd1a0bf9f9920f114197a7efea074c Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 31 Oct 2026 16:33:09 -0700 Subject: [PATCH] fix(nix): check the macOS formatting with rustfmt over the macOS files The kfm fmt check ran stable `cargo fmt -p ...` on the stubbed workspace source and failed twice: rustfmt follows the `mod windows;` of the shared entry files (komorebi-bar, komorebi-client; their windows modules are not in the macOS source), and the stable rustfmt ignores the nightly options of this tree's rustfmt.toml. The check is now a runCommand: the nightly rustfmt (already in the flake for treefmt) with --edition 2024 (the edition of the macOS manifests; cargo fmt uses it too) and komorebi-for-mac/rustfmt.toml, over komorebi-for-mac/**/*.rs, komorebic/src/macos, komorebi-bar/src/macos and komorebi-client/src/macos.rs. The entry files of the shared crates are not checked; their macos modules are. The macOS code is not clean under it: the next revision formats it. Verified: the command reproduced locally with the nightly rustfmt (11 files differ). The nix attribute is evaluated in the final eval table. Not built. --- komorebi-for-mac/flake.nix | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/komorebi-for-mac/flake.nix b/komorebi-for-mac/flake.nix index 80a2c30c..82634cc6 100644 --- a/komorebi-for-mac/flake.nix +++ b/komorebi-for-mac/flake.nix @@ -256,7 +256,24 @@ checks = { komorebi-workspace-clippy = build.craneLib.cargoClippy build.individualCrateArgs; - komorebi-workspace-fmt = build.craneLib.cargoFmt (build.workspaceArgs // { inherit (build) src; cargoExtraArgs = build.packages; }); + # rustfmt over the macOS files only, with the nightly rustfmt this tree's rustfmt.toml + # needs and the 2024 edition of the manifests. `cargo fmt` would follow the `mod windows;` + # of the shared entry files (komorebi-bar, komorebi-client), which the macOS source does + # not have. The entry files of the shared crates are not checked; their macos modules are. + komorebi-workspace-fmt = + pkgs.runCommand "komorebi-workspace-fmt" + { + nativeBuildInputs = [ nightlyRustfmt ]; + src = build.real; + } + '' + cd $src + files=$( { find komorebi-for-mac -name '*.rs'; \ + find komorebic/src/macos komorebi-bar/src/macos -name '*.rs'; \ + echo komorebi-client/src/macos.rs; } ) + rustfmt --edition 2024 --config-path komorebi-for-mac/rustfmt.toml --check $files + touch $out + ''; komorebi-workspace-toml-fmt = build.craneLib.taploFmt ( build.workspaceArgs