diff --git a/pkgs/applications/editors/neovim/default.nix b/pkgs/applications/editors/neovim/default.nix index 2fff5cdce8543..94a8b54a4c312 100644 --- a/pkgs/applications/editors/neovim/default.nix +++ b/pkgs/applications/editors/neovim/default.nix @@ -14,7 +14,7 @@ let neovimLuaEnv = lua.withPackages(ps: (with ps; [ lpeg luabitop mpack ] ++ optionals doCheck [ - nvim-client luv coxpcall busted luafilesystem penlight inspect + nvim-client libluv coxpcall busted luafilesystem penlight inspect ] )); in @@ -44,7 +44,7 @@ in libtermkey libuv libvterm-neovim - lua.pkgs.luv.libluv + lua.pkgs.libluv msgpack ncurses neovimLuaEnv @@ -79,9 +79,6 @@ in "-DGPERF_PRG=${gperf}/bin/gperf" "-DLUA_PRG=${neovimLuaEnv.interpreter}" ] - # FIXME: this is verry messy and strange. - ++ optional (!stdenv.isDarwin) "-DLIBLUV_LIBRARY=${lua.pkgs.luv}/lib/lua/${lua.luaversion}/luv.so" - ++ optional (stdenv.isDarwin) "-DLIBLUV_LIBRARY=${lua.pkgs.luv.libluv}/lib/lua/${lua.luaversion}/libluv.dylib" ++ optional doCheck "-DBUSTED_PRG=${neovimLuaEnv}/bin/busted" ++ optional (!lua.pkgs.isLuaJIT) "-DPREFER_LUA=ON" ; diff --git a/pkgs/development/lua-modules/generated-packages.nix b/pkgs/development/lua-modules/generated-packages.nix index 2a4146577ff05..b75c4d24b2eec 100644 --- a/pkgs/development/lua-modules/generated-packages.nix +++ b/pkgs/development/lua-modules/generated-packages.nix @@ -1326,11 +1326,11 @@ luuid = buildLuarocksPackage { }; luv = buildLuarocksPackage { pname = "luv"; - version = "1.34.1-1"; + version = "1.34.2-0"; src = fetchurl { - url = https://luarocks.org/luv-1.34.1-1.src.rock; - sha256 = "044cyp25xn35nj5qp1hx04lfkzrpa6adhqjshq2g7wvbga77p1q0"; + url = https://luarocks.org/luv-1.34.2-0.src.rock; + sha256 = "05c0s1a897yvk0qp31hra2b2qg6kr9fd4cib9hbrpxvzzn9a9cwc"; }; disabled = (luaOlder "5.1"); propagatedBuildInputs = [ lua ]; diff --git a/pkgs/development/lua-modules/overrides.nix b/pkgs/development/lua-modules/overrides.nix index fd99a70de3a62..5250440782171 100644 --- a/pkgs/development/lua-modules/overrides.nix +++ b/pkgs/development/lua-modules/overrides.nix @@ -264,37 +264,38 @@ with super; disabled = luaOlder "5.1" || (luaAtLeast "5.4"); }); + compat53 = super.compat53.override (old: { + # needed for luv build + postInstall = '' + cp -r c-api $out/c-api + ''; + }); + 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 - # 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 + # So we can be sure no internal dependency is used from the repo and that + # everything is provided by us + preConfigure = '' + rm -rf deps + '' + # See the following issues: + # - https://github.com/luarocks/luarocks/issues/1160 + # - https://github.com/luarocks/luarocks/issues/509 + # - https://github.com/luarocks/luarocks/issues/339 + + '' + sed -i 's,\(option(WITH_SHARED_LIBUV.*\)OFF,\1ON,' CMakeLists.txt ''; + LUA_COMPAT53_DIR="${lua.pkgs.compat53}"; buildInputs = [ pkgs.libuv ]; - passthru = { - libluv = self.luv.override ({ - preBuild = self.luv.preBuild + '' - sed -i 's,\(option(BUILD_MODULE.*\)ON,\1OFF,' CMakeLists.txt - sed -i 's,\(option(BUILD_SHARED_LIBS.*\)OFF,\1ON,' CMakeLists.txt - sed -i 's,${"\${INSTALL_INC_DIR}"},${placeholder "out"}/include/luv,' CMakeLists.txt - ''; - - nativeBuildInputs = [ pkgs.fixDarwinDylibNames ]; - - # Fixup linking libluv.dylib, for some reason it's not linked against lua correctly. - NIX_LDFLAGS = pkgs.lib.optionalString pkgs.stdenv.isDarwin - (if isLuaJIT then "-lluajit-${lua.luaversion}" else "-llua"); - }); - }; + nativeBuildInputs = [ + lua.pkgs.compat53 + ]; + # Fixup linking libluv.dylib, for some reason it's not linked against lua correctly. + NIX_LDFLAGS = pkgs.lib.optionalString pkgs.stdenv.isDarwin + (if isLuaJIT then "-lluajit-${lua.luaversion}" else "-llua"); }); - rapidjson = super.rapidjson.override({ preBuild = '' sed -i '/set(CMAKE_CXX_FLAGS/d' CMakeLists.txt diff --git a/pkgs/top-level/lua-packages.nix b/pkgs/top-level/lua-packages.nix index 7f29d47a993c6..8bdba4c9c854c 100644 --- a/pkgs/top-level/lua-packages.nix +++ b/pkgs/top-level/lua-packages.nix @@ -99,6 +99,63 @@ with self; { luarocks-nix = callPackage ../development/tools/misc/luarocks/luarocks-nix.nix { }; + # This package is very much like `lua.pkgs.luv`, but it's not defined as a + # module because it fails to install some files if we use + # `buildLuarocksPackage` instead of `mkDerivation`. However, if another + # package (e.g lua.pkgs.nvim-client) would require `luv = + # stdenv.mkDerivation`, it would not detect it and hence it would fail to + # build. + + # The workaround implemented here is to create 2 versions of `libluv` while + # `luv` is still defined by lua's generated packages and still overriden as + # necessary in lua's overrides. This version is used in neovim and every + # other package that needs luv as a shared library (not as a mere lua + # module). + libluv = pkgs.stdenv.mkDerivation rec { + pname = "luv"; + version = "1.34.2-0"; + + src = pkgs.fetchFromGitHub { + owner = "luvit"; + repo = pname; + rev = version; + sha256 = "0iq272n7p0wkll4a7d880qyhdp65582cwc3b2zzrirpli93x3v87"; + }; + disabled = (luaOlder "5.1"); + + # So we can be sure no internal dependency is used from the repo and that + # everything is provided by us + postUnpack = '' + rm -rf deps + ''; + + cmakeFlags = [ + "-DWITH_SHARED_LIBUV=ON" + "-DLUA_BUILD_TYPE=System" + "-DBUILD_MODULE=ON" + "-DBUILD_SHARED_LIBS=ON" + "-DLUA_COMPAT53_DIR=${lua.pkgs.compat53}" + ]; + + buildInputs = [ pkgs.libuv ]; + + nativeBuildInputs = [ + pkgs.cmake + lua.pkgs.compat53 + ]; + # Fixup linking libluv.dylib, for some reason it's not linked against lua correctly. + NIX_LDFLAGS = pkgs.lib.optionalString pkgs.stdenv.isDarwin + (if isLuaJIT then "-lluajit-${lua.luaversion}" else "-llua"); + propagatedBuildInputs = [ lua ]; + + meta = with stdenv.lib; { + homepage = "https://github.com/luvit/luv"; + description = "Bare libuv bindings for lua"; + license = { + fullName = "Apache 2.0"; + }; + }; + }; luxio = buildLuaPackage rec { name = "luxio-${version}"; version = "13";