From a486a8e2fa5311422ec5dd295c4a3bd746f56e70 Mon Sep 17 00:00:00 2001 From: Kamen Mladenov Date: Thu, 27 Feb 2025 10:28:28 +0200 Subject: feat: Add script for formatting all rust files in a directory This is meant to be used in our codebase, especially in CI pipelines --- rust-format-all.nix | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 rust-format-all.nix (limited to 'rust-format-all.nix') diff --git a/rust-format-all.nix b/rust-format-all.nix new file mode 100644 index 0000000..710f1ef --- /dev/null +++ b/rust-format-all.nix @@ -0,0 +1,20 @@ +{ writeShellApplication +, rustfmt +, +}: +writeShellApplication { + name = "rustfmt_all"; + + runtimeInputs = [ rustfmt ]; + + text = '' + # Using rustfmt instead of cargo fmt, because the latter doesn't support proc-macro crates + # Additionally, instead of emitting an error, it will "hang", waiting for input + while read -r file + do + rustfmt --edition 2021 -v "$@" "$file" || exit $? + done <