summary refs log tree commit diff
path: root/pkgs/development/lua-modules
diff options
context:
space:
mode:
authorAlexei Robyn <shados@shados.net>2019-06-13 21:01:10 +1000
committerAlexei Robyn <shados@shados.net>2019-06-14 13:17:15 +1000
commit274715cbc355e9d50e07a2f60a65a183f7d9855d (patch)
tree52131c594bc72a6a8d07fd64f45ad9ec82fdbe33 /pkgs/development/lua-modules
parent8eabbb3d205541a33658779dc70dc217d3161ed2 (diff)
downloadnixpkgs-274715cbc355e9d50e07a2f60a65a183f7d9855d.tar
nixpkgs-274715cbc355e9d50e07a2f60a65a183f7d9855d.tar.gz
nixpkgs-274715cbc355e9d50e07a2f60a65a183f7d9855d.tar.bz2
nixpkgs-274715cbc355e9d50e07a2f60a65a183f7d9855d.tar.lz
nixpkgs-274715cbc355e9d50e07a2f60a65a183f7d9855d.tar.xz
nixpkgs-274715cbc355e9d50e07a2f60a65a183f7d9855d.tar.zst
nixpkgs-274715cbc355e9d50e07a2f60a65a183f7d9855d.zip
luaPackages: Replace all rockspec packages with generated ones
luaPackages replaced by generated ones:
- bit32
- compat53
- cqueues
- luacyrussasl -> cyrussasl (luarocks name)
- luaexpat
- luadbi -> luadbi front-end module + separate backend modules
  luadbi-{mysql,postgresql,sqlite3}
- luafilesystem
- luaossl
- luasec
- luasocket
- luastdlib -> stdlib (luarocks name)
- lrexlib -> lrexlib-pcre (we already have lrexlib-gnu and
  lrexlib-posix, lrexlib-pcre however appears to be the variant used in
  mudlet, which is the only current dep in nixpkgs)
- luasqlite -> luasql-sqlite3 (luarocks name)
- lfs -> luafilesytem (we literally had two manually written
  luafilesystem expressions, under different names)

Changes and additions to overrides to generated luarocks packgaes,
including:
- busted: Install bash completions along with the zsh ones
- cqueues:
    - Perform minor surgery on the rockspec to allow using a single
      rockspec to build for all supported Lua versions
    - Add a patch by @vcunat to work around a build issue
- luuid: Wrote a tiny patch to allow for Lua 5.1/Luajit compatibility
- General changes:
    - Sorted the packages
    - Attempted to make the formatting consistent
    - Preferenced `.override` instead of `.overrideAttrs` wherever
      possible

Minor changes to other packages to adjust for the Lua package changes:
- luakit expression simplified
- prosody expression simplified; but users will now need to specify the
  luadbi backend module they intend to use in withExtraLibs
- knot-resolver inputs correctd
- mudlet inputs corrected (although this package was and should still be
  broken)
