about summary refs log tree commit diff
path: root/pkgs/applications/editors/neovim
diff options
context:
space:
mode:
authorArtturin <Artturin@artturin.com>2023-07-19 03:59:57 +0300
committerArtturin <Artturin@artturin.com>2023-07-26 06:48:56 +0300
commit81217587e6cd50d5a51c82302485016d0587bfe2 (patch)
treed9455c40fe62e3205dc9c34b1fb33432a366839e /pkgs/applications/editors/neovim
parent9baeb193078a376b5ab28fc0a83112341f48e4e2 (diff)
downloadnixlib-81217587e6cd50d5a51c82302485016d0587bfe2.tar
nixlib-81217587e6cd50d5a51c82302485016d0587bfe2.tar.gz
nixlib-81217587e6cd50d5a51c82302485016d0587bfe2.tar.bz2
nixlib-81217587e6cd50d5a51c82302485016d0587bfe2.tar.lz
nixlib-81217587e6cd50d5a51c82302485016d0587bfe2.tar.xz
nixlib-81217587e6cd50d5a51c82302485016d0587bfe2.tar.zst
nixlib-81217587e6cd50d5a51c82302485016d0587bfe2.zip
neovim-unwrapped: fix cross
sed commands are from void-packages
Diffstat (limited to 'pkgs/applications/editors/neovim')
-rw-r--r--pkgs/applications/editors/neovim/default.nix35
1 files changed, 26 insertions, 9 deletions
diff --git a/pkgs/applications/editors/neovim/default.nix b/pkgs/applications/editors/neovim/default.nix
index 7dfbebb95df1..15b9d0ba80b9 100644
--- a/pkgs/applications/editors/neovim/default.nix
+++ b/pkgs/applications/editors/neovim/default.nix
@@ -4,6 +4,7 @@
 , libvterm-neovim
 , tree-sitter
 , fetchurl
+, buildPackages
 , treesitter-parsers ? import ./treesitter-parsers.nix { inherit fetchurl; }
 , CoreServices
 , glibcLocales ? null, procps ? null
@@ -15,22 +16,32 @@
 }:
 
 let
-  neovimLuaEnv = lua.withPackages(ps:
-    (with ps; [ lpeg luabitop mpack ]
-    ++ lib.optionals doCheck [
-        nvim-client luv coxpcall busted luafilesystem penlight inspect
-      ]
-    ));
+  requiredLuaPkgs = ps: (with ps; [
+    lpeg
+    luabitop
+    mpack
+  ] ++ lib.optionals doCheck [
+    nvim-client
+    luv
+    coxpcall
+    busted
+    luafilesystem
+    penlight
+    inspect
+  ]
+  );
+  neovimLuaEnv = lua.withPackages requiredLuaPkgs;
+  neovimLuaEnvOnBuild = lua.luaOnBuild.withPackages requiredLuaPkgs;
   codegenLua =
-    if lua.pkgs.isLuaJIT
+    if lua.luaOnBuild.pkgs.isLuaJIT
       then
         let deterministicLuajit =
-          lua.override {
+          lua.luaOnBuild.override {
             deterministicStringIds = true;
             self = deterministicLuajit;
           };
         in deterministicLuajit.withPackages(ps: [ ps.mpack ps.lpeg ])
-      else lua;
+      else lua.luaOnBuild;
 
   pyEnv = python3.withPackages(ps: with ps; [ pynvim msgpack ]);
 in
@@ -99,6 +110,11 @@ in
     # nvim --version output retains compilation flags and references to build tools
     postPatch = ''
       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
     disallowedReferences = [ stdenv.cc ] ++ lib.optional (lua != codegenLua) codegenLua;
@@ -117,6 +133,7 @@ in
       cmakeFlagsArray+=(
         "-DLUAC_PRG=${codegenLua}/bin/luajit -b -s %s -"
         "-DLUA_GEN_PRG=${codegenLua}/bin/luajit"
+        "-DLUA_PRG=${neovimLuaEnvOnBuild}/bin/luajit"
       )
     '' + lib.optionalString stdenv.isDarwin ''
       substituteInPlace src/nvim/CMakeLists.txt --replace "    util" ""