3 declare -gA luaPathsSeen
=()
5 # shellcheck disable=SC2164,SC2041
7 if [ ${NIX_DEBUG:-0} -ge $1 ]; then
16 addToLuaSearchPathWithCustomDelimiter
() {
20 # export only if we haven't already got this dir in the search path
21 if [[ ${!varName-} == *"$absPattern"* ]]; then return; fi
23 # if the path variable has not yet been set, initialize it to ";;"
24 # this is a magic value that will be replaced by the default,
25 # allowing relative modules to be used even when there are system modules.
26 if [[ ! -v "${varName}" ]]; then export "${varName}=;;"; fi
28 # export only if the folder contains lua files
31 local adjustedPattern
="${absPattern/\?/\*\*\/\*}"
32 for _file
in $adjustedPattern; do
33 export "${varName}=${!varName:+${!varName};}${absPattern}"
40 # used in setup Hooks to load LUA_PATH and LUA_CPATH
49 if [ ! -d "$dir" ]; then
50 nix_debug
"$dir not a directory abort"
54 for pattern
in @luapathsearchpaths@
; do
55 addToLuaSearchPathWithCustomDelimiter LUA_PATH
"$PWD/$pattern"
59 for pattern
in @luacpathsearchpaths@
; do
60 addToLuaSearchPathWithCustomDelimiter LUA_CPATH
"$PWD/$pattern"
69 echo "_addToLuaPath called for dir $dir"
71 if [[ ! -d "$dir" ]]; then
72 nix_debug
"$dir not a directory abort"
77 # if [ -n "${pythonPathsSeen[$dir]}" ]; then return; fi
78 if [[ -n "${luaPathsSeen[$dir]:-}" ]]; then
79 # if [ -n "${luaPathsSeen[$dir]}" ]; then
80 echo "$dir already parsed"
84 luaPathsSeen
["$dir"]=true
86 # shellcheck disable=SC2164
88 for pattern
in @luapathsearchpaths@
; do
89 addToLuaSearchPathWithCustomDelimiter LUA_PATH
"$PWD/$pattern"
93 for pattern
in @luacpathsearchpaths@
; do
94 addToLuaSearchPathWithCustomDelimiter LUA_CPATH
"$PWD/$pattern"
99 addToSearchPath program_PATH
"$dir"/bin
101 # Inspect the propagated inputs (if they exist) and recur on them.
102 local prop
="$dir/nix-support/propagated-build-inputs"
103 if [ -e "$prop" ]; then
105 for new_path
in $
(cat $prop); do
106 echo "newpath: $new_path"
107 _addToLuaPath
"$new_path"
113 # Builds environment variables like LUA_PATH and PATH walking through closure
119 echo "BUILD_LUA_PATH"
122 # # Create an empty table of paths (see doc on loadFromPropagatedInputs
123 # # for how this is used). Build up the program_PATH and program_LUA_PATH
125 # declare -gA luaPathsSeen=()
126 # # shellcheck disable=SC2034
128 luaPathsSeen
["@lua@"]=1
129 # addToSearchPath program_PATH @lua@/bin
130 for path
in $luaPath; do
131 _addToLuaPath
"$path"