Diffstat (limited to 'pkgs/development/lua-modules')
-rw-r--r--pkgs/development/lua-modules/luasql.patch37
-rw-r--r--pkgs/development/lua-modules/luuid.patch16
-rw-r--r--pkgs/development/lua-modules/overrides.nix299
3 files changed, 239 insertions, 113 deletions
diff --git a/pkgs/development/lua-modules/luasql.patch b/pkgs/development/lua-modules/luasql.patch
deleted file mode 100644
index e91840101ee..00000000000
--- a/pkgs/development/lua-modules/luasql.patch
+++ /dev/null
@@ -1,37 +0,0 @@
---- a/config	2013-02-18 19:36:44.000000000 +0400
-+++ b/config	2014-10-01 08:36:37.104254404 +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,7 +51,7 @@
- #DRIVER_LIBS= -lsqlite
- #DRIVER_INCS=
- ######## SQLite3 
--#DRIVER_LIBS= -L/opt/local/lib -lsqlite3
-+DRIVER_LIBS= -lsqlite3
- #DRIVER_INCS= -I/opt/local/include
- ######## ODBC
- #DRIVER_LIBS= -L/usr/local/lib -lodbc
diff --git a/pkgs/development/lua-modules/luuid.patch b/pkgs/development/lua-modules/luuid.patch
new file mode 100644
index 00000000000..039d522be6d
--- /dev/null
+++ b/pkgs/development/lua-modules/luuid.patch
@@ -0,0 +1,16 @@
+diff -Naur 5.2/uuid/luuid.c rock/uuid/luuid.c
+--- 5.2/uuid/luuid.c	2012-05-10 11:22:00.000000000 +1000
++++ rock/uuid/luuid.c	2019-06-13 15:13:10.374134079 +1000
+@@ -64,7 +64,11 @@
+ 
+ LUALIB_API int luaopen_uuid(lua_State *L)
+ {
+- luaL_newlib(L,R);
++ #if LUA_VERSION_NUM == 501
++  luaL_register(L,MYNAME,R);
++ #else
++  luaL_newlib(L,R);
++ #endif
+  lua_pushliteral(L,"version");			/** version */
+  lua_pushliteral(L,MYVERSION);
+  lua_settable(L,-3);
diff --git a/pkgs/development/lua-modules/overrides.nix b/pkgs/development/lua-modules/overrides.nix
index e00a5b904c5..57557cf614c 100644
--- a/pkgs/development/lua-modules/overrides.nix
+++ b/pkgs/development/lua-modules/overrides.nix
@@ -5,113 +5,260 @@ with super;
   ##########################################3
   #### manual fixes for generated packages
   ##########################################3
-  lgi = super.lgi.overrideAttrs(oa: {
-    nativeBuildInputs = [ pkgs.pkgconfig ];
-    buildInputs = with pkgs; oa.buildInputs ++ [ glib gobjectIntrospection];
+  bit32 = super.bit32.override({
+    disabled = !isLua51;
+    # Theoretically works with luajit, but it does redefine at least one Lua
+    # 5.2 function that Luajit 2.1 provides, see:
+    # https://github.com/LuaJIT/LuaJIT/issues/325
+  });
+
+  busted = super.busted.override({
+    postConfigure = ''
+      substituteInPlace ''${rockspecFilename} \
+        --replace "'lua_cliargs = 3.0-1'," "'lua_cliargs >= 3.0-1',"
+    '';
+    postInstall = ''
+      install -D completions/zsh/_busted $out/share/zsh/site-functions/_busted
+      install -D completions/bash/busted.bash $out/share/bash-completion/completions/busted
+    '';
+  });
+
+  cqueues = super.cqueues.override(rec {
+    # Parse out a version number without the Lua version inserted
+    version = with pkgs.lib; let
+      version' = super.cqueues.version;
+      rel = splitString "." version';
+      date = head rel;
+      rev = last (splitString "-" (last rel));
+    in "${date}-${rev}";
+    nativeBuildInputs = [
+      pkgs.gnum4
+    ];
+    externalDeps = [
+      { name = "CRYPTO"; dep = pkgs.openssl; }
+      { name = "OPENSSL"; dep = pkgs.openssl; }
+    ];
     patches = [
-        (pkgs.fetchpatch {
-            name = "lgi-find-cairo-through-typelib.patch";
-            url = "https://github.com/psychon/lgi/commit/46a163d9925e7877faf8a4f73996a20d7cf9202a.patch";
-            sha256 = "0gfvvbri9kyzhvq3bvdbj2l6mwvlz040dk4mrd5m9gz79f7w109c";
-        })
+      # https://github.com/wahern/cqueues/issues/216 &
+      # https://github.com/wahern/cqueues/issues/217
+      (pkgs.fetchpatch {
+        name = "find-version-fix.patch";
+        url = "https://github.com/wahern/cqueues/pull/217.patch";
+        sha256 = "0068ql0jlxmjkvhzydyy52sjd0k4vad6b8w4y5szpbv4vb2lzcsc";
+      })
     ];
+    disabled = luaOlder "5.1" || luaAtLeast "5.4";
+    # Upstream rockspec is pointlessly broken into separate rockspecs, per Lua
+    # version, which doesn't work well for us, so modify it
+    postConfigure = let inherit (super.cqueues) pname; in ''
+      # 'all' target auto-detects correct Lua version, which is fine for us as
+      # we only have the right one available :)
+      sed -Ei ''${rockspecFilename} \
+        -e 's|lua == 5.[[:digit:]]|lua >= 5.1, <= 5.3|' \
+        -e 's|build_target = "[^"]+"|build_target = "all"|' \
+        -e 's|version = "[^"]+"|version = "${version}"|'
+      specDir=$(dirname ''${rockspecFilename})
+      cp ''${rockspecFilename} "$specDir/${pname}-${version}.rockspec"
+      rockspecFilename="$specDir/${pname}-${version}.rockspec"
+    '';
   });
 
-  ltermbox = super.ltermbox.override( {
-    disabled = !isLua51 || isLuaJIT;
+  cyrussasl = super.cyrussasl.override({
+    externalDeps = [
+      { name = "LIBSASL"; dep = pkgs.cyrus_sasl; }
+    ];
   });
 
-  lua-cmsgpack = super.lua-cmsgpack.override({
-    # TODO this should work with luajit once we fix luajit headers ?
-    disabled = (!isLua51) || isLuaJIT;
+  http = super.http.override({
+    patches = [
+      (pkgs.fetchpatch {
+        name = "invalid-state-progression.patch";
+        url = "https://github.com/daurnimator/lua-http/commit/cb7b59474a.diff";
+        sha256 = "1vmx039n3nqfx50faqhs3wgiw28ws416rhw6vh6srmh9i826dac7";
+      })
+    ];
+    /* TODO: separate docs derivation? (pandoc is heavy)
+    nativeBuildInputs = [ pandoc ];
+    makeFlags = [ "-C doc" "lua-http.html" "lua-http.3" ];
+    */
   });
 
-  lrexlib-posix = super.lrexlib-posix.override({
-    buildInputs = [ pkgs.glibc.dev ];
+  lgi = super.lgi.override({
+    nativeBuildInputs = [
+      pkgs.pkgconfig
+    ];
+    buildInputs = [
+      pkgs.glib
+      pkgs.gobjectIntrospection
+    ];
+    patches = [
+      (pkgs.fetchpatch {
+        name = "lgi-find-cairo-through-typelib.patch";
+        url = "https://github.com/psychon/lgi/commit/46a163d9925e7877faf8a4f73996a20d7cf9202a.patch";
+        sha256 = "0gfvvbri9kyzhvq3bvdbj2l6mwvlz040dk4mrd5m9gz79f7w109c";
+      })
+    ];
   });
+
   lrexlib-gnu = super.lrexlib-gnu.override({
-    buildInputs = [ pkgs.gnulib ];
+    buildInputs = [
+      pkgs.gnulib
+    ];
+  });
+
+  lrexlib-pcre = super.lrexlib-pcre.override({
+    externalDeps = [
+      { name = "PCRE"; dep = pkgs.pcre; }
+    ];
+  });
+
+  lrexlib-posix = super.lrexlib-posix.override({
+    buildInputs = [
+      pkgs.glibc.dev
+    ];
+  });
+
+  ltermbox = super.ltermbox.override( {
+    disabled = !isLua51 || isLuaJIT;
   });
+
+  lua-iconv = super.lua-iconv.override({
+    buildInputs = [
+      pkgs.libiconv
+    ];
+  });
+
   lua-zlib = super.lua-zlib.override({
-    buildInputs = [ pkgs.zlib.dev ];
-    disabled=luaOlder "5.1" || luaAtLeast "5.4";
+    buildInputs = [
+      pkgs.zlib.dev
+    ];
+    disabled = luaOlder "5.1" || luaAtLeast "5.4";
   });
-  luaevent = super.luaevent.override({
-    buildInputs = with pkgs; [ libevent.dev libevent ];
-    propagatedBuildInputs = [ luasocket ];
-    extraConfig = ''
-      variables={
-        EVENT_INCDIR="${pkgs.libevent.dev}/include";
-        EVENT_LIBDIR="${pkgs.libevent}/lib";
-      }
+
+  luadbi-mysql = super.luadbi-mysql.override({
+    extraVariables = ''
+      -- Can't just be /include, unfortunately
+      MYSQL_INCDIR='${pkgs.mysql.connector-c}/include/mysql';
     '';
-    disabled= luaOlder "5.1" || luaAtLeast "5.4" || isLuaJIT;
+    buildInputs = [
+      pkgs.mysql.client
+      pkgs.mysql.connector-c
+    ];
   });
-  lua-iconv = super.lua-iconv.override({
-    buildInputs = [ pkgs.libiconv ];
+
+  luadbi-postgresql = super.luadbi-postgresql.override({
+    buildInputs = [
+      pkgs.postgresql
+    ];
+  });
+
+  luadbi-sqlite3 = super.luadbi-sqlite3.override({
+    externalDeps = [
+      { name = "SQLITE"; dep = pkgs.sqlite; }
+    ];
   });
+
+  luaevent = super.luaevent.override({
+    propagatedBuildInputs = [
+      luasocket
+    ];
+    externalDeps = [
+      { name = "EVENT"; dep = pkgs.libevent; }
+    ];
+    disabled = luaOlder "5.1" || luaAtLeast "5.4";
+  });
+
+  luaexpat = super.luaexpat.override({
+    externalDeps = [
+      { name = "EXPAT"; dep = pkgs.expat; }
+    ];
+  });
+
+  # TODO Somehow automatically amend buildInputs for things that need luaffi
+  # but are in luajitPackages?
+  luaffi = super.luaffi.override({
+    # The packaged .src.rock version is pretty old, and doesn't work with Lua 5.3
+    src = pkgs.fetchFromGitHub {
+      owner = "facebook"; repo = "luaffifb";
+      rev = "532c757e51c86f546a85730b71c9fef15ffa633d";
+      sha256 = "1nwx6sh56zfq99rcs7sph0296jf6a9z72mxknn0ysw9fd7m1r8ig";
+    };
+    knownRockspec = with super.luaffi; "${pname}-${version}.rockspec";
+    disabled = luaOlder "5.1" || luaAtLeast "5.4" || isLuaJIT;
+  });
+
+  luaossl = super.luaossl.override({
+    externalDeps = [
+      { name = "CRYPTO"; dep = pkgs.openssl; }
+      { name = "OPENSSL"; dep = pkgs.openssl; }
+    ];
+  });
+
+  luasec = super.luasec.override({
+    externalDeps = [
+      { name = "OPENSSL"; dep = pkgs.openssl; }
+    ];
+  });
+
+  luasql-sqlite3 = super.luasql-sqlite3.override({
+    externalDeps = [
+      { name = "SQLITE"; dep = pkgs.sqlite; }
+    ];
+  });
+
+  luasystem = super.luasystem.override({
+    buildInputs = [
+      pkgs.glibc
+    ];
+  });
+
   luazip = super.luazip.override({
-    buildInputs = [ pkgs.zziplib ];
+    buildInputs = [
+      pkgs.zziplib
+    ];
   });
-  luv = super.luv.overrideAttrs(oa: {
+
+  luuid = super.luuid.override(old: {
+    externalDeps = [
+      { name = "LIBUUID"; dep = pkgs.libuuid; }
+    ];
+    meta = old.meta // {
+      platforms = pkgs.lib.platforms.linux;
+    };
+    # Trivial patch to make it work in both 5.1 and 5.2.  Basically just the
+    # tiny diff between the two upstream versions placed behind an #if.
+    # Upstreams:
+    # 5.1: http://webserver2.tecgraf.puc-rio.br/~lhf/ftp/lua/5.1/luuid.tar.gz
+    # 5.2: http://webserver2.tecgraf.puc-rio.br/~lhf/ftp/lua/5.2/luuid.tar.gz
+    patchFlags = "-p2";
+    patches = [
+      ./luuid.patch
+    ];
+    postConfigure = let inherit (super.luuid) version pname; in ''
+      sed -Ei ''${rockspecFilename} -e 's|lua >= 5.2|lua >= 5.1,|'
+    '';
+    disabled = luaOlder "5.1" || (luaAtLeast "5.4");
+  });
+
+  luv = super.luv.override({
     # Use system libuv instead of building local and statically linking
     # This is a hacky way to specify -DWITH_SHARED_LIBUV=ON which
-    # should be possible but I'm unable to make work.
+    # is not possible with luarocks and the current luv rockspec
     # While at it, remove bundled libuv source entirely to be sure.
     # We may wish to drop bundled lua submodules too...
     preBuild = ''
      sed -i 's,\(option(WITH_SHARED_LIBUV.*\)OFF,\1ON,' CMakeLists.txt
      rm -rf deps/libuv
     '';
-    propagatedBuildInputs = oa.propagatedBuildInputs ++ [ pkgs.libuv ];
-  });
-
-  busted = super.busted.overrideAttrs(oa: {
-    postInstall = ''
-      install -D completions/zsh/_busted $out/share/zsh/site-functions/_busted
-    '';
-  });
-
-  luuid = super.luuid.override(oa: {
-    buildInputs = [ pkgs.libuuid ];
-    extraConfig = ''
-      variables = {
-        LIBUUID_INCDIR="${pkgs.lib.getDev pkgs.libuuid}/include";
-        LIBUUID_LIBDIR="${pkgs.lib.getLib pkgs.libuuid}/lib";
-      }
-    '';
-    meta = oa.meta // {
-      platforms = pkgs.lib.platforms.linux;
-    };
+    propagatedBuildInputs = [
+      pkgs.libuv
+    ];
   });
 
-  rapidjson = super.rapidjson.overrideAttrs(oa: {
+  rapidjson = super.rapidjson.override({
     preBuild = ''
       sed -i '/set(CMAKE_CXX_FLAGS/d' CMakeLists.txt
       sed -i '/set(CMAKE_C_FLAGS/d' CMakeLists.txt
     '';
   });
-
-  binaryheap = super.binaryheap.overrideAttrs(oa: {
-    meta = oa.meta // {
-      maintainers = with pkgs.lib.maintainers; oa.meta.maintainers ++ [ vcunat ];
-    };
-  });
-
-  http = super.http.overrideAttrs(oa: {
-    patches = oa.patches or [] ++ [
-      (pkgs.fetchpatch {
-        name = "invalid-state-progression.patch";
-        url = "https://github.com/daurnimator/lua-http/commit/cb7b59474a.diff";
-        sha256 = "1vmx039n3nqfx50faqhs3wgiw28ws416rhw6vh6srmh9i826dac7";
-      })
-    ];
-    /* TODO: separate docs derivation? (pandoc is heavy)
-    nativeBuildInputs = [ pandoc ];
-    makeFlags = [ "-C doc" "lua-http.html" "lua-http.3" ];
-    */
-    meta = oa.meta // {
-      maintainers = with pkgs.lib.maintainers; oa.meta.maintainers ++ [ vcunat ];
-    };
-  });
 }