{ stdenv, fetchurl, readline , compat ? false , callPackage , packageOverrides ? (self: super: {}) , sourceVersion , hash , patches ? [] }: let 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/${pname}-${luaversion}.tar.gz"; sha256 = hash; }; LuaPathSearchPaths = luaPackages.getLuaPathList luaversion; LuaCPathSearchPaths = luaPackages.getLuaCPathList luaversion; setupHook = luaPackages.lua-setup-hook LuaPathSearchPaths LuaCPathSearchPaths; buildInputs = [ readline ]; inherit patches; # 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" ]) ; 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 = '' 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" <