nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at haskell-updates 66 lines 2.1 kB view raw
1# Inspired by python/wrapper.nix 2# Wrapper around wrapLuaProgramsIn, below. The $luaPath 3# variable is passed in from the buildLuarocksPackage function. 4set -e 5 6source @luaBuild@/nix-support/utils.sh 7 8wrapLuaPrograms() { 9 wrapLuaProgramsIn "$out/bin" "$out $luaPath" 10} 11 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 15wrapLuaProgramsIn() { 16 local dir="$1" 17 local luaPath="$2" 18 local f 19 20 buildLuaPath "$luaPath" 21 22 if [ ! -d "$dir" ]; then 23 nix_debug "$dir not a directory" 24 return 25 fi 26 27 nix_debug "wrapping programs in [$dir]" 28 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 if head -n1 "$f" | grep -q '#!.*'; then 32 # Cross-compilation hack: exec '/nix/store/...-lua-.../bin/lua' execute 33 # the host lua 34 substituteInPlace "$f" \ 35 --replace-fail "@luaBuild@" "@luaHost@" 36 # Build platform's Luarocks writes scripts that reference luarocks 37 # itself in them, so we fix these references to reference the host 38 # platform's luarocks. 39 substituteInPlace "$f" \ 40 --replace-fail "@luarocksBuild@" "@luarocksHost@" 41 fi 42 43 # wrapProgram creates the executable shell script described 44 # above. The script will set LUA_(C)PATH and PATH variables! 45 # (see pkgs/build-support/setup-hooks/make-wrapper.sh) 46 local -a wrap_args=("$f" 47 --prefix PATH ':' "$program_PATH" 48 --prefix LUA_PATH ';' "$LUA_PATH" 49 --prefix LUA_CPATH ';' "$LUA_CPATH" 50 ) 51 52 # Add any additional arguments provided by makeWrapperArgs 53 # argument to buildLuaPackage. 54 # makeWrapperArgs 55 local -a user_args="($makeWrapperArgs)" 56 local -a wrapProgramArgs=("${wrap_args[@]}" "${user_args[@]}") 57 58 # see setup-hooks/make-wrapper.sh 59 wrapProgram "${wrapProgramArgs[@]}" 60 61 # Same as above, but now for the wrapper script 62 substituteInPlace "$f" \ 63 --replace-fail "@luarocksBuild@" "@luarocksHost@" 64 65 done 66}