Merge pull request #244252 from Artturin/nvimcrossfix

This commit is contained in:
Artturi 2023-07-26 07:00:56 +03:00 committed by GitHub
commit 80bd687e64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,6 +4,7 @@
, libvterm-neovim , libvterm-neovim
, tree-sitter , tree-sitter
, fetchurl , fetchurl
, buildPackages
, treesitter-parsers ? import ./treesitter-parsers.nix { inherit fetchurl; } , treesitter-parsers ? import ./treesitter-parsers.nix { inherit fetchurl; }
, CoreServices , CoreServices
, glibcLocales ? null, procps ? null , glibcLocales ? null, procps ? null
@ -15,22 +16,32 @@
}: }:
let let
neovimLuaEnv = lua.withPackages(ps: requiredLuaPkgs = ps: (with ps; [
(with ps; [ lpeg luabitop mpack ] lpeg
++ lib.optionals doCheck [ luabitop
nvim-client luv coxpcall busted luafilesystem penlight inspect mpack
] ] ++ lib.optionals doCheck [
)); nvim-client
luv
coxpcall
busted
luafilesystem
penlight
inspect
]
);
neovimLuaEnv = lua.withPackages requiredLuaPkgs;
neovimLuaEnvOnBuild = lua.luaOnBuild.withPackages requiredLuaPkgs;
codegenLua = codegenLua =
if lua.pkgs.isLuaJIT if lua.luaOnBuild.pkgs.isLuaJIT
then then
let deterministicLuajit = let deterministicLuajit =
lua.override { lua.luaOnBuild.override {
deterministicStringIds = true; deterministicStringIds = true;
self = deterministicLuajit; self = deterministicLuajit;
}; };
in deterministicLuajit.withPackages(ps: [ ps.mpack ps.lpeg ]) in deterministicLuajit.withPackages(ps: [ ps.mpack ps.lpeg ])
else lua; else lua.luaOnBuild;
pyEnv = python3.withPackages(ps: with ps; [ pynvim msgpack ]); pyEnv = python3.withPackages(ps: with ps; [ pynvim msgpack ]);
in in
@ -99,6 +110,11 @@ in
# nvim --version output retains compilation flags and references to build tools # nvim --version output retains compilation flags and references to build tools
postPatch = '' postPatch = ''
substituteInPlace src/nvim/version.c --replace NVIM_VERSION_CFLAGS ""; substituteInPlace src/nvim/version.c --replace NVIM_VERSION_CFLAGS "";
'' + lib.optionalString (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
sed -i runtime/CMakeLists.txt \
-e "s|\".*/bin/nvim|\${stdenv.hostPlatform.emulator buildPackages} &|g"
sed -i src/nvim/po/CMakeLists.txt \
-e "s|\$<TARGET_FILE:nvim|\${stdenv.hostPlatform.emulator buildPackages} &|g"
''; '';
# check that the above patching actually works # check that the above patching actually works
disallowedReferences = [ stdenv.cc ] ++ lib.optional (lua != codegenLua) codegenLua; disallowedReferences = [ stdenv.cc ] ++ lib.optional (lua != codegenLua) codegenLua;
@ -117,6 +133,7 @@ in
cmakeFlagsArray+=( cmakeFlagsArray+=(
"-DLUAC_PRG=${codegenLua}/bin/luajit -b -s %s -" "-DLUAC_PRG=${codegenLua}/bin/luajit -b -s %s -"
"-DLUA_GEN_PRG=${codegenLua}/bin/luajit" "-DLUA_GEN_PRG=${codegenLua}/bin/luajit"
"-DLUA_PRG=${neovimLuaEnvOnBuild}/bin/luajit"
) )
'' + lib.optionalString stdenv.isDarwin '' '' + lib.optionalString stdenv.isDarwin ''
substituteInPlace src/nvim/CMakeLists.txt --replace " util" "" substituteInPlace src/nvim/CMakeLists.txt --replace " util" ""