diff options
| author | Kamen Mladenov <kamen@syndamia.com> | 2025-02-27 10:28:28 +0200 |
|---|---|---|
| committer | Kamen Mladenov <kamen@syndamia.com> | 2025-02-27 10:28:55 +0200 |
| commit | 26d27f0063e9738c52eb39508a60decad8c820bd (patch) | |
| tree | 7834ec529958ed4df4be4ad0b6a22129a87bdd46 /rust-format-all.nix | |
| parent | 7cae7ec66ab2204572911b3f47342a703254f4e9 (diff) | |
| download | zkVMs-benchmarks-26d27f0063e9738c52eb39508a60decad8c820bd.tar zkVMs-benchmarks-26d27f0063e9738c52eb39508a60decad8c820bd.tar.gz zkVMs-benchmarks-26d27f0063e9738c52eb39508a60decad8c820bd.zip | |
feat: Add script for formatting all rust files in a directory
This is meant to be used in our codebase, especially in CI pipelines
Diffstat (limited to 'rust-format-all.nix')
| -rw-r--r-- | rust-format-all.nix | 20 |
1 files changed, 20 insertions, 0 deletions
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 <<EOF + $(find . -type f -name "*.rs" -not -path "*target*") + EOF + ''; +} |
