forked from sodiboo/niri-flake
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpost-commit
More file actions
executable file
·45 lines (31 loc) · 1.32 KB
/
post-commit
File metadata and controls
executable file
·45 lines (31 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env bash
if [[ ! -e .git/rebase-merge/done ]]; then
# buffer the output of nix eval through a temporary file
# because that way, we can move it to the new place atomically
# vs clearing the file during eval.
# in other words, this is reimplementing sponge(1)
# why not just use sponge? because this runs in CI (which doesn't have sponge)
tmp="$(mktemp)"
# lol yes the docs really do exceed the default call depth limit.
# luckily, this basically only affects my CI and not any users.
export NIX_CONFIG="max-call-depth = 20000"
nix eval --raw "git+file:.?ref=HEAD&shallow=1#lib.internal.docs-markdown" --show-trace > $tmp
# GitHub Actions doesn't seem to have a HEAD ref (???)
if [ $? -ne 0 ]; then
echo "git didn't like the HEAD i gave it; falling back to working directory" >&2
nix eval --raw .#lib.internal.docs-markdown --show-trace > $tmp
fi
mv $tmp docs.md
nix eval --raw --file fetch-refs.nix --show-trace > refs.nix
nix eval --raw .#lib.internal.memo-binds --show-trace > memo-binds.nix
git diff --quiet docs.md refs.nix
if [ $? -ne 0 ]; then
git add docs.md
git add memo-binds.nix
git add refs.nix
git commit --no-verify --amend --no-edit
# restore the docs from the working directory if you commit with unstaged changes
nix eval --no-warn-dirty --raw .#lib.internal.docs-markdown --show-trace > $tmp
mv $tmp docs.md
fi
fi