Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1# shellcheck disable=SC2154,SC2034,SC2016
2
3addHarepath() {
4 local -r thirdparty="${1-}/src/hare/third-party"
5 if [[ -d "$thirdparty" ]]; then
6 addToSearchPath HAREPATH "$thirdparty"
7 fi
8}
9
10# Hare's stdlib should come after its third party libs, since the latter may
11# expand or shadow the former.
12readonly hareSetStdlibPhase='
13addToSearchPath HAREPATH "@hare_stdlib@"
14'
15readonly hareInfoPhase='
16echoCmd "HARECACHE" "$HARECACHE"
17echoCmd "HAREPATH" "$HAREPATH"
18echoCmd "hare" "$(command -v hare)"
19echoCmd "hare-native" "$(command -v hare-native)"
20'
21appendToVar prePhases hareSetStdlibPhase hareInfoPhase
22
23readonly hare_unconditional_flags="@hare_unconditional_flags@"
24case "${hareBuildType:-"release"}" in
25"release") export NIX_HAREFLAGS="-R $hare_unconditional_flags" ;;
26"debug") export NIX_HAREFLAGS="$hare_unconditional_flags" ;;
27*)
28 printf -- 'Invalid hareBuildType: "%s"\n' "${hareBuildType-}"
29 exit 1
30 ;;
31esac
32
33HARECACHE="$(mktemp -d)"
34export HARECACHE
35
36addEnvHooks "$hostOffset" addHarepath