blob: f6868e6faac56f0d380e300e0cb055bd5e48a755 (
plain) (
blame)
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
46
47
48
49
50
51
52
53
54
55
56
|
# Inspired by python/wrapper.nix
# Wrapper around wrapLuaProgramsIn, below. The $luaPath
# variable is passed in from the buildLuarocksPackage function.
set -e
source @lua@/nix-support/utils.sh
wrapLuaPrograms() {
wrapLuaProgramsIn "$out/bin" "$out $luaPath"
}
# with an executable shell script which will set some environment variables
# and then call into the original binary (which has been given a .wrapped suffix).
# luaPath is a list of directories
wrapLuaProgramsIn() {
local dir="$1"
local luaPath="$2"
local f
buildLuaPath "$luaPath"
if [ ! -d "$dir" ]; then
nix_debug "$dir not a directory"
return
fi
nix_debug "wrapping programs in [$dir]"
# Find all regular files in the output directory that are executable.
find "$dir" -type f -perm -0100 -print0 | while read -d "" f; do
# Rewrite "#! .../env lua" to "#! /nix/store/.../lua".
# Lua to use besides one with this hook anyway.
if head -n1 "$f" | grep -q '#!.*/env.*\(lua\)'; then
sed -i "$f" -e "1 s^.*/env[ ]*\(lua\)[^ ]*^#! @executable@^"
fi
# wrapProgram creates the executable shell script described
# above. The script will set LUA_(C)PATH and PATH variables!
# (see pkgs/build-support/setup-hooks/make-wrapper.sh)
local -a wrap_args=("$f"
--prefix PATH ':' "$program_PATH"
--prefix LUA_PATH ';' "$LUA_PATH"
--prefix LUA_CPATH ';' "$LUA_CPATH"
)
# Add any additional arguments provided by makeWrapperArgs
# argument to buildLuaPackage.
# makeWrapperArgs
local -a user_args="($makeWrapperArgs)"
local -a wrapProgramArgs=("${wrap_args[@]}" "${user_args[@]}")
# see setup-hooks/make-wrapper.sh
wrapProgram "${wrapProgramArgs[@]}"
done
}
|