-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbuild.sh
executable file
·45 lines (31 loc) · 1.04 KB
/
build.sh
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
set -e
target=$(jq -er '.targetDrv' <<< "$JSON")
declare -r target
declare -a uncached
function calc_uncached() {
echo "::group::Calculate Uncached Builds"
set -x
#shellcheck disable=SC2086
mapfile -t uncached < <(nix-store --realise --dry-run $target 2>&1 1>/dev/null | sed '/paths will be fetched/,$ d' | grep '/nix/store/.*\.drv$')
# filter out builds that are always run locally, and thus, not cached
#shellcheck disable=SC2068
mapfile -t uncached < <(nix show-derivation ${uncached[@]} | jq -r '.| to_entries[] | select(.value|.env.preferLocalBuild != "1") | .key')
set +x
echo "::debug::uncached paths: ${uncached[*]}"
echo "uncached=${uncached[*]}" >> "$GITHUB_OUTPUT"
echo "::endgroup::"
}
#shellcheck disable=SC2068
function build() {
echo "::group::Nix Build"
if [[ -n ${uncached[*]} ]]; then
#shellcheck disable=SC2086
nix-build --eval-store auto --store "$BUILDER" "$target"
else
echo "Everything already cached, nothing to build."
fi
echo "::endgroup::"
}
calc_uncached
build