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

luaPackages.luv: cleanup build #80528

Closed
wants to merge 11 commits into from
7 changes: 3 additions & 4 deletions pkgs/applications/editors/neovim/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ in
libtermkey
libuv
libvterm-neovim
lua.pkgs.luv.libluv
lua.pkgs.luv
msgpack
ncurses
neovimLuaEnv
Expand Down Expand Up @@ -79,9 +79,8 @@ 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"
# TODO: Check if that's needed on darwin
doronbehar marked this conversation as resolved.
Show resolved Hide resolved
++ optional (stdenv.isDarwin) "-DLIBLUV_LIBRARY=${lua.pkgs.luv}/lib/lua/${lua.luaversion}/libluv.dylib"
++ optional doCheck "-DBUSTED_PRG=${neovimLuaEnv}/bin/busted"
++ optional (!lua.pkgs.isLuaJIT) "-DPREFER_LUA=ON"
;
Expand Down
65 changes: 40 additions & 25 deletions pkgs/development/lua-modules/overrides.nix
Original file line number Diff line number Diff line change
Expand Up @@ -264,36 +264,51 @@ with super;
disabled = luaOlder "5.1" || (luaAtLeast "5.4");
});

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
'';
luv = pkgs.stdenv.mkDerivation rec {
doronbehar marked this conversation as resolved.
Show resolved Hide resolved

buildInputs = [ pkgs.libuv ];
pname = super.luv.pname;
version = super.luv.version;

src = pkgs.fetchFromGitHub {
owner = "luvit";
repo = pname;
rev = version;
sha256 = "0lg3kncaka1mx18k0w4wsylsa6xnp7m11n68wgn38sph7f2nn1x9";
};

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
'';
# So we can be sure no internal dependency is used from the repo and that
# everything is provided by us
postUnpack = ''
rm -rf deps
'';

nativeBuildInputs = [ pkgs.fixDarwinDylibNames ];
cmakeFlags = [
"-DWITH_SHARED_LIBUV=ON"
"-DLUA_BUILD_TYPE=System"
"-DBUILD_MODULE=OFF"
"-DBUILD_SHARED_LIBS=ON"
"-DLUA_COMPAT53_DIR=${super.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");
});
};
});
buildInputs = [ pkgs.libuv ];

nativeBuildInputs = [
pkgs.cmake
super.lua.pkgs.compat53
]
# TODO: Check if that's needed on darwin
++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
doronbehar marked this conversation as resolved.
Show resolved Hide resolved
pkgs.fixDarwinDylibNames
]
;
# Fixup linking libluv.dylib, for some reason it's not linked against lua correctly.
# TODO: Check if that's needed on darwin
doronbehar marked this conversation as resolved.
Show resolved Hide resolved
NIX_LDFLAGS = pkgs.lib.optionalString pkgs.stdenv.isDarwin
(if isLuaJIT then "-lluajit-${lua.luaversion}" else "-llua");
Comment on lines +295 to +296
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
NIX_LDFLAGS = pkgs.lib.optionalString pkgs.stdenv.isDarwin
(if isLuaJIT then "-lluajit-${lua.luaversion}" else "-llua");
NIX_LDFLAGS = pkgs.lib.optionalString pkgs.stdenv.isDarwin (if isLuaJIT then "-lluajit-${lua.luaversion}" else "-llua");

propagatedBuildInputs = [ lua ];

meta = super.luv.meta;
};

rapidjson = super.rapidjson.override({
preBuild = ''
Expand Down