mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-07-19 23:21:27 +00:00
buildLuarocksPackage: fix cross compilation wrapping (#481511)
This commit is contained in:
@@ -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,
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -90,6 +90,13 @@ let
|
||||
inherit packageOverrides;
|
||||
self = luaOnBuild;
|
||||
};
|
||||
inherit
|
||||
luaOnBuildForBuild
|
||||
luaOnBuildForHost
|
||||
luaOnBuildForTarget
|
||||
luaOnHostForHost
|
||||
luaOnTargetForTarget
|
||||
;
|
||||
|
||||
tests = callPackage ./tests {
|
||||
lua = self;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
@@ -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
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user