lua: merge lua5.X interpreters (#59919)

lua: merge lua5.X interpreters

similar to what was done for python.
Makes it easier to change the passthru settings and the lua infrastructure.
This commit is contained in:
Matthieu Coudron 2019-04-27 22:00:12 +09:00 committed by GitHub
parent 8e146ec387
commit 672c3c1d2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 110 additions and 225 deletions

@ -1,76 +0,0 @@
{ stdenv, fetchurl, readline
, self
, callPackage
, packageOverrides ? (self: super: {})
}:
let
dsoPatch = fetchurl {
url = "https://projects.archlinux.org/svntogit/packages.git/plain/trunk/lua-arch.patch?h=packages/lua51";
sha256 = "11fcyb4q55p4p7kdb8yp85xlw8imy14kzamp2khvcyxss4vw8ipw";
name = "lua-arch.patch";
};
luaPackages = callPackage ../../lua-modules {lua=self; overrides=packageOverrides;};
in
stdenv.mkDerivation rec {
name = "lua-${version}";
version = "5.1.5";
luaversion = "5.1";
src = fetchurl {
url = "https://www.lua.org/ftp/${name}.tar.gz";
sha256 = "2640fc56a795f29d28ef15e13c34a47e223960b0240e8cb0a82d9b0738695333";
};
LuaPathSearchPaths = luaPackages.getLuaPathList luaversion;
LuaCPathSearchPaths = luaPackages.getLuaCPathList luaversion;
setupHook = luaPackages.lua-setup-hook LuaPathSearchPaths LuaCPathSearchPaths;
buildInputs = [ readline ];
patches = (if stdenv.isDarwin then [ ./5.1.darwin.patch ] else [ dsoPatch ])
++ [ ./5.1.0004-Fix-stack-overflow-in-vararg-functions.patch ];
configurePhase =
if stdenv.isDarwin
then ''
makeFlagsArray=( INSTALL_TOP=$out INSTALL_MAN=$out/share/man/man1 PLAT=macosx CFLAGS="-DLUA_USE_LINUX -fno-common -O2" LDFLAGS="" CC="$CC" )
installFlagsArray=( TO_BIN="lua luac" TO_LIB="liblua.5.1.5.dylib" INSTALL_DATA='cp -d' )
'' else ''
makeFlagsArray=( INSTALL_TOP=$out INSTALL_MAN=$out/share/man/man1 PLAT=linux CFLAGS="-DLUA_USE_LINUX -O2 -fPIC" LDFLAGS="-fPIC" CC="$CC" AR="$AR q" RANLIB="$RANLIB" )
installFlagsArray=( TO_BIN="lua luac" TO_LIB="liblua.a liblua.so liblua.so.5.1 liblua.so.5.1.5" INSTALL_DATA='cp -d' )
'';
postInstall = ''
mkdir -p "$out/share/doc/lua" "$out/lib/pkgconfig"
sed <"etc/lua.pc" >"$out/lib/pkgconfig/lua.pc" -e "s|^prefix=.*|prefix=$out|"
mv "doc/"*.{gif,png,css,html} "$out/share/doc/lua/"
rmdir $out/{share,lib}/lua/5.1 $out/{share,lib}/lua
'';
passthru = rec {
buildEnv = callPackage ./wrapper.nix {
lua=self;
inherit (luaPackages) requiredLuaModules;
};
withPackages = import ./with-packages.nix { inherit buildEnv luaPackages;};
pkgs = luaPackages;
interpreter = "${self}/bin/lua";
};
meta = {
homepage = http://www.lua.org;
description = "Powerful, fast, lightweight, embeddable scripting language";
longDescription = ''
Lua combines simple procedural syntax with powerful data
description constructs based on associative arrays and extensible
semantics. Lua is dynamically typed, runs by interpreting bytecode
for a register-based virtual machine, and has automatic memory
management with incremental garbage collection, making it ideal
for configuration, scripting, and rapid prototyping.
'';
license = stdenv.lib.licenses.mit;
platforms = with stdenv.lib.platforms; linux ++ darwin;
hydraPlatforms = stdenv.lib.platforms.linux;
};
}

@ -1,95 +0,0 @@
{ stdenv, fetchurl, readline
# compiles compatibility layer with lua5.1
, compat ? false
, callPackage
, self
, packageOverrides ? (self: super: {})
}:
let
dsoPatch = fetchurl {
url = "https://projects.archlinux.org/svntogit/packages.git/plain/trunk/liblua.so.patch?h=packages/lua52";
sha256 = "1by1dy4ql61f5c6njq9ibf9kaqm3y633g2q8j54iyjr4cxvqwqz9";
name = "lua-arch.patch";
};
luaPackages = callPackage ../../lua-modules {lua=self; overrides=packageOverrides;};
in
stdenv.mkDerivation rec {
name = "lua-${version}";
luaversion = "5.2";
version = "${luaversion}.4";
LuaPathSearchPaths = luaPackages.getLuaPathList luaversion;
LuaCPathSearchPaths = luaPackages.getLuaCPathList luaversion;
setupHook = luaPackages.lua-setup-hook LuaPathSearchPaths LuaCPathSearchPaths;
src = fetchurl {
url = "https://www.lua.org/ftp/${name}.tar.gz";
sha256 = "0jwznq0l8qg9wh5grwg07b5cy3lzngvl5m2nl1ikp6vqssmf9qmr";
};
buildInputs = [ readline ];
patches = if stdenv.isDarwin then [ ./5.2.darwin.patch ] else [ dsoPatch ];
passthru = rec {
buildEnv = callPackage ./wrapper.nix {
lua = self;
inherit (luaPackages) requiredLuaModules;
};
withPackages = import ./with-packages.nix { inherit buildEnv luaPackages;};
pkgs = luaPackages;
interpreter = "${self}/bin/lua";
};
enableParallelBuilding = true;
configurePhase =
if stdenv.isDarwin
then ''
makeFlagsArray=( INSTALL_TOP=$out INSTALL_MAN=$out/share/man/man1 PLAT=macosx CFLAGS="-DLUA_USE_LINUX -fno-common -O2 -fPIC${if compat then " -DLUA_COMPAT_ALL" else ""}" LDFLAGS="-fPIC" V=${luaversion} R=${version} CC="$CC" )
installFlagsArray=( TO_BIN="lua luac" TO_LIB="liblua.${version}.dylib" INSTALL_DATA='cp -d' )
'' else ''
makeFlagsArray=( INSTALL_TOP=$out INSTALL_MAN=$out/share/man/man1 PLAT=linux CFLAGS="-DLUA_USE_LINUX -O2 -fPIC${if compat then " -DLUA_COMPAT_ALL" else ""}" LDFLAGS="-fPIC" V=${luaversion} R=${version} CC="$CC" AR="$AR q" RANLIB="$RANLIB" )
installFlagsArray=( TO_BIN="lua luac" TO_LIB="liblua.a liblua.so liblua.so.${luaversion} liblua.so.${version}" INSTALL_DATA='cp -d' )
'';
postInstall = ''
mkdir -p "$out/share/doc/lua" "$out/lib/pkgconfig"
mv "doc/"*.{gif,png,css,html} "$out/share/doc/lua/"
rmdir $out/{share,lib}/lua/${luaversion} $out/{share,lib}/lua
mkdir -p "$out/lib/pkgconfig"
cat >"$out/lib/pkgconfig/lua.pc" <<EOF
prefix=$out
libdir=$out/lib
includedir=$out/include
INSTALL_BIN=$out/bin
INSTALL_INC=$out/include
INSTALL_LIB=$out/lib
INSTALL_MAN=$out/man/man1
Name: Lua
Description: An Extensible Extension Language
Version: ${version}
Requires:
Libs: -L$out/lib -llua -lm
Cflags: -I$out/include
EOF
'';
meta = {
homepage = http://www.lua.org;
description = "Powerful, fast, lightweight, embeddable scripting language";
longDescription = ''
Lua combines simple procedural syntax with powerful data
description constructs based on associative arrays and extensible
semantics. Lua is dynamically typed, runs by interpreting bytecode
for a register-based virtual machine, and has automatic memory
management with incremental garbage collection, making it ideal
for configuration, scripting, and rapid prototyping.
'';
license = stdenv.lib.licenses.mit;
platforms = stdenv.lib.platforms.unix;
};
}

@ -0,0 +1,66 @@
# similar to interpreters/python/default.nix
{ stdenv, lib, callPackage, fetchurl }:
let
dsoPatch51 = fetchurl {
url = "https://projects.archlinux.org/svntogit/packages.git/plain/trunk/lua-arch.patch?h=packages/lua51";
sha256 = "11fcyb4q55p4p7kdb8yp85xlw8imy14kzamp2khvcyxss4vw8ipw";
name = "lua-arch.patch";
};
dsoPatch52 = fetchurl {
url = "https://projects.archlinux.org/svntogit/packages.git/plain/trunk/liblua.so.patch?h=packages/lua52";
sha256 = "1by1dy4ql61f5c6njq9ibf9kaqm3y633g2q8j54iyjr4cxvqwqz9";
name = "lua-arch.patch";
};
in rec {
lua5_3 = (callPackage ./interpreter.nix {
sourceVersion = { major = "5"; minor = "3"; patch = "5"; };
hash = "0c2eed3f960446e1a3e4b9a1ca2f3ff893b6ce41942cf54d5dd59ab4b3b058ac";
patches = lib.optionals stdenv.isDarwin [ ./5.2.darwin.patch ] ;
}).overrideAttrs( oa: {
postConfigure = lib.optionalString (!stdenv.isDarwin) ''
cat ${./lua-5.3-dso.make} >> src/Makefile
sed -e 's/ALL_T *= */& $(LUA_SO)/' -i src/Makefile
'';
postBuild = stdenv.lib.optionalString (!stdenv.isDarwin) ''
( cd src; make $makeFlags "''${makeFlagsArray[@]}" liblua.so )
'';
});
lua5_3_compat = lua5_3.override({
compat = true;
});
lua5_2 = callPackage ./interpreter.nix {
sourceVersion = { major = "5"; minor = "2"; patch = "4"; };
hash = "0jwznq0l8qg9wh5grwg07b5cy3lzngvl5m2nl1ikp6vqssmf9qmr";
patches = if stdenv.isDarwin then [ ./5.2.darwin.patch ] else [ dsoPatch52 ];
};
lua5_2_compat = lua5_2.override({
compat = true;
});
lua5_1 = callPackage ./interpreter.nix {
sourceVersion = { major = "5"; minor = "1"; patch = "5"; };
hash = "2640fc56a795f29d28ef15e13c34a47e223960b0240e8cb0a82d9b0738695333";
patches = (if stdenv.isDarwin then [ ./5.1.darwin.patch ] else [ dsoPatch51 ])
++ [ ./5.1.0004-Fix-stack-overflow-in-vararg-functions.patch ];
};
luajit_2_0 = import ../luajit/2.0.nix {
self = luajit_2_0;
inherit callPackage lib;
};
luajit_2_1 = import ../luajit/2.1.nix {
self = luajit_2_1;
inherit callPackage lib;
};
}

@ -1,19 +1,22 @@
{ stdenv, fetchurl, readline, compat ? false
{ stdenv, fetchurl, readline
, compat ? false
, callPackage
, self
, packageOverrides ? (self: super: {})
, sourceVersion
, hash
, patches ? []
}:
let
luaPackages = callPackage ../../lua-modules {lua=self; overrides=packageOverrides;};
in
stdenv.mkDerivation rec {
name = "lua-${version}";
luaversion = "5.3";
version = "${luaversion}.5";
luaPackages = callPackage ../../lua-modules {lua=self; overrides=packageOverrides;};
self = stdenv.mkDerivation rec {
pname = "lua";
luaversion = with sourceVersion; "${major}.${minor}";
version = "${luaversion}.${sourceVersion.patch}";
src = fetchurl {
url = "https://www.lua.org/ftp/${name}.tar.gz";
sha256 = "0c2eed3f960446e1a3e4b9a1ca2f3ff893b6ce41942cf54d5dd59ab4b3b058ac";
url = "https://www.lua.org/ftp/${pname}-${luaversion}.tar.gz";
sha256 = hash;
};
LuaPathSearchPaths = luaPackages.getLuaPathList luaversion;
@ -22,22 +25,32 @@ stdenv.mkDerivation rec {
buildInputs = [ readline ];
patches = if stdenv.isDarwin then [ ./5.2.darwin.patch ] else [];
inherit patches;
configurePhase =
if stdenv.isDarwin
then ''
makeFlagsArray=( INSTALL_TOP=$out INSTALL_MAN=$out/share/man/man1 PLAT=macosx CFLAGS="-DLUA_USE_LINUX -fno-common -O2 -fPIC${if compat then " -DLUA_COMPAT_ALL" else ""}" LDFLAGS="-fPIC" V=${luaversion} R=${version} CC="$CC" )
installFlagsArray=( TO_BIN="lua luac" TO_LIB="liblua.${version}.dylib" INSTALL_DATA='cp -d' )
'' else ''
makeFlagsArray=( INSTALL_TOP=$out INSTALL_MAN=$out/share/man/man1 PLAT=linux CFLAGS="-DLUA_USE_LINUX -O2 -fPIC${if compat then " -DLUA_COMPAT_ALL" else ""}" LDFLAGS="-fPIC" V=${luaversion} R=${version} CC="$CC" AR="$AR q" RANLIB="$RANLIB" )
installFlagsArray=( TO_BIN="lua luac" TO_LIB="liblua.a liblua.so liblua.so.${luaversion} liblua.so.${version}" INSTALL_DATA='cp -d' )
cat ${./lua-5.3-dso.make} >> src/Makefile
sed -e 's/ALL_T *= */& $(LUA_SO)/' -i src/Makefile
'';
# see configurePhase for additional flags (with space)
makeFlags = [
"INSTALL_TOP=${placeholder "out"}"
"INSTALL_MAN=${placeholder "out"}/share/man/man1"
"R=${version}"
"LDFLAGS=-fPIC"
"V=${luaversion}"
] ++ (if stdenv.isDarwin then [
"PLAT=macosx"
] else [
"PLAT=linux"
])
;
postBuild = stdenv.lib.optionalString (! stdenv.isDarwin) ''
( cd src; make liblua.so "''${makeFlagsArray[@]}" )
configurePhase = ''
runHook preConfigure
makeFlagsArray+=(CFLAGS="-DLUA_USE_LINUX -O2 -fPIC${if compat then " -DLUA_COMPAT_ALL" else ""}" )
makeFlagsArray+=(${stdenv.lib.optionalString stdenv.isDarwin "CC=\"$CC\""})
installFlagsArray=( TO_BIN="lua luac" INSTALL_DATA='cp -d' \
TO_LIB="${if stdenv.isDarwin then "liblua.${version}.dylib" else "liblua.a liblua.so liblua.so.${luaversion} liblua.so.${version}"}" )
runHook postConfigure
'';
postInstall = ''
@ -45,6 +58,7 @@ stdenv.mkDerivation rec {
mv "doc/"*.{gif,png,css,html} "$out/share/doc/lua/"
rmdir $out/{share,lib}/lua/${luaversion} $out/{share,lib}/lua
mkdir -p "$out/lib/pkgconfig"
cat >"$out/lib/pkgconfig/lua.pc" <<EOF
prefix=$out
libdir=$out/lib
@ -88,4 +102,5 @@ stdenv.mkDerivation rec {
license = stdenv.lib.licenses.mit;
platforms = stdenv.lib.platforms.unix;
};
}
};
in self

@ -8095,24 +8095,10 @@ in
wabt = callPackage ../development/tools/wabt { };
### LUA MODULES
lua5_1 = callPackage ../development/interpreters/lua-5/5.1.nix {
self = lua5_1;
};
lua5_2 = callPackage ../development/interpreters/lua-5/5.2.nix {
self = lua5_2;
};
lua5_2_compat = callPackage ../development/interpreters/lua-5/5.2.nix {
compat = true;
self = lua5_2_compat;
};
lua5_3 = callPackage ../development/interpreters/lua-5/5.3.nix {
self = lua5_3;
};
lua5_3_compat = callPackage ../development/interpreters/lua-5/5.3.nix {
compat = true;
self = lua5_3_compat;
};
### LUA interpreters
luaInterpreters = callPackage ./../development/interpreters/lua-5 {};
inherit (luaInterpreters) lua5_1 lua5_2 lua5_2_compat lua5_3 lua5_3_compat luajit_2_1 luajit_2_0;
lua5 = lua5_2_compat;
lua = lua5;
@ -8123,17 +8109,6 @@ in
luaPackages = lua52Packages;
# override instead ?
luajit_2_0 = import ../development/interpreters/luajit/2.0.nix {
self = luajit_2_0;
inherit (super) callPackage lib;
};
luajit_2_1 = import ../development/interpreters/luajit/2.1.nix {
self = luajit_2_1;
inherit (super) callPackage lib;
};
luajit = luajit_2_1;
luarocks = luaPackages.luarocks;