From d4b7910f80267613017baa7388a9c39ab7a722fb Mon Sep 17 00:00:00 2001 From: wyvie Date: Tue, 23 Sep 2014 18:01:02 +0400 Subject: [PATCH] Added more lua modules to lua-packages, added them as dependencies for mudlet Closes #4269 --- pkgs/development/lua-modules/luasql.patch | 39 +++++++++ pkgs/development/lua-modules/zip.patch | 23 +++++ pkgs/games/mudlet/default.nix | 16 ++-- pkgs/top-level/all-packages.nix | 11 +-- pkgs/top-level/lua-packages.nix | 102 ++++++++++++++++++++-- 5 files changed, 173 insertions(+), 18 deletions(-) create mode 100644 pkgs/development/lua-modules/luasql.patch create mode 100644 pkgs/development/lua-modules/zip.patch diff --git a/pkgs/development/lua-modules/luasql.patch b/pkgs/development/lua-modules/luasql.patch new file mode 100644 index 00000000000..c2b6b067a2d --- /dev/null +++ b/pkgs/development/lua-modules/luasql.patch @@ -0,0 +1,39 @@ +--- a/config 2014-09-19 13:32:52.356775109 +0400 ++++ b/config 2014-09-19 13:33:42.750501633 +0400 +@@ -1,12 +1,12 @@ + # $Id: config,v 1.10 2008/05/30 17:21:18 tomas Exp $ + + # Driver (leave uncommented ONLY the line with the name of the driver) +-T= mysql ++#T= mysql + #T= oci8 + #T= odbc + #T= postgres + #T= sqlite +-#T=sqlite3 ++T=sqlite3 + #T=firebird + + # Installation directories +@@ -37,8 +37,8 @@ + ######## MySQL + #DRIVER_LIBS= -L/usr/local/mysql/lib -lmysqlclient -lz + #DRIVER_INCS= -I/usr/local/mysql/include +-DRIVER_LIBS= -L/usr/lib -lmysqlclient -lz +-DRIVER_INCS= -I/usr/include/mysql ++#DRIVER_LIBS= -L/usr/lib -lmysqlclient -lz ++#DRIVER_INCS= -I/usr/include/mysql + ######## Oracle OCI8 + #DRIVER_LIBS= -L/home/oracle/OraHome1/lib -lz -lclntsh + #DRIVER_INCS= -I/home/oracle/OraHome1/rdbms/demo -I/home/oracle/OraHome1/rdbms/public +@@ -51,8 +51,8 @@ + #DRIVER_LIBS= -lsqlite + #DRIVER_INCS= + ######## SQLite3 +-#DRIVER_LIBS= -L/opt/local/lib -lsqlite3 +-#DRIVER_INCS= -I/opt/local/include ++DRIVER_LIBS= -L/opt/local/lib -lsqlite3 ++DRIVER_INCS= -I/opt/local/include + ######## ODBC + #DRIVER_LIBS= -L/usr/local/lib -lodbc + #DRIVER_INCS= -DUNIXODBC -I/usr/local/include diff --git a/pkgs/development/lua-modules/zip.patch b/pkgs/development/lua-modules/zip.patch new file mode 100644 index 00000000000..c3f88f451e8 --- /dev/null +++ b/pkgs/development/lua-modules/zip.patch @@ -0,0 +1,23 @@ +--- a/Makefile 2007-10-30 01:59:10.000000000 +0300 ++++ b/Makefile 2014-09-18 11:04:53.176320021 +0400 +@@ -6,10 +6,6 @@ + + include $(CONFIG) + +-ifeq "$(LUA_VERSION_NUM)" "500" +-COMPAT_O= $(COMPAT_DIR)/compat-5.1.o +-endif +- + SRCS= src/lua$T.c + OBJS= src/lua$T.o $(COMPAT_O) + +@@ -19,9 +15,6 @@ + src/$(LIBNAME): $(OBJS) + export MACOSX_DEPLOYMENT_TARGET="10.3"; $(CC) $(CFLAGS) $(LIB_OPTION) -o src/$(LIBNAME) $(OBJS) -lzzip + +-$(COMPAT_DIR)/compat-5.1.o: $(COMPAT_DIR)/compat-5.1.c +- $(CC) -c $(CFLAGS) -o $@ $(COMPAT_DIR)/compat-5.1.c +- + install: src/$(LIBNAME) + mkdir -p $(LUA_LIBDIR) + cp src/$(LIBNAME) $(LUA_LIBDIR) diff --git a/pkgs/games/mudlet/default.nix b/pkgs/games/mudlet/default.nix index 2766521f7b3..fd8948276f1 100644 --- a/pkgs/games/mudlet/default.nix +++ b/pkgs/games/mudlet/default.nix @@ -1,4 +1,4 @@ -{ fetchurl, pkgs, stdenv, makeWrapper, qt5, yajl, libzip, hunspell, lua5_1, boost, filesystem }: +{ fetchurl, pkgs, stdenv, makeWrapper, qt5, yajl, libzip, hunspell, boost, lua5_1, luafilesystem, luazip, lrexlib, luasqlite3 }: stdenv.mkDerivation rec { name = "mudlet-${version}"; @@ -9,19 +9,23 @@ stdenv.mkDerivation rec { sha256 = "c7b9a383d2cf393da730ce07ac8f06478eaec1fdf730054e837e58c598222d38"; }; - buildInputs = [ pkgs.unzip qt5 lua5_1 hunspell libzip yajl boost makeWrapper filesystem ]; + buildInputs = [ pkgs.unzip qt5 lua5_1 hunspell libzip yajl boost makeWrapper luafilesystem luazip lrexlib luasqlite3 ]; configurePhase = "cd src && qmake"; - installPhase = '' - mkdir -pv $out + installPhase = let + luaZipPath = "${luazip}/lib/lua/5.1/?.so"; + luaFileSystemPath = "${luafilesystem}/lib/lua/5.1/?.so"; + lrexlibPath = "${lrexlib}/lib/lua/5.1/?.so"; + luasqlitePath = "${luasqlite3}/lib/lua/5.1/?.so"; + in '' mkdir -pv $out/bin cp mudlet $out cp -r mudlet-lua $out - # ln -s $out/mudlet $out/bin/mudlet makeWrapper $out/mudlet $out/bin/mudlet \ - --set LUA_CPATH "${filesystem}/lib/lua/5.1/?.so" + --set LUA_CPATH "\"${luaFileSystemPath};${luaZipPath};${lrexlibPath};${luasqlitePath}\"" \ + --run "cd $out"; ''; patches = [ ./libs.patch ]; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 4777a974d76..37f67fe665e 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -3774,18 +3774,15 @@ let luaPackages = lua52Packages; - lua5_1_sockets = lua51Packages.sockets; + lua5_1_sockets = lua51Packages.luasocket; lua5_expat = callPackage ../development/interpreters/lua-5/expat.nix {}; - lua51_zip = callPackage ../development/interpreters/lua-5/zip.nix { }; lua5_sec = callPackage ../development/interpreters/lua-5/sec.nix { }; - luarocks = callPackage ../development/tools/misc/luarocks { - lua = lua5; - }; - luajit = callPackage ../development/interpreters/luajit {}; + luarocks = luaPackages.luarocks; + ### END OF LUA lush2 = callPackage ../development/interpreters/lush {}; @@ -9727,7 +9724,7 @@ let mrxvt = callPackage ../applications/misc/mrxvt { }; mudlet = callPackage ../games/mudlet { - inherit (lua51Packages) filesystem; + inherit (lua51Packages) luafilesystem lrexlib luazip luasqlite3; }; multisync = callPackage ../applications/misc/multisync { diff --git a/pkgs/top-level/lua-packages.nix b/pkgs/top-level/lua-packages.nix index 2b8c699286b..8a44a997c07 100644 --- a/pkgs/top-level/lua-packages.nix +++ b/pkgs/top-level/lua-packages.nix @@ -5,7 +5,9 @@ for each package in a separate file: the call to the function would be almost as must code as the function itself. */ -{ fetchurl, stdenv, lua, callPackage }: +{ fetchurl, stdenv, lua, callPackage, unzip, zziplib, +pcre, oniguruma, gnulib, tre, glibc, +sqlite }: let isLua51 = lua.luaversion == "5.1"; @@ -17,12 +19,16 @@ let #define build lua package function buildLuaPackage = callPackage ../development/lua-modules/generic lua; - filesystem = buildLuaPackage { + luarocks = callPackage ../development/tools/misc/luarocks { + inherit lua; + }; + + luafilesystem = buildLuaPackage { name = "filesystem-1.6.2"; src = fetchurl { url = "https://github.com/keplerproject/luafilesystem/archive/v1_6_2.tar.gz"; sha256 = "1n8qdwa20ypbrny99vhkmx8q04zd2jjycdb5196xdhgvqzk10abz"; - }; + }; meta = { homepage = "https://github.com/keplerproject/luafilesystem"; hydraPlatforms = stdenv.lib.platforms.linux; @@ -30,8 +36,8 @@ let }; }; - sockets = buildLuaPackage rec { - name = "sockets-${version}"; + luasocket = buildLuaPackage rec { + name = "socket-${version}"; version = "2.0.2"; src = fetchurl { url = "http://files.luaforge.net/releases/luasocket/luasocket/luasocket-${version}/luasocket-${version}.tar.gz"; @@ -50,4 +56,90 @@ let }; }; + luazip = buildLuaPackage rec { + name = "zip-${version}"; + version = "1.2.3"; + src = fetchurl { + url = "https://github.com/luaforge/luazip/archive/0b8f5c958e170b1b49f05bc267bc0351ad4dfc44.zip"; + sha256 = "beb9260d606fdd5304aa958d95f0d3c20be7ca0a2cff44e7b75281c138a76a50"; + }; + buildInputs = [ unzip zziplib ]; + patches = [ ../development/lua-modules/zip.patch ]; + # does not currently work under lua 5.2 + disabled = isLua52; + meta = { + homepage = "https://github.com/luaforge/luazip"; + hydraPlatforms = stdenv.lib.platforms.linux; + license = stdenv.lib.licenses.mit; + }; + }; + + luastdlib = buildLuaPackage { + name = "stdlib"; + src = fetchurl { + url = "https://github.com/lua-stdlib/lua-stdlib/archive/release.zip"; + sha256 = "1v3158g5050sdqfrqi6d2bjh0lmi1v01a6m2nwqpr527a2dqcf0c"; + }; + buildInputs = [ unzip ]; + meta = { + homepage = "https://github.com/lua-stdlib/lua-stdlib/"; + hydraPlatforms = stdenv.lib.platforms.linux; + license = stdenv.lib.licenses.mit; + }; + }; + + lrexlib = buildLuaPackage rec { + name = "lrexlib-${version}"; + version = "2.7.2"; + src = fetchurl { + url = "https://github.com/rrthomas/lrexlib/archive/150c251be57c4e569da0f48bf6b01fbca97179fe.zip"; + sha256 = "0i5brqbykc2nalp8snlq1r0wmf8y2wqp6drzr2xmq5phvj8913xh"; + }; + buildInputs = [ unzip luastdlib pcre luarocks oniguruma gnulib tre glibc ]; + + buildPhase = let + luaVariable = "LUA_PATH=${luastdlib}/share/lua/${lua.luaversion}/?.lua"; + + pcreVariable = "PCRE_DIR=${pcre}"; + onigVariable = "ONIG_DIR=${oniguruma}"; + gnuVariable = "GNU_INCDIR=${gnulib}/lib"; + treVariable = "TRE_DIR=${tre}"; + posixVariable = "POSIX_DIR=${glibc}"; + in '' + sed -e 's@$(LUAROCKS) $(LUAROCKS_COMMAND) $$i;@$(LUAROCKS) $(LUAROCKS_COMMAND) $$i ${pcreVariable} ${onigVariable} ${gnuVariable} ${treVariable} ${posixVariable};@' \ + -i Makefile + ${luaVariable} make + ''; + + installPhase = '' + mkdir -pv $out; + cp -r luarocks/lib $out; + ''; + + meta = { + homepage = "https://github.com/lua-stdlib/lua-stdlib/"; + hydraPlatforms = stdenv.lib.platforms.linux; + license = stdenv.lib.licenses.mit; + }; + }; + + luasqlite3 = buildLuaPackage rec { + name = "sqlite3-${version}"; + version = "2.1.1"; + src = fetchurl { + url = "https://github.com/LuaDist/luasql-sqlite3/archive/2acdb6cb256e63e5b5a0ddd72c4639d8c0feb52d.zip"; + sha256 = "1yy1n1l1801j48rlf3bhxpxqfgx46ixrs8jxhhbf7x1hn1j4axlv"; + }; + + buildInputs = [ unzip sqlite ]; + + patches = [ ../development/lua-modules/luasql.patch ]; + + meta = { + homepage = "https://github.com/LuaDist/luasql-sqlite3"; + hydraPlatforms = stdenv.lib.platforms.linux; + license = stdenv.lib.licenses.mit; + }; + }; + }; in self