python3Packages.orjson: Disable failing tests on 32 bit
[NixPkgs.git] / pkgs / development / interpreters / lua-5 / hooks / setup-hook.sh
blob1c445b82afdedac84ce4969e4fe9c40e06f68b5a
1 # set -e
3 nix_print() {
4 if [ ${NIX_DEBUG:-0} -ge $1 ]; then
5 echo "$2"
6 fi
9 nix_debug() {
10 nix_print 3 "$1"
13 addToLuaSearchPathWithCustomDelimiter() {
14 local varName="$1"
15 local absPattern="$2"
16 # delete longest match starting from the lua placeholder '?'
17 local topDir="${absPattern%%\?*}"
19 # export only if the folder exists else LUA_PATH/LUA_CPATH grow too large
20 if [[ ! -d "$topDir" ]]; then return; fi
22 # export only if we haven't already got this dir in the search path
23 if [[ ${!varName-} == *"$absPattern"* ]]; then return; fi
25 export "${varName}=${!varName:+${!varName};}${absPattern}"
28 addToLuaPath() {
29 local dir="$1"
31 if [[ ! -d "$dir" ]]; then
32 nix_debug "$dir not a directory abort"
33 return 0
35 cd "$dir"
36 for pattern in @luapathsearchpaths@; do
37 addToLuaSearchPathWithCustomDelimiter LUA_PATH "$PWD/$pattern"
38 done
40 # LUA_CPATH
41 for pattern in @luacpathsearchpaths@; do
42 addToLuaSearchPathWithCustomDelimiter LUA_CPATH "$PWD/$pattern"
43 done
44 cd - >/dev/null
47 addEnvHooks "$hostOffset" addToLuaPath