aboutsummaryrefslogtreecommitdiff
path: root/scripts/assert-nixfmt.sh
blob: 7a68fa943b385e5903e1fa2e6fb033f75c83fb9a (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/env bash
set -Eeuo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")"
cd ../

format() {
  nix_file="${1}"
  diff <(nixfmt < "${nix_file}") "${nix_file}" || {
    echo "The file '${nix_file}' is unformatted. To fix it, run:"
    echo "  nixfmt ${nix_file}"
    exit 1
  }
}
export -f format

find . -type f -name '*.nix' -print0 | xargs -0 -I% bash -c "format %"