Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 17.09 98 lines 3.3 kB view raw
1{ stdenv, fetchurl, readline, compat ? false 2, hostPlatform 3}: 4 5let 6 dsoPatch = fetchurl { 7 url = "https://projects.archlinux.org/svntogit/packages.git/plain/trunk/liblua.so.patch?h=packages/lua52"; 8 sha256 = "1by1dy4ql61f5c6njq9ibf9kaqm3y633g2q8j54iyjr4cxvqwqz9"; 9 name = "lua-arch.patch"; 10 }; 11in 12stdenv.mkDerivation rec { 13 name = "lua-${version}"; 14 luaversion = "5.2"; 15 version = "${luaversion}.3"; 16 17 src = fetchurl { 18 url = "http://www.lua.org/ftp/${name}.tar.gz"; 19 sha256 = "0b8034v1s82n4dg5rzcn12067ha3nxaylp2vdp8gg08kjsbzphhk"; 20 }; 21 22 nativeBuildInputs = [ readline ]; 23 24 patches = if stdenv.isDarwin then [ ./5.2.darwin.patch ] else [ dsoPatch ]; 25 26 configurePhase = 27 if stdenv.isDarwin 28 then '' 29 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} ) 30 installFlagsArray=( TO_BIN="lua luac" TO_LIB="liblua.${version}.dylib" INSTALL_DATA='cp -d' ) 31 '' else '' 32 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} ) 33 installFlagsArray=( TO_BIN="lua luac" TO_LIB="liblua.a liblua.so liblua.so.${luaversion} liblua.so.${version}" INSTALL_DATA='cp -d' ) 34 ''; 35 36 postInstall = '' 37 mkdir -p "$out/share/doc/lua" "$out/lib/pkgconfig" 38 mv "doc/"*.{gif,png,css,html} "$out/share/doc/lua/" 39 rmdir $out/{share,lib}/lua/${luaversion} $out/{share,lib}/lua 40 mkdir -p "$out/lib/pkgconfig" 41 cat >"$out/lib/pkgconfig/lua.pc" <<EOF 42 prefix=$out 43 libdir=$out/lib 44 includedir=$out/include 45 INSTALL_BIN=$out/bin 46 INSTALL_INC=$out/include 47 INSTALL_LIB=$out/lib 48 INSTALL_MAN=$out/man/man1 49 50 Name: Lua 51 Description: An Extensible Extension Language 52 Version: ${version} 53 Requires: 54 Libs: -L$out/lib -llua -lm 55 Cflags: -I$out/include 56 EOF 57 ''; 58 59 crossAttrs = let 60 inherit (hostPlatform) isDarwin isMingw; 61 in { 62 configurePhase = '' 63 makeFlagsArray=( 64 INSTALL_TOP=$out 65 INSTALL_MAN=$out/share/man/man1 66 V=${luaversion} 67 R=${version} 68 ${if isMingw then "mingw" else stdenv.lib.optionalString isDarwin '' 69 ''} 70 ) 71 '' + stdenv.lib.optionalString isMingw '' 72 installFlagsArray=( 73 TO_BIN="lua.exe luac.exe" 74 TO_LIB="liblua.a lua52.dll" 75 INSTALL_DATA="cp -d" 76 ) 77 ''; 78 } // stdenv.lib.optionalAttrs isDarwin { 79 postPatch = '' 80 sed -i -e 's/-Wl,-soname[^ ]* *//' src/Makefile 81 ''; 82 }; 83 84 meta = { 85 homepage = http://www.lua.org; 86 description = "Powerful, fast, lightweight, embeddable scripting language"; 87 longDescription = '' 88 Lua combines simple procedural syntax with powerful data 89 description constructs based on associative arrays and extensible 90 semantics. Lua is dynamically typed, runs by interpreting bytecode 91 for a register-based virtual machine, and has automatic memory 92 management with incremental garbage collection, making it ideal 93 for configuration, scripting, and rapid prototyping. 94 ''; 95 license = stdenv.lib.licenses.mit; 96 platforms = stdenv.lib.platforms.unix; 97 }; 98}