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