fix(nix): check the KDE formatting file by file with the flake's nightly rustfmt

The kfde fmt check ran `cargo fmt -p ...` and failed with `failed to resolve
mod windows` for komorebic and komorebi-client: rustfmt follows the
cfg_select! branches of the shared entry files into files the KDE source does
not have. It is now a runCommand running tools/format-all --tree kde with the
rustfmt of the flake's own nightly (fmtToolchain, the toolchain craneLibFmt
already used) over komorebi-for-kde/**/*.rs and the linux modules of the
shared crates, file by file with skip_children and komorebi-for-kde/rustfmt.toml.
tools/format-all now takes the rustfmt of the root dev shell first (the same
pinned nightly) before a nightly on PATH, because a different nightly may
format differently or not follow cfg_select.

Verified: with the rustfmt of that very nightly (rust-overlay 19ecdd08,
rustfmt 1.11.0-nightly 2026-10-27, built from the flake's pins)
tools/format-all --check passes for kde, mac and windows on this tree, so the
only failure was the module resolution, not different formatting. The nix
attribute evaluates; not built.
This commit is contained in:
LGUG2Z committed 2026-11-05 15:03:27 -08:00
1 parent 87f34317d0
commit 2544012c2e
2 files changed
+27 -13

No files matched your search

+14 -6
View File
@@ -53,9 +53,8 @@
toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
craneLib = (crane.mkLib pkgs).overrideToolchain toolchain;
# rustfmt.toml uses options only a nightly rustfmt knows
craneLibFmt = (crane.mkLib pkgs).overrideToolchain (
pkgs.rust-bin.nightly.latest.minimal.override { extensions = [ "rustfmt" ]; }
);
fmtToolchain = pkgs.rust-bin.nightly.latest.minimal.override { extensions = [ "rustfmt" ]; };
craneLibFmt = (crane.mkLib pkgs).overrideToolchain fmtToolchain;
# the repository, cut down to this workspace and the crates of the root workspace it depends
# on by path (komorebi-layouts and what they depend on, komorebi-themes), with the root
@@ -208,6 +207,7 @@
inherit
craneLib
craneLibFmt
fmtToolchain
src
real
workspaceArgs
@@ -339,9 +339,17 @@
};
checks = {
komorebi-workspace-fmt = build.craneLibFmt.cargoFmt (
build.workspaceArgs // { inherit (build) src; cargoExtraArgs = build.packages; }
);
# tools/format-all --tree kde: the nightly rustfmt over the files of this tree, file by file. `cargo fmt`
# followed `mod windows;` of the shared entry files into files this source does not have.
komorebi-workspace-fmt =
pkgs.runCommand "komorebi-workspace-fmt"
{
nativeBuildInputs = [ build.fmtToolchain ];
}
''
RUSTFMT=rustfmt bash ${builtins.path { path = repoRoot + "/tools/format-all"; name = "format-all"; }} --check --tree kde --root ${build.real}
touch $out
'';
komorebi-workspace-clippy = build.craneLib.cargoClippy (
build.individualCrateArgs
+13 -7
View File
@@ -15,10 +15,13 @@
# shared crates belong to the kde and mac trees
# mac komorebi-for-mac/**/*.rs and the macos modules of the shared crates, with
# komorebi-for-mac/rustfmt.toml
# kde `cargo fmt -p <the kde packages>`, as komorebi-for-kde/flake.nix does
# The nightly rustfmt is $RUSTFMT if set, else `rustfmt` if that is a nightly, else the one of the
# dev shell of the root flake (`nix develop`), which is the one the nix checks use (a nightly of the
# pinned rust-overlay; another nightly may format a little differently).
# kde komorebi-for-kde/**/*.rs and the linux modules of the shared crates, with
# komorebi-for-kde/rustfmt.toml (the same file-by-file invocation as the mac one; the nix
# check runs this script with the rustfmt of the flake's own nightly, fmtToolchain)
# The nightly rustfmt is $RUSTFMT if set, else the one of the dev shell of the root flake (`nix develop`),
# which is the nightly of the pinned rust-overlay that the nix checks use (the flake of each tree pins the
# same revision; another nightly may format differently and may not follow cfg_select), else a nightly
# `rustfmt` on PATH.
set -uo pipefail
orig_args=("$@")
@@ -39,10 +42,12 @@ done
root=$(cd "$root" && pwd)
if [ -z "${RUSTFMT:-}" ]; then
if rustfmt --version 2>/dev/null | grep -q nightly; then
if [ -n "${FORMAT_ALL_IN_SHELL:-}" ]; then
RUSTFMT=rustfmt
elif [ -z "${FORMAT_ALL_IN_SHELL:-}" ] && command -v nix >/dev/null; then
elif command -v nix >/dev/null; then
FORMAT_ALL_IN_SHELL=1 exec nix develop "$root" --command "$0" "${orig_args[@]}" --root "$root"
elif rustfmt --version 2>/dev/null | grep -q nightly; then
RUSTFMT=rustfmt
else
echo "format-all: no nightly rustfmt (set RUSTFMT)" >&2; exit 2
fi
@@ -77,6 +82,7 @@ if [ "$tree" = mac ] || [ "$tree" = all ]; then
fi
if [ "$tree" = kde ] || [ "$tree" = all ]; then
echo "format-all: kde"
cargo fmt -p komorebi -p komorebi-linux -p komorebic -p komorebi-client -p komorebi-hotkeys -- $flag || status=1
{ rs_files | grep '^komorebi-for-kde/'; rs_files | grep -E "^(komorebic/src/linux|komorebic/tests/linux_|komorebi-client/src/linux\.rs|komorebi-client/tests/linux_)"; } \
| run_rustfmt komorebi-for-kde/rustfmt.toml || status=1
fi
exit $status