lua packages: propagate libs with a setupHook
The LUA_PATH and LUA_CPATH variables are needed to load libraries. This setupHook exports them to the environment.
This commit is contained in:
parent
8645a1b69d
commit
7b7607382d
@ -1,4 +1,4 @@
|
|||||||
lua:
|
{ lua, writeText }:
|
||||||
|
|
||||||
{ buildInputs ? [], disabled ? false, ... } @ attrs:
|
{ buildInputs ? [], disabled ? false, ... } @ attrs:
|
||||||
|
|
||||||
@ -19,5 +19,36 @@ else
|
|||||||
{
|
{
|
||||||
name = "lua${lua.luaversion}-" + attrs.name;
|
name = "lua${lua.luaversion}-" + attrs.name;
|
||||||
buildInputs = buildInputs ++ [ lua ];
|
buildInputs = buildInputs ++ [ lua ];
|
||||||
|
|
||||||
|
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
|
||||||
|
export LUA_PATH="$package_path/?.lua"
|
||||||
|
else
|
||||||
|
export LUA_PATH="$LUA_PATH;$package_path/?.lua"
|
||||||
|
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
|
||||||
|
'';
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
, pcre, oniguruma, gnulib, tre, glibc, sqlite, openssl, expat, cairo
|
, pcre, oniguruma, gnulib, tre, glibc, sqlite, openssl, expat, cairo
|
||||||
, perl, gtk2, python, glib, gobjectIntrospection, libevent, zlib, autoreconfHook
|
, perl, gtk2, python, glib, gobjectIntrospection, libevent, zlib, autoreconfHook
|
||||||
, mysql, postgresql, cyrus_sasl
|
, mysql, postgresql, cyrus_sasl
|
||||||
, fetchFromGitHub, libmpack, which, fetchpatch
|
, fetchFromGitHub, libmpack, which, fetchpatch, writeText
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
@ -35,7 +35,9 @@ let
|
|||||||
getLuaCPath = lib : getPath lib "so";
|
getLuaCPath = lib : getPath lib "so";
|
||||||
|
|
||||||
#define build lua package function
|
#define build lua package function
|
||||||
buildLuaPackage = callPackage ../development/lua-modules/generic lua;
|
buildLuaPackage = callPackage ../development/lua-modules/generic {
|
||||||
|
inherit lua writeText;
|
||||||
|
};
|
||||||
|
|
||||||
luarocks = callPackage ../development/tools/misc/luarocks {
|
luarocks = callPackage ../development/tools/misc/luarocks {
|
||||||
inherit lua;
|
inherit lua;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user