1
Fork 0
mirror of https://github.com/RGBCube/alejandra synced 2025-07-30 12:07:46 +00:00

feat: more robust pre-commit hook

This commit is contained in:
Kevin Amado 2022-05-06 16:06:11 -06:00
parent 73af6ae9b5
commit 131c177c90
2 changed files with 26 additions and 3 deletions

View file

@ -1,3 +1,26 @@
#! /usr/bin/env sh
nix run github:kamadorueda/alejandra -- -q "$@"
set -eux
if ! command -v nix-build; then
echo 'ERROR: this pre-commit hook requires "nix-build" to be installed first'
exit 1
fi
if !command -v nix-instantiate; then
echo 'ERROR: this pre-commit hook requires "nix-instantiate" to be installed first'
exit 1
fi
echo INFO: computing current system
system="$(nix-instantiate --eval --expr builtins.currentSystem)"
echo INFO: building Alejandra
nix-build \
--attr ${system} \
--out-link result-alejandra \
https://github.com/kamadorueda/alejandra/tarball/1.2.0
echo INFO: running Alejandra:
result-alejandra/bin/alejandra -- -q "${@}"