1 # Inspired by python/wrapper.nix
2 # Wrapper around wrapLuaProgramsIn, below. The $luaPath
3 # variable is passed in from the buildLuarocksPackage function.
6 source @lua@
/nix-support
/utils.sh
9 wrapLuaProgramsIn
"$out/bin" "$out $luaPath"
12 # with an executable shell script which will set some environment variables
13 # and then call into the original binary (which has been given a .wrapped suffix).
14 # luaPath is a list of directories
20 buildLuaPath
"$luaPath"
22 if [ ! -d "$dir" ]; then
23 nix_debug
"$dir not a directory"
27 nix_debug
"wrapping programs in [$dir]"
29 # Find all regular files in the output directory that are executable.
30 find "$dir" -type f
-perm -0100 -print0 |
while read -d "" f
; do
31 # Rewrite "#! .../env lua" to "#! /nix/store/.../lua".
32 # Lua to use besides one with this hook anyway.
33 if head -n1 "$f" |
grep -q '#!.*/env.*\(lua\)'; then
34 sed -i "$f" -e "1 s^.*/env[ ]*\(lua\)[^ ]*^#! @executable@^"
37 # wrapProgram creates the executable shell script described
38 # above. The script will set LUA_(C)PATH and PATH variables!
39 # (see pkgs/build-support/setup-hooks/make-wrapper.sh)
40 local -a wrap_args
=("$f"
41 --prefix PATH
':' "$program_PATH"
42 --prefix LUA_PATH
';' "$LUA_PATH"
43 --prefix LUA_CPATH
';' "$LUA_CPATH"
46 # Add any additional arguments provided by makeWrapperArgs
47 # argument to buildLuaPackage.
49 local -a user_args
="($makeWrapperArgs)"
50 local -a wrapProgramArgs
=("${wrap_args[@]}" "${user_args[@]}")
52 # see setup-hooks/make-wrapper.sh
53 wrapProgram
"${wrapProgramArgs[@]}"