mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 06:53:01 +00:00
workflows/check-nix-format: show command to fix
When some files are not formatted properly, this shows how people can
fix the problem.
This notably uses the shell.nix introduced in the parent commit to
ensure that the nixfmt version matches what CI expects.
(cherry picked from commit 53b517c685
)
This commit is contained in:
parent
7d5716c800
commit
34c5271739
10
.github/workflows/check-nix-format.yml
vendored
10
.github/workflows/check-nix-format.yml
vendored
@ -56,6 +56,7 @@ jobs:
|
||||
NIX_FMT_PATHS_BUILD_SUPPORT_PHP: pkgs/build-support/php
|
||||
# Iterate over all environment variables beginning with NIX_FMT_PATHS_.
|
||||
run: |
|
||||
unformattedPaths=()
|
||||
for env_var in "${!NIX_FMT_PATHS_@}"; do
|
||||
readarray -t paths <<< "${!env_var}"
|
||||
if [[ "${paths[*]}" == "" ]]; then
|
||||
@ -64,7 +65,12 @@ jobs:
|
||||
fi
|
||||
echo "Checking paths: ${paths[@]}"
|
||||
if ! nixfmt --check "${paths[@]}"; then
|
||||
echo "Error: nixfmt failed."
|
||||
exit 1
|
||||
unformattedPaths+=("${paths[@]}")
|
||||
fi
|
||||
done
|
||||
if (( "${#unformattedPaths[@]}" > 0 )); then
|
||||
echo "Some required Nix files are not properly formatted"
|
||||
echo "Please run the following in \`nix-shell\`:"
|
||||
echo "nixfmt ${unformattedPaths[*]@Q}"
|
||||
exit 1
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user