From 672c3c1d2a8ed40c1ef6bd29823af6a8c915584c Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Sat, 27 Apr 2019 22:00:12 +0900 Subject: [PATCH] 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. --- pkgs/development/interpreters/lua-5/5.1.nix | 76 --------------- pkgs/development/interpreters/lua-5/5.2.nix | 95 ------------------- .../interpreters/lua-5/default.nix | 66 +++++++++++++ .../lua-5/{5.3.nix => interpreter.nix} | 65 ++++++++----- pkgs/top-level/all-packages.nix | 33 +------ 5 files changed, 110 insertions(+), 225 deletions(-) delete mode 100644 pkgs/development/interpreters/lua-5/5.1.nix delete mode 100644 pkgs/development/interpreters/lua-5/5.2.nix create mode 100644 pkgs/development/interpreters/lua-5/default.nix rename pkgs/development/interpreters/lua-5/{5.3.nix => interpreter.nix} (57%) diff --git a/pkgs/development/interpreters/lua-5/5.1.nix b/pkgs/development/interpreters/lua-5/5.1.nix deleted file mode 100644 index b2948b392d5e..000000000000 --- a/pkgs/development/interpreters/lua-5/5.1.nix +++ /dev/null @@ -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; - }; -} diff --git a/pkgs/development/interpreters/lua-5/5.2.nix b/pkgs/development/interpreters/lua-5/5.2.nix deleted file mode 100644 index e89a2cbece6d..000000000000 --- a/pkgs/development/interpreters/lua-5/5.2.nix +++ /dev/null @@ -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" <> 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; + }; + +} diff --git a/pkgs/development/interpreters/lua-5/5.3.nix b/pkgs/development/interpreters/lua-5/interpreter.nix similarity index 57% rename from pkgs/development/interpreters/lua-5/5.3.nix rename to pkgs/development/interpreters/lua-5/interpreter.nix index c1fdc0fd9904..29e1e4cf21c8 100644 --- a/pkgs/development/interpreters/lua-5/5.3.nix +++ b/pkgs/development/interpreters/lua-5/interpreter.nix @@ -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" <