2018-02-25 20:48:48 +00:00
|
|
|
{ lua, writeText }:
|
2014-09-19 20:40:37 +01:00
|
|
|
|
|
|
|
{ buildInputs ? [], disabled ? false, ... } @ attrs:
|
|
|
|
|
2014-09-23 11:09:36 +01:00
|
|
|
if disabled then
|
|
|
|
throw "${attrs.name} not supported by interpreter lua-${lua.luaversion}"
|
|
|
|
else
|
2017-09-30 15:36:10 +01:00
|
|
|
lua.stdenv.mkDerivation (
|
|
|
|
{
|
|
|
|
makeFlags = [
|
|
|
|
"PREFIX=$(out)"
|
|
|
|
"LUA_LIBDIR=$(out)/lib/lua/${lua.luaversion}"
|
|
|
|
"LUA_INC=-I${lua}/include"
|
|
|
|
];
|
2014-09-23 11:09:36 +01:00
|
|
|
}
|
|
|
|
//
|
|
|
|
attrs
|
|
|
|
//
|
|
|
|
{
|
|
|
|
name = "lua${lua.luaversion}-" + attrs.name;
|
|
|
|
buildInputs = buildInputs ++ [ lua ];
|
2018-02-25 20:48:48 +00:00
|
|
|
|
|
|
|
setupHook = writeText "setup-hook.sh" ''
|
|
|
|
# check for lua/clua modules and don't add duplicates
|
|
|
|
|
|
|
|
addLuaLibPath() {
|
|
|
|
local package_path="$1/share/lua/${lua.luaversion}"
|
|
|
|
if [[ ! -d $package_path ]]; then return; fi
|
|
|
|
if [[ $LUA_PATH = *"$package_path"* ]]; then return; fi
|
|
|
|
|
|
|
|
if [[ -z $LUA_PATH ]]; then
|
2018-05-24 14:43:15 +01:00
|
|
|
export LUA_PATH="$package_path/?.lua;$package_path/?/init.lua"
|
2018-02-25 20:48:48 +00:00
|
|
|
else
|
2018-05-24 14:43:15 +01:00
|
|
|
export LUA_PATH="$LUA_PATH;$package_path/?.lua;$package_path/?/init.lua"
|
2018-02-25 20:48:48 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
addLuaLibCPath() {
|
|
|
|
local package_cpath="$1/lib/lua/${lua.luaversion}"
|
|
|
|
if [[ ! -d $package_cpath ]]; then return; fi
|
|
|
|
if [[ $LUA_CPATH = *"$package_cpath"* ]]; then return; fi
|
|
|
|
|
|
|
|
if [[ -z $LUA_CPATH ]]; then
|
|
|
|
export LUA_CPATH="$package_cpath/?.so"
|
|
|
|
else
|
|
|
|
export LUA_CPATH="$LUA_CPATH;$package_cpath/?.so"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
addEnvHooks "$hostOffset" addLuaLibPath
|
|
|
|
addEnvHooks "$hostOffset" addLuaLibCPath
|
|
|
|
'';
|
2014-09-23 11:09:36 +01:00
|
|
|
}
|
|
|
|
)
|