From e3c908fdf6dff268b04ffb6758bcfc7c018489b9 Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Sat, 13 Jun 2026 21:48:29 +0100 Subject: [PATCH] modules/output: add source locations to vimPlugin assertions Include the definition locations of offending vim-plugins in the `extraPackages` & `extraPackagesAfter` assertion messages. This makes it easier to track down the plugin declarations, especially when values originate from multiple modules. --- modules/output.nix | 16 +++++++++++++--- tests/test-sources/modules/output.nix | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/modules/output.nix b/modules/output.nix index 6c6224f5..45f6f75c 100644 --- a/modules/output.nix +++ b/modules/output.nix @@ -31,13 +31,23 @@ let mkVimPluginPackageAssertion = opt: let - vimPlugins = builtins.filter isVimPluginPackage opt.value; + vimPluginDefs = lib.pipe opt.definitionsWithLocations [ + # Flatten to [{file, package}] + (lib.concatMap ({ file, value }: map (package: { inherit file package; }) value)) + # Select vimPlugins + (lib.filter (def: isVimPluginPackage def.package)) + # Group definition files by plugin name + (lib.groupBy (def: lib.getName def.package)) + (lib.mapAttrs (_: map (def: def.file))) + ]; in { - assertion = vimPlugins == [ ]; + assertion = vimPluginDefs == { }; message = '' `${opt}` is for executable packages added to Neovim's PATH, but it contains Vim plugin package(s): - ${lib.concatMapStringsSep "\n" (package: " - ${lib.getName package}") vimPlugins} + ${lib.concatMapAttrsStringSep "\n" ( + name: files: " - ${name} defined in ${lib.options.showFiles files}" + ) vimPluginDefs} Use `${options.extraPlugins}` for Vim plugin packages: ${options.extraPlugins} = [ pkgs.vimPlugins. ]; diff --git a/tests/test-sources/modules/output.nix b/tests/test-sources/modules/output.nix index 1fd1aa5a..a1cd7ee1 100644 --- a/tests/test-sources/modules/output.nix +++ b/tests/test-sources/modules/output.nix @@ -315,7 +315,7 @@ (expect "any" "`extraPackages` is for executable packages added to Neovim's PATH") (expect "any" "`extraPackagesAfter` is for executable packages added to Neovim's PATH") (expect "all" "Use `extraPlugins` for Vim plugin packages:") - (expect "all" "nixvim-extra-packages-vim-plugin-test") + (expect "all" "- nixvim-extra-packages-vim-plugin-test defined in `${toString __curPos.file}'") ]; }; };