From 6eae18979174e9bf51201e4a0b02e673e4ef1ea8 Mon Sep 17 00:00:00 2001 From: teto <886074+teto@users.noreply.github.com> Date: Sun, 15 Mar 2026 19:35:40 +0100 Subject: [PATCH] neovimUtils.makeVimPackageInfo: add lua dependencies Neovim currently resolves its lua dependencies at buildtime in the wrapper, which causes some trouble as it's difficult to debug or replicate the result outside the nixpkgs wrapper. This change makes lua dependencies available at runtime. We can thus build a luaEnv to avoid building a long LUA_PATH which can help with runtime perf. The drawback is that we now need to engrave in nix the default LUA_PATH for the various lua interpreters. This is what I tried to avoid at first but this proves annoying. As far as neovim is concerned, we only care about the lua 5.1 and luajit interpreters whose defaults only slightly differ for cpath IIRC. So it should mostly transparent except for one or two plugins in which case we can adapt the lua code. --- pkgs/applications/editors/neovim/module.nix | 14 ++++++++++++++ pkgs/applications/editors/neovim/utils.nix | 1 + pkgs/applications/editors/neovim/wrapper.nix | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/pkgs/applications/editors/neovim/module.nix b/pkgs/applications/editors/neovim/module.nix index 258352c4e41b..5a9ca56afb56 100644 --- a/pkgs/applications/editors/neovim/module.nix +++ b/pkgs/applications/editors/neovim/module.nix @@ -93,6 +93,14 @@ in ''; }; + luaDependencies = lib.mkOption { + readOnly = true; + type = lib.types.listOf (lib.types.nullOr lib.types.package); + example = lib.literalExpression "[ (lp: [ lp.mpack ]) ]"; + description = '' + Lua dependencies required by the plugins. + ''; + }; }; config = @@ -122,5 +130,11 @@ in ) [ ] pluginsNormalized; pluginPython3Packages = map (plugin: plugin.python3Dependencies or (_: [ ])) pluginsNormalized; + + luaDependencies = + let + op = acc: p: acc ++ (p.plugin.requiredLuaModules or [ ]); + in + lib.foldl' op [ ] pluginsNormalized; }; } diff --git a/pkgs/applications/editors/neovim/utils.nix b/pkgs/applications/editors/neovim/utils.nix index 57ab04f98308..9e95bae2ca76 100644 --- a/pkgs/applications/editors/neovim/utils.nix +++ b/pkgs/applications/editors/neovim/utils.nix @@ -112,6 +112,7 @@ let runtimeDeps pluginAdvisedLua pluginPython3Packages + luaDependencies ; # A Vim "package", see ':h packages' diff --git a/pkgs/applications/editors/neovim/wrapper.nix b/pkgs/applications/editors/neovim/wrapper.nix index fe461dd08977..440c3be53654 100644 --- a/pkgs/applications/editors/neovim/wrapper.nix +++ b/pkgs/applications/editors/neovim/wrapper.nix @@ -109,7 +109,7 @@ let luaPathLuaRc = let - luaEnv = lua.withPackages extraLuaPackages; + luaEnv = lua.withPackages (lp: extraLuaPackages lp ++ vimPackageInfo.luaDependencies); # getLuaPath / getLuaCPath are not interpreter dependant at the moment and might thus cause # errors between luajit/Puc lua