2019-04-27 13:00:12 +00:00
|
|
|
{ stdenv, fetchurl, readline
|
|
|
|
, compat ? false
|
2019-01-30 14:13:15 +00:00
|
|
|
, callPackage
|
|
|
|
, packageOverrides ? (self: super: {})
|
2019-04-27 13:00:12 +00:00
|
|
|
, sourceVersion
|
|
|
|
, hash
|
|
|
|
, patches ? []
|
2019-04-27 18:28:54 +00:00
|
|
|
, postConfigure ? null
|
|
|
|
, postBuild ? null
|
2019-01-30 14:13:15 +00:00
|
|
|
}:
|
|
|
|
let
|
2019-04-27 13:00:12 +00:00
|
|
|
luaPackages = callPackage ../../lua-modules {lua=self; overrides=packageOverrides;};
|
|
|
|
|
|
|
|
self = stdenv.mkDerivation rec {
|
|
|
|
pname = "lua";
|
|
|
|
luaversion = with sourceVersion; "${major}.${minor}";
|
|
|
|
version = "${luaversion}.${sourceVersion.patch}";
|
2015-06-02 17:31:34 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2019-04-27 13:00:12 +00:00
|
|
|
url = "https://www.lua.org/ftp/${pname}-${luaversion}.tar.gz";
|
|
|
|
sha256 = hash;
|
2015-06-02 17:31:34 +00:00
|
|
|
};
|
|
|
|
|
2019-01-30 14:13:15 +00:00
|
|
|
LuaPathSearchPaths = luaPackages.getLuaPathList luaversion;
|
|
|
|
LuaCPathSearchPaths = luaPackages.getLuaCPathList luaversion;
|
|
|
|
setupHook = luaPackages.lua-setup-hook LuaPathSearchPaths LuaCPathSearchPaths;
|
|
|
|
|
2018-03-21 21:05:39 +00:00
|
|
|
buildInputs = [ readline ];
|
2015-06-02 17:31:34 +00:00
|
|
|
|
2019-04-27 13:00:12 +00:00
|
|
|
inherit patches;
|
2015-06-02 17:31:34 +00:00
|
|
|
|
2019-04-27 13:00:12 +00:00
|
|
|
# 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"
|
2019-08-19 07:37:24 +00:00
|
|
|
]) ++ (if stdenv.buildPlatform != stdenv.hostPlatform then [
|
|
|
|
"CC=${stdenv.hostPlatform.config}-gcc"
|
|
|
|
"RANLIB=${stdenv.hostPlatform.config}-ranlib"
|
|
|
|
] else [])
|
2019-04-27 13:00:12 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
configurePhase = ''
|
|
|
|
runHook preConfigure
|
2015-06-02 17:31:34 +00:00
|
|
|
|
2019-04-27 13:00:12 +00:00
|
|
|
makeFlagsArray+=(CFLAGS="-DLUA_USE_LINUX -O2 -fPIC${if compat then " -DLUA_COMPAT_ALL" else ""}" )
|
2019-08-19 07:37:24 +00:00
|
|
|
makeFlagsArray+=(${stdenv.lib.optionalString stdenv.isDarwin "CC=\"$CC\""}${stdenv.lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform) " 'AR=${stdenv.hostPlatform.config}-ar rcu'"})
|
2019-04-27 13:00:12 +00:00
|
|
|
|
|
|
|
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
|
2015-06-02 17:31:34 +00:00
|
|
|
'';
|
2019-04-27 18:28:54 +00:00
|
|
|
inherit postConfigure;
|
|
|
|
|
|
|
|
inherit postBuild;
|
2015-06-02 17:31:34 +00:00
|
|
|
|
|
|
|
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"
|
2019-04-27 13:00:12 +00:00
|
|
|
|
2015-06-02 17:31:34 +00:00
|
|
|
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
|
2018-06-24 02:25:48 +00:00
|
|
|
ln -s "$out/lib/pkgconfig/lua.pc" "$out/lib/pkgconfig/lua${luaversion}.pc"
|
2015-06-02 17:31:34 +00:00
|
|
|
'';
|
|
|
|
|
2019-01-30 14:13:15 +00:00
|
|
|
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";
|
|
|
|
};
|
|
|
|
|
2015-06-02 17:31:34 +00:00
|
|
|
meta = {
|
2017-08-01 20:03:30 +00:00
|
|
|
homepage = http://www.lua.org;
|
2015-06-02 17:31:34 +00:00
|
|
|
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;
|
2016-08-02 20:12:20 +00:00
|
|
|
platforms = stdenv.lib.platforms.unix;
|
2015-06-02 17:31:34 +00:00
|
|
|
};
|
2019-04-27 13:00:12 +00:00
|
|
|
};
|
|
|
|
in self
|