diff --git a/pkgs/applications/editors/neovim/default.nix b/pkgs/applications/editors/neovim/default.nix index 03cc0b35b8d39..e06096933c975 100644 --- a/pkgs/applications/editors/neovim/default.nix +++ b/pkgs/applications/editors/neovim/default.nix @@ -5,7 +5,8 @@ , tree-sitter , glibcLocales ? null, procps ? null -# now defaults to false because some tests can be flaky (clipboard etc) +# now defaults to false because some tests can be flaky (clipboard etc), see +# also: https://github.com/neovim/neovim/issues/16233 , doCheck ? false , nodejs ? null, fish ? null, python3 ? null }: @@ -21,14 +22,6 @@ let )); pyEnv = python3.withPackages(ps: with ps; [ pynvim msgpack ]); - - # FIXME: this is verry messy and strange. - # see https://github.com/NixOS/nixpkgs/pull/80528 - luv = lua.pkgs.luv; - luvpath = with builtins ; if stdenv.isDarwin - then "${luv.libluv}/lib/lua/${lua.luaversion}/libluv.${head (match "([0-9.]+).*" luv.version)}.dylib" - else "${luv}/lib/lua/${lua.luaversion}/luv.so"; - in stdenv.mkDerivation rec { pname = "neovim-unwrapped"; @@ -57,7 +50,11 @@ in libtermkey libuv libvterm-neovim - luv.libluv + # This is actually a c library, hence it's not included in neovimLuaEnv, + # see: + # https://github.com/luarocks/luarocks/issues/1402#issuecomment-1080616570 + # and it's definition at: pkgs/development/lua-modules/overrides.nix + lua.pkgs.libluv msgpack ncurses neovimLuaEnv @@ -97,12 +94,12 @@ in disallowedReferences = [ stdenv.cc ]; cmakeFlags = [ - "-DGPERF_PRG=${gperf}/bin/gperf" - "-DLUA_PRG=${neovimLuaEnv.interpreter}" - "-DLIBLUV_LIBRARY=${luvpath}" + # Don't use downloaded dependencies. At the end of the configurePhase one + # can spot that cmake says this option was "not used by the project". + # That's because all dependencies were found and + # third-party/CMakeLists.txt is not read at all. "-DUSE_BUNDLED=OFF" ] - ++ optional doCheck "-DBUSTED_PRG=${neovimLuaEnv}/bin/busted" ++ optional (!lua.pkgs.isLuaJIT) "-DPREFER_LUA=ON" ; @@ -113,12 +110,6 @@ in substituteInPlace src/nvim/CMakeLists.txt --replace " util" "" ''; - # For treesitter plugins, libstdc++.so.6, or equivalent will be needed - NIX_LDFLAGS = - lib.optionals stdenv.cc.isGNU [ "-lstdc++"] - ++ lib.optionals stdenv.cc.isClang [ "-lc++" ]; - - # export PATH=$PWD/build/bin:${PATH} shellHook='' export VIMRUNTIME=$PWD/runtime ''; diff --git a/pkgs/development/lua-modules/generated-packages.nix b/pkgs/development/lua-modules/generated-packages.nix index 71d85a776bb29..4269d7eb0d7e6 100644 --- a/pkgs/development/lua-modules/generated-packages.nix +++ b/pkgs/development/lua-modules/generated-packages.nix @@ -2028,22 +2028,32 @@ buildLuarocksPackage { }; }) {}; -luv = callPackage({ buildLuarocksPackage, luaOlder, luaAtLeast -, fetchurl, lua +luv = callPackage ({ buildLuarocksPackage, luaOlder, luaAtLeast +, cmake, fetchurl, lua }: buildLuarocksPackage { pname = "luv"; version = "1.43.0-0"; knownRockspec = (fetchurl { - url = "https://raw.githubusercontent.com/rocks-moonscript-org/moonrocks-mirror/master/luv-1.43.0-0.rockspec"; + url = "https://luarocks.org/luv-1.43.0-0.rockspec"; sha256 = "0z5a7yp20xbb3f9w73skm9fj89gxxqv72nrxjq3kycsc6c2v3m8f"; }).outPath; - src = fetchurl { - url = "https://github.com/luvit/luv/releases/download/1.43.0-0/luv-1.43.0-0.tar.gz"; - sha256 = "1qlx1r79sfn8r20yx19bhdr0v58ykpwgwzy5vma9p2ngrlynyyjn"; - }; + + src = fetchgit ( removeAttrs (builtins.fromJSON ''{ + "url": "https://github.com/luvit/luv.git", + "rev": "1.43.0-0", + "date": "2022-03-12T16:05:50+08:00", + "path": "/nix/store/d7f3sdw5l0cm8xkjdm4m6jkmx794w48j-luv", + "sha256": "sha256-CcUX69XzgWlJEwHUhhtqs9sDA5TNIusKek5yV2Nt3Wc=", + "fetchLFS": false, + "fetchSubmodules": true, + "deepClone": false, + "leaveDotGit": false +} + '') ["date" "path"]) ; disabled = with lua; (luaOlder "5.1"); + nativeBuildInputs = [ cmake ]; propagatedBuildInputs = [ lua ]; meta = { diff --git a/pkgs/development/lua-modules/lib.nix b/pkgs/development/lua-modules/lib.nix index bd952e7b8ce78..5079a4b25405c 100644 --- a/pkgs/development/lua-modules/lib.nix +++ b/pkgs/development/lua-modules/lib.nix @@ -82,6 +82,8 @@ rec { */ generateLuarocksConfig = { externalDeps + + # a list of lua derivations , requiredLuaRocks , extraVariables ? {} , rocksSubdir @@ -113,9 +115,10 @@ rec { -- To prevent collisions when creating environments, we install the rock -- files into per-package subdirectories rocks_subdir = '${rocksSubdir}' - -- Then we need to tell luarocks where to find the rock files per - -- dependency + -- first tree is the default target where new rocks are installed, + -- any other trees in the list are treated as additional sources of installed rocks for matching dependencies. rocks_trees = { + {name = "current", root = '${placeholder "out"}', rocks_dir = "current" }, ${lib.concatStringsSep "\n, " rocksTrees} } '' + lib.optionalString lua.pkgs.isLuaJIT '' diff --git a/pkgs/development/lua-modules/overrides.nix b/pkgs/development/lua-modules/overrides.nix index 9190f1fff8643..7f85ddb783a5f 100644 --- a/pkgs/development/lua-modules/overrides.nix +++ b/pkgs/development/lua-modules/overrides.nix @@ -280,34 +280,47 @@ with prev; ''; }); - luv = prev.lib.overrideLuarocks prev.luv (drv: { - # 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 - ''; - buildInputs = [ pkgs.libuv ]; + # as advised in https://github.com/luarocks/luarocks/issues/1402#issuecomment-1080616570 + # we shouldn't use luarocks machinery to build complex cmake components + libluv = pkgs.stdenv.mkDerivation { + + inherit (prev.luv) pname version meta src; + + cmakeFlags = [ + "-DBUILD_SHARED_LIBS=ON" + "-DBUILD_MODULE=OFF" + "-DWITH_SHARED_LIBUV=ON" + ]; + + buildInputs = [ pkgs.libuv ]; + + nativeBuildInputs = [ pkgs.pkg-config pkgs.fixDarwinDylibNames pkgs.cmake ]; + # 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"); + }; - passthru = { - libluv = final.luv.overrideAttrs (oa: { - preBuild = final.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 - ''; + luv = prev.lib.overrideLuarocks prev.luv (drv: { + + buildInputs = [ pkgs.pkg-config pkgs.libuv ]; - nativeBuildInputs = [ pkgs.fixDarwinDylibNames ]; + doInstallCheck = true; - # 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"); - }); + # Use system libuv instead of building local and statically linking + extraVariables = { + "WITH_SHARED_LIBUV" = "ON"; }; + + # we unset the LUA_PATH since the hook erases the interpreter defaults (To fix) + installCheckPhase = '' + unset LUA_PATH + rm tests/test-{dns,thread}.lua + lua tests/run.lua + ''; + + passthru.libluv = final.libluv; + }); lyaml = prev.lib.overrideLuarocks prev.lyaml (oa: { diff --git a/pkgs/development/tools/misc/luarocks/3.7.nix b/pkgs/development/tools/misc/luarocks/3.7.nix deleted file mode 100644 index 95fa79c6d125b..0000000000000 --- a/pkgs/development/tools/misc/luarocks/3.7.nix +++ /dev/null @@ -1,81 +0,0 @@ -{lib, stdenv, fetchFromGitHub -, curl, makeWrapper, which, unzip -, lua -# for 'luarocks pack' -, zip -# some packages need to be compiled with cmake -, cmake -, installShellFiles -}: - -stdenv.mkDerivation rec { - pname = "luarocks"; - version = "3.7.0"; - - src = fetchFromGitHub { - owner = "luarocks"; - repo = "luarocks"; - rev = "v${version}"; - sha256 = "1sn2j7hv8nbdjqj1747glk9770zw8q5v8ivaxhvwbk3vl038ck9d"; - }; - - patches = [ ./darwin-3.7.0.patch ]; - - postPatch = lib.optionalString stdenv.targetPlatform.isDarwin '' - substituteInPlace src/luarocks/core/cfg.lua --subst-var-by 'darwinMinVersion' '${stdenv.targetPlatform.darwinMinVersion}' - ''; - - preConfigure = '' - lua -e "" || { - luajit -e "" && { - export LUA_SUFFIX=jit - configureFlags="$configureFlags --lua-suffix=$LUA_SUFFIX" - } - } - lua_inc="$(echo "${lua}/include"/*/)" - if test -n "$lua_inc"; then - configureFlags="$configureFlags --with-lua-include=$lua_inc" - fi - ''; - - nativeBuildInputs = [ makeWrapper installShellFiles ]; - - buildInputs = [ lua curl which ]; - - postInstall = '' - sed -e "1s@.*@#! ${lua}/bin/lua$LUA_SUFFIX@" -i "$out"/bin/* - for i in "$out"/bin/*; do - test -L "$i" || { - wrapProgram "$i" \ - --suffix LUA_PATH ";" "$(echo "$out"/share/lua/*/)?.lua" \ - --suffix LUA_PATH ";" "$(echo "$out"/share/lua/*/)?/init.lua" \ - --suffix LUA_CPATH ";" "$(echo "$out"/lib/lua/*/)?.so" \ - --suffix LUA_CPATH ";" "$(echo "$out"/share/lua/*/)?/init.lua" - } - done - - installShellCompletion --cmd luarocks --bash <($out/bin/luarocks completion bash) - installShellCompletion --cmd luarocks --zsh <($out/bin/luarocks completion zsh) - ''; - - propagatedBuildInputs = [ zip unzip cmake ]; - - # unpack hook for src.rock and rockspec files - setupHook = ./setup-hook.sh; - - # cmake is just to compile packages with "cmake" buildType, not luarocks itself - dontUseCmakeConfigure = true; - - shellHook = '' - export PATH="src/bin:''${PATH:-}" - export LUA_PATH="src/?.lua;''${LUA_PATH:-}" - ''; - - meta = with lib; { - description = "A package manager for Lua"; - license = licenses.mit ; - maintainers = with maintainers; [raskin teto]; - platforms = platforms.linux ++ platforms.darwin; - downloadPage = "http://luarocks.org/releases/"; - }; -} diff --git a/pkgs/development/tools/misc/luarocks/darwin-3.1.3.patch b/pkgs/development/tools/misc/luarocks/darwin-3.1.3.patch deleted file mode 100644 index 8070af173aaf7..0000000000000 --- a/pkgs/development/tools/misc/luarocks/darwin-3.1.3.patch +++ /dev/null @@ -1,24 +0,0 @@ -diff --git a/src/luarocks/core/cfg.lua b/src/luarocks/core/cfg.lua -index c5af5a2..1949fdc 100644 ---- a/src/luarocks/core/cfg.lua -+++ b/src/luarocks/core/cfg.lua -@@ -425,7 +425,7 @@ local function make_defaults(lua_version, target_cpu, platforms, home) - defaults.external_lib_extension = "dylib" - defaults.arch = "macosx-"..target_cpu - defaults.variables.LIBFLAG = "-bundle -undefined dynamic_lookup -all_load" -- local version = util.popen_read("sw_vers -productVersion") -+ local version = os.getenv("MACOSX_DEPLOYMENT_TARGET") or "@darwinMinVersion@" - version = tonumber(version and version:match("^[^.]+%.([^.]+)")) or 3 - if version >= 10 then - version = 8 -@@ -434,8 +434,8 @@ local function make_defaults(lua_version, target_cpu, platforms, home) - else - defaults.gcc_rpath = false - end -- defaults.variables.CC = "env MACOSX_DEPLOYMENT_TARGET=10."..version.." gcc" -- defaults.variables.LD = "env MACOSX_DEPLOYMENT_TARGET=10."..version.." gcc" -+ defaults.variables.CC = "env MACOSX_DEPLOYMENT_TARGET=10."..version.." clang" -+ defaults.variables.LD = "env MACOSX_DEPLOYMENT_TARGET=10."..version.." clang" - defaults.web_browser = "open" - end - diff --git a/pkgs/development/tools/misc/luarocks/default.nix b/pkgs/development/tools/misc/luarocks/default.nix index 58f5996992af6..b34c889792113 100644 --- a/pkgs/development/tools/misc/luarocks/default.nix +++ b/pkgs/development/tools/misc/luarocks/default.nix @@ -10,16 +10,16 @@ stdenv.mkDerivation rec { pname = "luarocks"; - version = "3.2.1"; + version = "3.8.0"; src = fetchFromGitHub { owner = "luarocks"; repo = "luarocks"; rev = "v${version}"; - sha256 = "0viiafmb8binksda79ah828q1dfnb6jsqlk7vyndl2xvx9yfn4y2"; + sha256 = "sha256-tPSAtveOodF2w54d82hEyaTj91imtySJUTsk/gje2dQ="; }; - patches = [ ./darwin-3.1.3.patch ]; + patches = [ ./darwin-3.7.0.patch ]; postPatch = lib.optionalString stdenv.targetPlatform.isDarwin '' substituteInPlace src/luarocks/core/cfg.lua --subst-var-by 'darwinMinVersion' '${stdenv.targetPlatform.darwinMinVersion}' diff --git a/pkgs/development/tools/misc/luarocks/luarocks-nix.nix b/pkgs/development/tools/misc/luarocks/luarocks-nix.nix index 05770464de7d6..fe34bfd20a6f9 100644 --- a/pkgs/development/tools/misc/luarocks/luarocks-nix.nix +++ b/pkgs/development/tools/misc/luarocks/luarocks-nix.nix @@ -5,8 +5,8 @@ luarocks.overrideAttrs(old: { src = fetchFromGitHub { owner = "nix-community"; repo = "luarocks-nix"; - rev = "standalone"; - sha256 = "sha256-53Zi+GTayO9EQTCIVrzPeRRHeIkHLqy0mHyBDzbcQQk="; + rev = "6aa1d59e88eaef72d699477c3e7aa98b274ca405"; + sha256 = "sha256-nQLl01RFYZYhpShz0gHxnhwFPvTgALpAbjFPIuTD2D0="; }; patches = []; diff --git a/pkgs/top-level/lua-packages.nix b/pkgs/top-level/lua-packages.nix index efaf06d30a22b..e8ac6445d0ebf 100644 --- a/pkgs/top-level/lua-packages.nix +++ b/pkgs/top-level/lua-packages.nix @@ -63,11 +63,7 @@ in inherit (pkgs) makeSetupHook makeWrapper; }; - luarocks = callPackage ../development/tools/misc/luarocks { - inherit lua lib; - }; - - luarocks-3_7 = callPackage ../development/tools/misc/luarocks/3.7.nix { + luarocks = callPackage ../development/tools/misc/luarocks/default.nix { inherit lua lib; };