From cbd8536a05d1aae2593cb5c9ace1010c8c5845cb Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Sun, 29 Mar 2026 10:31:39 -0500 Subject: [PATCH] modules/output: restore plugin lua dependencies With the newer nixpkgs Neovim wrapper, plugin Lua dependencies are surfaced through neovimUtils.makeVimPackageInfo as vimPackageInfo.luaDependencies. Nixvim was still only feeding explicit extraLuaPackages into its wrapper Lua environment, so plugin-provided Lua modules stopped reaching the runtime search path after the flake.lock bump. That showed up as real runtime failures: Telescope could not load plenary.strings and Neorg could not load lua-utils, even though explicit extraLuaPackages still worked. Fix that by computing vimPackageInfo from config.build.plugins and appending vimPackageInfo.luaDependencies to the wrapper's extraLuaPackages. That keeps Nixvim aligned with the nixpkgs/Home Manager dependency resolution path instead of maintaining a separate recursive Lua dependency collector. Add focused regression coverage for the two reported plugin cases: - telescope -> plenary.strings - neorg -> lua-utils --- modules/top-level/output.nix | 11 ++- .../modules/wrapper-dependencies.nix | 69 +++++++++++++++++++ 2 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 tests/test-sources/modules/wrapper-dependencies.nix diff --git a/modules/top-level/output.nix b/modules/top-level/output.nix index b95c5c7f..d6837127 100644 --- a/modules/top-level/output.nix +++ b/modules/top-level/output.nix @@ -199,11 +199,18 @@ in else config.extraLuaPackages; - luaEnv = package.lua.withPackages extraLuaPackages; + vimPackageInfo = pkgs.neovimUtils.makeVimPackageInfo config.build.plugins; + + luaPackagesForWrapper = + ps: + extraLuaPackages ps + ++ lib.optionals (vimPackageInfo ? luaDependencies) vimPackageInfo.luaDependencies; + + luaEnv = package.lua.withPackages luaPackagesForWrapper; wrappedNeovim = (pkgs.wrapNeovimUnstable package { - inherit extraLuaPackages; + extraLuaPackages = luaPackagesForWrapper; inherit (config) extraPython3Packages viAlias diff --git a/tests/test-sources/modules/wrapper-dependencies.nix b/tests/test-sources/modules/wrapper-dependencies.nix new file mode 100644 index 00000000..c07e0953 --- /dev/null +++ b/tests/test-sources/modules/wrapper-dependencies.nix @@ -0,0 +1,69 @@ +let + mkLuaPathAssertions = moduleName: '' + local function split_semicolon_list(value) + local result = {} + for entry in string.gmatch(value or "", "[^;]+") do + table.insert(result, entry) + end + return result + end + + local function resolve_module(module_name, search_path) + local module_path = module_name:gsub("%.", "/") + for _, entry in ipairs(split_semicolon_list(search_path)) do + local candidate = entry:gsub("%?", module_path) + if vim.uv.fs_stat(candidate) then + return candidate + end + end + end + + local function assert_env_path_visible(env_name, runtime_value) + local env_value = vim.env[env_name] + assert(type(env_value) == "string", env_name .. " is unset") + + local entries = split_semicolon_list(env_value) + assert(#entries > 0, env_name .. " has no non-empty entries") + + for _, entry in ipairs(entries) do + assert( + runtime_value:find(entry, 1, true), + string.format( + "expected %s entry %q to be visible in runtime search path", + env_name, + entry + ) + ) + end + end + + assert_env_path_visible("LUA_PATH", package.path) + assert_env_path_visible("LUA_CPATH", package.cpath) + assert( + resolve_module(${builtins.toJSON moduleName}, vim.env.LUA_PATH), + string.format("Unable to resolve %q via LUA_PATH", ${builtins.toJSON moduleName}) + ) + assert( + resolve_module(${builtins.toJSON moduleName}, package.path), + string.format("Unable to resolve %q via package.path", ${builtins.toJSON moduleName}) + ) + ''; +in +{ + telescope = { + plugins.web-devicons.enable = true; + plugins.telescope.enable = true; + + extraConfigLuaPost = mkLuaPathAssertions "plenary.strings" + '' + local strings = require("plenary.strings") + assert(type(strings.truncate) == "function", "plenary.strings.truncate is unavailable") + ''; + }; + + neorg = { + plugins.treesitter.enable = true; + plugins.neorg.enable = true; + + extraConfigLuaPost = mkLuaPathAssertions "lua-utils" + ''require("lua-utils")''; + }; +}