mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-12-05 12:19:57 +00:00
This is a follow-up to d2cbb4ba81.
A few exceptions have since been added to the wrapper.
To avoid that and give a way out to the callers, 2 new flags are added
to bypass the default protection.
The allowlist of variables that was created is replaced by these flags.
Also added tests to cover these cases.
88 lines
2.3 KiB
Nix
88 lines
2.3 KiB
Nix
{
|
|
lib,
|
|
stdenv,
|
|
lua,
|
|
buildEnv,
|
|
makeWrapper,
|
|
extraLibs ? [ ],
|
|
extraOutputsToInstall ? [ ],
|
|
postBuild ? "",
|
|
ignoreCollisions ? false,
|
|
requiredLuaModules,
|
|
makeWrapperArgs ? [ ],
|
|
}:
|
|
|
|
# Create a lua executable that knows about additional packages.
|
|
let
|
|
env =
|
|
let
|
|
paths = [ lua ] ++ requiredLuaModules extraLibs;
|
|
in
|
|
buildEnv {
|
|
name = "${lua.name}-env";
|
|
|
|
inherit paths;
|
|
inherit ignoreCollisions;
|
|
extraOutputsToInstall = [ "out" ] ++ extraOutputsToInstall;
|
|
|
|
nativeBuildInputs = [
|
|
makeWrapper
|
|
];
|
|
|
|
# we create wrapper for the binaries in the different packages
|
|
postBuild = ''
|
|
source ${lua}/nix-support/utils.sh
|
|
if [ -L "$out/bin" ]; then
|
|
unlink "$out/bin"
|
|
fi
|
|
mkdir -p "$out/bin"
|
|
|
|
buildLuaPath "$out"
|
|
|
|
# take every binary from lua packages and put them into the env
|
|
for path in ${lib.concatStringsSep " " paths}; do
|
|
nix_debug "looking for binaries in path = $path"
|
|
if [ -d "$path/bin" ]; then
|
|
cd "$path/bin"
|
|
for prg in *; do
|
|
if [ -f "$prg" ]; then
|
|
rm -f "$out/bin/$prg"
|
|
if [ -x "$prg" ]; then
|
|
nix_debug "Making wrapper $prg"
|
|
makeWrapper "$path/bin/$prg" "$out/bin/$prg" \
|
|
--set-default LUA_PATH ";;" \
|
|
--suffix-unchecked LUA_PATH ';' "$LUA_PATH" \
|
|
--set-default LUA_CPATH ";;" \
|
|
--suffix-unchecked LUA_CPATH ';' "$LUA_CPATH" \
|
|
${lib.concatStringsSep " " makeWrapperArgs}
|
|
fi
|
|
fi
|
|
done
|
|
fi
|
|
done
|
|
''
|
|
+ postBuild;
|
|
|
|
inherit (lua) meta;
|
|
|
|
passthru = lua.passthru // {
|
|
interpreter = "${env}/bin/lua";
|
|
inherit lua;
|
|
luaPath = lua.pkgs.luaLib.genLuaPathAbsStr env;
|
|
luaCpath = lua.pkgs.luaLib.genLuaCPathAbsStr env;
|
|
env = stdenv.mkDerivation {
|
|
name = "interactive-${lua.name}-environment";
|
|
nativeBuildInputs = [ env ];
|
|
|
|
buildCommand = ''
|
|
echo >&2 ""
|
|
echo >&2 "*** lua 'env' attributes are intended for interactive nix-shell sessions, not for building! ***"
|
|
echo >&2 ""
|
|
exit 1
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
in
|
|
env
|