aboutsummaryrefslogtreecommitdiff
path: root/scripts/assert-nixfmt.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/assert-nixfmt.sh')
-rwxr-xr-xscripts/assert-nixfmt.sh16
1 files changed, 16 insertions, 0 deletions
diff --git a/scripts/assert-nixfmt.sh b/scripts/assert-nixfmt.sh
new file mode 100755
index 0000000..7a68fa9
--- /dev/null
+++ b/scripts/assert-nixfmt.sh
@@ -0,0 +1,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 %"