git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #166162 from teto/lua-checks-pr
commite98e3a2365fc30eb8a7cdbda726e304451843097 authorMatthieu Coudron <teto@users.noreply.github.com> dateThu 31 Mar 2022, 16:12 (5 years ago) parent17e5adaeb54094
9 files changed+75−167
pkgs/applications/editors/neovim/default.nix+11−20 pkgs/development/lua-modules/generated-packages.nix+17−7 pkgs/development/lua-modules/lib.nix+5−2 pkgs/development/lua-modules/overrides.nix+36−23 pkgs/development/tools/misc/luarocks/3.7.nix−81 pkgs/development/tools/misc/luarocks/darwin-3.1.3.patch−24 pkgs/development/tools/misc/luarocks/default.nix+3−3 pkgs/development/tools/misc/luarocks/luarocks-nix.nix+2−2 pkgs/top-level/lua-packages.nix+1−5
pkgs/applications/editors/neovim/default.nix+11−20
@@ -5,7 +5,8 @@
55, tree-sitter
66, glibcLocales ? null, procps ? null
77
8−# now defaults to false because some tests can be flaky (clipboard etc)
8+# now defaults to false because some tests can be flaky (clipboard etc), see
9+# also: https://github.com/neovim/neovim/issues/16233
910, doCheck ? false
1011, nodejs ? null, fish ? null, python3 ? null
1112}:
@@ -21,14 +22,6 @@ let
2122 ));
2223
2324 pyEnv = python3.withPackages(ps: with ps; [ pynvim msgpack ]);
24−
25− # FIXME: this is verry messy and strange.
26− # see https://github.com/NixOS/nixpkgs/pull/80528
27− luv = lua.pkgs.luv;
28− luvpath = with builtins ; if stdenv.isDarwin
29− then "${luv.libluv}/lib/lua/${lua.luaversion}/libluv.${head (match "([0-9.]+).*" luv.version)}.dylib"
30− else "${luv}/lib/lua/${lua.luaversion}/luv.so";
31−
3225in
3326 stdenv.mkDerivation rec {
3427 pname = "neovim-unwrapped";
@@ -57,7 +50,11 @@ in
5750 libtermkey
5851 libuv
5952 libvterm-neovim
60− luv.libluv
53+ # This is actually a c library, hence it's not included in neovimLuaEnv,
54+ # see:
55+ # https://github.com/luarocks/luarocks/issues/1402#issuecomment-1080616570
56+ # and it's definition at: pkgs/development/lua-modules/overrides.nix
57+ lua.pkgs.libluv
6158 msgpack
6259 ncurses
6360 neovimLuaEnv
@@ -97,12 +94,12 @@ in
9794 disallowedReferences = [ stdenv.cc ];
9895
9996 cmakeFlags = [
100− "-DGPERF_PRG=${gperf}/bin/gperf"
101− "-DLUA_PRG=${neovimLuaEnv.interpreter}"
102− "-DLIBLUV_LIBRARY=${luvpath}"
97+ # Don't use downloaded dependencies. At the end of the configurePhase one
98+ # can spot that cmake says this option was "not used by the project".
99+ # That's because all dependencies were found and
100+ # third-party/CMakeLists.txt is not read at all.
103101 "-DUSE_BUNDLED=OFF"
104102 ]
105− ++ optional doCheck "-DBUSTED_PRG=${neovimLuaEnv}/bin/busted"
106103 ++ optional (!lua.pkgs.isLuaJIT) "-DPREFER_LUA=ON"
107104 ;
108105
@@ -113,12 +110,6 @@ in
113110 substituteInPlace src/nvim/CMakeLists.txt --replace " util" ""
114111 '';
115112
116− # For treesitter plugins, libstdc++.so.6, or equivalent will be needed
117− NIX_LDFLAGS =
118− lib.optionals stdenv.cc.isGNU [ "-lstdc++"]
119− ++ lib.optionals stdenv.cc.isClang [ "-lc++" ];
120−
121− # export PATH=$PWD/build/bin:${PATH}
122113 shellHook=''
123114 export VIMRUNTIME=$PWD/runtime
124115 '';
pkgs/development/lua-modules/generated-packages.nix+17−7
@@ -2028,22 +2028,32 @@ buildLuarocksPackage {
20282028 };
20292029}) {};
20302030
2031−luv = callPackage({ buildLuarocksPackage, luaOlder, luaAtLeast
2032−, fetchurl, lua
2031+luv = callPackage ({ buildLuarocksPackage, luaOlder, luaAtLeast
2032+, cmake, fetchurl, lua
20332033}:
20342034buildLuarocksPackage {
20352035 pname = "luv";
20362036 version = "1.43.0-0";
20372037 knownRockspec = (fetchurl {
2038− url = "https://raw.githubusercontent.com/rocks-moonscript-org/moonrocks-mirror/master/luv-1.43.0-0.rockspec";
2038+ url = "https://luarocks.org/luv-1.43.0-0.rockspec";
20392039 sha256 = "0z5a7yp20xbb3f9w73skm9fj89gxxqv72nrxjq3kycsc6c2v3m8f";
20402040 }).outPath;
2041− src = fetchurl {
2042− url = "https://github.com/luvit/luv/releases/download/1.43.0-0/luv-1.43.0-0.tar.gz";
2043− sha256 = "1qlx1r79sfn8r20yx19bhdr0v58ykpwgwzy5vma9p2ngrlynyyjn";
2044− };
2041+
2042+ src = fetchgit ( removeAttrs (builtins.fromJSON ''{
2043+ "url": "https://github.com/luvit/luv.git",
2044+ "rev": "1.43.0-0",
2045+ "date": "2022-03-12T16:05:50+08:00",
2046+ "path": "/nix/store/d7f3sdw5l0cm8xkjdm4m6jkmx794w48j-luv",
2047+ "sha256": "sha256-CcUX69XzgWlJEwHUhhtqs9sDA5TNIusKek5yV2Nt3Wc=",
2048+ "fetchLFS": false,
2049+ "fetchSubmodules": true,
2050+ "deepClone": false,
2051+ "leaveDotGit": false
2052+}
2053+ '') ["date" "path"]) ;
20452054
20462055 disabled = with lua; (luaOlder "5.1");
2056+ nativeBuildInputs = [ cmake ];
20472057 propagatedBuildInputs = [ lua ];
20482058
20492059 meta = {
pkgs/development/lua-modules/lib.nix+5−2
@@ -82,6 +82,8 @@ rec {
8282 */
8383 generateLuarocksConfig = {
8484 externalDeps
85+
86+ # a list of lua derivations
8587 , requiredLuaRocks
8688 , extraVariables ? {}
8789 , rocksSubdir
@@ -113,9 +115,10 @@ rec {
113115 -- To prevent collisions when creating environments, we install the rock
114116 -- files into per-package subdirectories
115117 rocks_subdir = '${rocksSubdir}'
116− -- Then we need to tell luarocks where to find the rock files per
117− -- dependency
118+ -- first tree is the default target where new rocks are installed,
119+ -- any other trees in the list are treated as additional sources of installed rocks for matching dependencies.
118120 rocks_trees = {
121+ {name = "current", root = '${placeholder "out"}', rocks_dir = "current" },
119122 ${lib.concatStringsSep "\n, " rocksTrees}
120123 }
121124 '' + lib.optionalString lua.pkgs.isLuaJIT ''
pkgs/development/lua-modules/overrides.nix+36−23
@@ -280,34 +280,47 @@ with prev;
280280 '';
281281 });
282282
283− luv = prev.lib.overrideLuarocks prev.luv (drv: {
284− # Use system libuv instead of building local and statically linking
285− # This is a hacky way to specify -DWITH_SHARED_LIBUV=ON which
286− # is not possible with luarocks and the current luv rockspec
287− # While at it, remove bundled libuv source entirely to be sure.
288− # We may wish to drop bundled lua submodules too...
289− preBuild = ''
290− sed -i 's,\(option(WITH_SHARED_LIBUV.*\)OFF,\1ON,' CMakeLists.txt
291− rm -rf deps/libuv
292− '';
293283
294− buildInputs = [ pkgs.libuv ];
284+ # as advised in https://github.com/luarocks/luarocks/issues/1402#issuecomment-1080616570
285+ # we shouldn't use luarocks machinery to build complex cmake components
286+ libluv = pkgs.stdenv.mkDerivation {
287+
288+ inherit (prev.luv) pname version meta src;
289+
290+ cmakeFlags = [
291+ "-DBUILD_SHARED_LIBS=ON"
292+ "-DBUILD_MODULE=OFF"
293+ "-DWITH_SHARED_LIBUV=ON"
294+ ];
295+
296+ buildInputs = [ pkgs.libuv ];
297+
298+ nativeBuildInputs = [ pkgs.pkg-config pkgs.fixDarwinDylibNames pkgs.cmake ];
299+ # Fixup linking libluv.dylib, for some reason it's not linked against lua correctly.
300+ NIX_LDFLAGS = pkgs.lib.optionalString pkgs.stdenv.isDarwin
301+ (if isLuaJIT then "-lluajit-${lua.luaversion}" else "-llua");
302+ };
295303
296− passthru = {
297− libluv = final.luv.overrideAttrs (oa: {
298− preBuild = final.luv.preBuild + ''
299− sed -i 's,\(option(BUILD_MODULE.*\)ON,\1OFF,' CMakeLists.txt
300− sed -i 's,\(option(BUILD_SHARED_LIBS.*\)OFF,\1ON,' CMakeLists.txt
301− sed -i 's,${"\${.*INSTALL_INC_DIR}"},${placeholder "out"}/include/luv,' CMakeLists.txt
302− '';
304+ luv = prev.lib.overrideLuarocks prev.luv (drv: {
305+
306+ buildInputs = [ pkgs.pkg-config pkgs.libuv ];
303307
304− nativeBuildInputs = [ pkgs.fixDarwinDylibNames ];
308+ doInstallCheck = true;
305309
306− # Fixup linking libluv.dylib, for some reason it's not linked against lua correctly.
307− NIX_LDFLAGS = pkgs.lib.optionalString pkgs.stdenv.isDarwin
308− (if isLuaJIT then "-lluajit-${lua.luaversion}" else "-llua");
309− });
310+ # Use system libuv instead of building local and statically linking
311+ extraVariables = {
312+ "WITH_SHARED_LIBUV" = "ON";
310313 };
314+
315+ # we unset the LUA_PATH since the hook erases the interpreter defaults (To fix)
316+ installCheckPhase = ''
317+ unset LUA_PATH
318+ rm tests/test-{dns,thread}.lua
319+ lua tests/run.lua
320+ '';
321+
322+ passthru.libluv = final.libluv;
323+
311324 });
312325
313326 lyaml = prev.lib.overrideLuarocks prev.lyaml (oa: {
pkgs/development/tools/misc/luarocks/3.7.nixdeleted−81
@@ -1,81 +0,0 @@
1−{lib, stdenv, fetchFromGitHub
2−, curl, makeWrapper, which, unzip
3−, lua
4−# for 'luarocks pack'
5−, zip
6−# some packages need to be compiled with cmake
7−, cmake
8−, installShellFiles
9−}:
10−
11−stdenv.mkDerivation rec {
12− pname = "luarocks";
13− version = "3.7.0";
14−
15− src = fetchFromGitHub {
16− owner = "luarocks";
17− repo = "luarocks";
18− rev = "v${version}";
19− sha256 = "1sn2j7hv8nbdjqj1747glk9770zw8q5v8ivaxhvwbk3vl038ck9d";
20− };
21−
22− patches = [ ./darwin-3.7.0.patch ];
23−
24− postPatch = lib.optionalString stdenv.targetPlatform.isDarwin ''
25− substituteInPlace src/luarocks/core/cfg.lua --subst-var-by 'darwinMinVersion' '${stdenv.targetPlatform.darwinMinVersion}'
26− '';
27−
28− preConfigure = ''
29− lua -e "" || {
30− luajit -e "" && {
31− export LUA_SUFFIX=jit
32− configureFlags="$configureFlags --lua-suffix=$LUA_SUFFIX"
33− }
34− }
35− lua_inc="$(echo "${lua}/include"/*/)"
36− if test -n "$lua_inc"; then
37− configureFlags="$configureFlags --with-lua-include=$lua_inc"
38− fi
39− '';
40−
41− nativeBuildInputs = [ makeWrapper installShellFiles ];
42−
43− buildInputs = [ lua curl which ];
44−
45− postInstall = ''
46− sed -e "1s@.*@#! ${lua}/bin/lua$LUA_SUFFIX@" -i "$out"/bin/*
47− for i in "$out"/bin/*; do
48− test -L "$i" || {
49− wrapProgram "$i" \
50− --suffix LUA_PATH ";" "$(echo "$out"/share/lua/*/)?.lua" \
51− --suffix LUA_PATH ";" "$(echo "$out"/share/lua/*/)?/init.lua" \
52− --suffix LUA_CPATH ";" "$(echo "$out"/lib/lua/*/)?.so" \
53− --suffix LUA_CPATH ";" "$(echo "$out"/share/lua/*/)?/init.lua"
54− }
55− done
56−
57− installShellCompletion --cmd luarocks --bash <($out/bin/luarocks completion bash)
58− installShellCompletion --cmd luarocks --zsh <($out/bin/luarocks completion zsh)
59− '';
60−
61− propagatedBuildInputs = [ zip unzip cmake ];
62−
63− # unpack hook for src.rock and rockspec files
64− setupHook = ./setup-hook.sh;
65−
66− # cmake is just to compile packages with "cmake" buildType, not luarocks itself
67− dontUseCmakeConfigure = true;
68−
69− shellHook = ''
70− export PATH="src/bin:''${PATH:-}"
71− export LUA_PATH="src/?.lua;''${LUA_PATH:-}"
72− '';
73−
74− meta = with lib; {
75− description = "A package manager for Lua";
76− license = licenses.mit ;
77− maintainers = with maintainers; [raskin teto];
78− platforms = platforms.linux ++ platforms.darwin;
79− downloadPage = "http://luarocks.org/releases/";
80− };
81−}
pkgs/development/tools/misc/luarocks/darwin-3.1.3.patchdeleted−24
@@ -1,24 +0,0 @@
1−diff --git a/src/luarocks/core/cfg.lua b/src/luarocks/core/cfg.lua
2−index c5af5a2..1949fdc 100644
3−--- a/src/luarocks/core/cfg.lua
4−+++ b/src/luarocks/core/cfg.lua
5−@@ -425,7 +425,7 @@ local function make_defaults(lua_version, target_cpu, platforms, home)
6− defaults.external_lib_extension = "dylib"
7− defaults.arch = "macosx-"..target_cpu
8− defaults.variables.LIBFLAG = "-bundle -undefined dynamic_lookup -all_load"
9−- local version = util.popen_read("sw_vers -productVersion")
10−+ local version = os.getenv("MACOSX_DEPLOYMENT_TARGET") or "@darwinMinVersion@"
11− version = tonumber(version and version:match("^[^.]+%.([^.]+)")) or 3
12− if version >= 10 then
13− version = 8
14−@@ -434,8 +434,8 @@ local function make_defaults(lua_version, target_cpu, platforms, home)
15− else
16− defaults.gcc_rpath = false
17− end
18−- defaults.variables.CC = "env MACOSX_DEPLOYMENT_TARGET=10."..version.." gcc"
19−- defaults.variables.LD = "env MACOSX_DEPLOYMENT_TARGET=10."..version.." gcc"
20−+ defaults.variables.CC = "env MACOSX_DEPLOYMENT_TARGET=10."..version.." clang"
21−+ defaults.variables.LD = "env MACOSX_DEPLOYMENT_TARGET=10."..version.." clang"
22− defaults.web_browser = "open"
23− end
24−
pkgs/development/tools/misc/luarocks/default.nix+3−3
@@ -10,16 +10,16 @@
1010
1111stdenv.mkDerivation rec {
1212 pname = "luarocks";
13− version = "3.2.1";
13+ version = "3.8.0";
1414
1515 src = fetchFromGitHub {
1616 owner = "luarocks";
1717 repo = "luarocks";
1818 rev = "v${version}";
19− sha256 = "0viiafmb8binksda79ah828q1dfnb6jsqlk7vyndl2xvx9yfn4y2";
19+ sha256 = "sha256-tPSAtveOodF2w54d82hEyaTj91imtySJUTsk/gje2dQ=";
2020 };
2121
22− patches = [ ./darwin-3.1.3.patch ];
22+ patches = [ ./darwin-3.7.0.patch ];
2323
2424 postPatch = lib.optionalString stdenv.targetPlatform.isDarwin ''
2525 substituteInPlace src/luarocks/core/cfg.lua --subst-var-by 'darwinMinVersion' '${stdenv.targetPlatform.darwinMinVersion}'
pkgs/development/tools/misc/luarocks/luarocks-nix.nix+2−2
@@ -5,8 +5,8 @@ luarocks.overrideAttrs(old: {
55 src = fetchFromGitHub {
66 owner = "nix-community";
77 repo = "luarocks-nix";
8− rev = "standalone";
9− sha256 = "sha256-53Zi+GTayO9EQTCIVrzPeRRHeIkHLqy0mHyBDzbcQQk=";
8+ rev = "6aa1d59e88eaef72d699477c3e7aa98b274ca405";
9+ sha256 = "sha256-nQLl01RFYZYhpShz0gHxnhwFPvTgALpAbjFPIuTD2D0=";
1010 };
1111 patches = [];
1212
pkgs/top-level/lua-packages.nix+1−5
@@ -63,11 +63,7 @@ in
6363 inherit (pkgs) makeSetupHook makeWrapper;
6464 };
6565
66− luarocks = callPackage ../development/tools/misc/luarocks {
67− inherit lua lib;
68− };
69−
70− luarocks-3_7 = callPackage ../development/tools/misc/luarocks/3.7.nix {
66+ luarocks = callPackage ../development/tools/misc/luarocks/default.nix {
7167 inherit lua lib;
7268 };
7369