Merge pull request #166162 from teto/lua-checks-pr

This commit is contained in:
Matthieu Coudron
2022-03-31 16:12:07 +02:00
committed by GitHub
9 changed files with 75 additions and 167 deletions
+11 -20
View File
@@ -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
'';
@@ -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 = {
+5 -2
View File
@@ -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 ''
+36 -23
View File
@@ -280,34 +280,47 @@ with prev;
'';
});
# 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");
};
luv = prev.lib.overrideLuarocks prev.luv (drv: {
buildInputs = [ pkgs.pkg-config pkgs.libuv ];
doInstallCheck = true;
# 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
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
'';
buildInputs = [ pkgs.libuv ];
passthru.libluv = final.libluv;
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
'';
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");
});
};
});
lyaml = prev.lib.overrideLuarocks prev.lyaml (oa: {
@@ -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/";
};
}
@@ -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
@@ -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}'
@@ -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 = [];
+1 -5
View File
@@ -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;
};