Skip to content

Commit 131c177

Browse files
committed
feat: more robust pre-commit hook
1 parent 73af6ae commit 131c177

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

.pre-commit-entry.sh

+24-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
11
#! /usr/bin/env sh
22

3-
nix run github:kamadorueda/alejandra -- -q "$@"
3+
set -eux
4+
5+
if ! command -v nix-build; then
6+
echo 'ERROR: this pre-commit hook requires "nix-build" to be installed first'
7+
exit 1
8+
fi
9+
10+
if !command -v nix-instantiate; then
11+
echo 'ERROR: this pre-commit hook requires "nix-instantiate" to be installed first'
12+
exit 1
13+
fi
14+
15+
echo INFO: computing current system
16+
system="$(nix-instantiate --eval --expr builtins.currentSystem)"
17+
18+
echo INFO: building Alejandra
19+
20+
nix-build \
21+
--attr ${system} \
22+
--out-link result-alejandra \
23+
https://github.com/kamadorueda/alejandra/tarball/1.2.0
24+
25+
echo INFO: running Alejandra:
26+
result-alejandra/bin/alejandra -- -q "${@}"

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,7 @@ Thank you ❤️
269269

270270
- [Kevin Amado](https://github.com/kamadorueda) ~
271271
[Email](mailto:[email protected]),
272-
[Patreon](https://www.patreon.com/kamadorueda),
273-
@kamadorueda:[matrix.org](https://matrix.org/).
272+
[Patreon](https://www.patreon.com/kamadorueda).
274273
- [Thomas Bereknyei](https://github.com/tomberek).
275274
- [Piegames](https://github.com/piegamesde).
276275
- [Joachim Ernst](https://github.com/0x4A6F).
@@ -282,6 +281,7 @@ Thank you ❤️
282281
- [Rehno Lindeque](https://github.com/rehno-lindeque).
283282
- [Jörg Thalheim](https://github.com/Mic92).
284283
- [Vincent Ambo](https://github.com/tazjin).
284+
- [Loïc Reynier](https://github.com/loicreynier).
285285
- [Mr Hedgehog](https://github.com/ModdedGamers).
286286
- [Tristan Maat](https://github.com/TLATER).
287287
- [Norbert Melzer](https://github.com/NobbZ).

0 commit comments

Comments
 (0)