Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# Generic builder for lua packages
{
lib,
stdenv,
lua,
wrapLua,
luarocks_bootstrap,
writeTextFile,
buildPackages,

# Whether the derivation provides a lua module or not.
luarocksCheckHook,
Expand Down Expand Up @@ -236,6 +238,12 @@ let
runHook postShell
'';

disallowedReferences = lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
buildPackages.bash
lua.luaOnBuild
lua.luaOnBuild.pkgs.luarocks_bootstrap
];

passthru = {
inherit lua;
}
Expand Down
7 changes: 7 additions & 0 deletions pkgs/development/interpreters/lua-5/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ let
inherit packageOverrides;
self = luaOnBuild;
};
inherit
luaOnBuildForBuild
luaOnBuildForHost
luaOnBuildForTarget
luaOnHostForHost
luaOnTargetForTarget
;

tests = callPackage ./tests {
lua = self;
Expand Down
6 changes: 4 additions & 2 deletions pkgs/development/interpreters/lua-5/wrap-lua.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
makeSetupHook {
name = "wrap-lua-hook";
propagatedBuildInputs = [ makeWrapper ];
substitutions.executable = lua.interpreter;
substitutions.lua = lua;
substitutions.luaBuild = lua.luaOnBuildForHost;
substitutions.luaHost = lua.luaOnHostForHost;
substitutions.luarocksBuild = lua.luaOnBuildForHost.pkgs.luarocks_bootstrap;
substitutions.luarocksHost = lua.luaOnHostForHost.pkgs.luarocks_bootstrap;
} ./wrap.sh
20 changes: 15 additions & 5 deletions pkgs/development/interpreters/lua-5/wrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# variable is passed in from the buildLuarocksPackage function.
set -e

source @lua@/nix-support/utils.sh
source @luaBuild@/nix-support/utils.sh

wrapLuaPrograms() {
wrapLuaProgramsIn "$out/bin" "$out $luaPath"
Expand All @@ -28,10 +28,16 @@ wrapLuaProgramsIn() {

# Find all regular files in the output directory that are executable.
find "$dir" -type f -perm -0100 -print0 | while read -d "" f; do
# Rewrite "#! .../env lua" to "#! /nix/store/.../lua".
# Lua to use besides one with this hook anyway.
if head -n1 "$f" | grep -q '#!.*/env.*\(lua\)'; then
sed -i "$f" -e "1 s^.*/env[ ]*\(lua\)[^ ]*^#! @executable@^"
if head -n1 "$f" | grep -q '#!.*'; then
# Cross-compilation hack: exec '/nix/store/...-lua-.../bin/lua' execute
# the host lua
substituteInPlace "$f" \
--replace-fail "@luaBuild@" "@luaHost@"
# Build platform's Luarocks writes scripts that reference luarocks
# itself in them, so we fix these references to reference the host
# platform's luarocks.
substituteInPlace "$f" \
--replace-fail "@luarocksBuild@" "@luarocksHost@"
fi

# wrapProgram creates the executable shell script described
Expand All @@ -52,5 +58,9 @@ wrapLuaProgramsIn() {
# see setup-hooks/make-wrapper.sh
wrapProgram "${wrapProgramArgs[@]}"

# Same as above, but now for the wrapper script
substituteInPlace "$f" \
--replace-fail "@luarocksBuild@" "@luarocksHost@"

done
}
Loading