Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

luarocks-nix: bump #166162

Merged
merged 7 commits into from
Mar 31, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 9 additions & 19 deletions pkgs/applications/editors/neovim/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,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";
Expand Down Expand Up @@ -57,7 +49,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
Expand Down Expand Up @@ -97,12 +93,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"
teto marked this conversation as resolved.
Show resolved Hide resolved
++ optional (!lua.pkgs.isLuaJIT) "-DPREFER_LUA=ON"
;

Expand All @@ -113,12 +109,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
'';
Expand Down
24 changes: 17 additions & 7 deletions pkgs/development/lua-modules/generated-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
7 changes: 5 additions & 2 deletions pkgs/development/lua-modules/lib.nix
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ rec {
*/
generateLuarocksConfig = {
externalDeps

# a list of lua derivations
, requiredLuaRocks
, extraVariables ? {}
, rocksSubdir
Expand Down Expand Up @@ -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 ''
Expand Down
59 changes: 36 additions & 23 deletions pkgs/development/lua-modules/overrides.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
81 changes: 0 additions & 81 deletions pkgs/development/tools/misc/luarocks/3.7.nix

This file was deleted.

24 changes: 0 additions & 24 deletions pkgs/development/tools/misc/luarocks/darwin-3.1.3.patch

This file was deleted.

6 changes: 3 additions & 3 deletions pkgs/development/tools/misc/luarocks/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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}'
Expand Down
4 changes: 2 additions & 2 deletions pkgs/development/tools/misc/luarocks/luarocks-nix.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];

Expand Down
6 changes: 1 addition & 5 deletions pkgs/top-level/lua-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down