aboutsummaryrefslogtreecommitdiff
path: root/rust-format-all.nix
blob: 90b4e781abd77b0620a89f4bf8103d037a3ad5ec (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{ 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
  '';
}