1 { lib, stdenv, lua, buildEnv, makeWrapper
3 , extraOutputsToInstall ? []
5 , ignoreCollisions ? false
10 # Create a lua executable that knows about additional packages.
13 paths = requiredLuaModules (extraLibs ++ [ lua ] );
15 name = "${lua.name}-env";
18 inherit ignoreCollisions;
19 extraOutputsToInstall = [ "out" ] ++ extraOutputsToInstall;
23 (lua.pkgs.lua-setup-hook lua.LuaPathSearchPaths lua.LuaCPathSearchPaths)
26 # we create wrapper for the binaries in the different packages
28 if [ -L "$out/bin" ]; then
35 # take every binary from lua packages and put them into the env
36 for path in ${lib.concatStringsSep " " paths}; do
37 nix_debug "looking for binaries in path = $path"
38 if [ -d "$path/bin" ]; then
41 if [ -f "$prg" ]; then
43 if [ -x "$prg" ]; then
44 nix_debug "Making wrapper $prg"
45 makeWrapper "$path/bin/$prg" "$out/bin/$prg" \
46 --set-default LUA_PATH ";;" \
47 --suffix LUA_PATH ';' "$LUA_PATH" \
48 --set-default LUA_CPATH ";;" \
49 --suffix LUA_CPATH ';' "$LUA_CPATH" \
50 ${lib.concatStringsSep " " makeWrapperArgs}
60 passthru = lua.passthru // {
61 interpreter = "${env}/bin/lua";
63 luaPath = lua.pkgs.lib.genLuaPathAbsStr env;
64 luaCpath = lua.pkgs.lib.genLuaCPathAbsStr env;
65 env = stdenv.mkDerivation {
66 name = "interactive-${lua.name}-environment";
67 nativeBuildInputs = [ env ];
71 echo >&2 "*** lua 'env' attributes are intended for interactive nix-shell sessions, not for building! ***"