modules/performance: fix specifying combinePlugin.standalonePlugins as packages when byte compilation enabled

Previously, specifying plugins as packages in the
`performance.combinePlugins.standalonePlugins` option did not work when
the `performance.byteCompileLua` option was also enabled. This issue was
due to several package transformations performed by the
`byteCompileLua` which broke package comparison.

There are at least three methods to fix the issue:

- Change transformation order: combine plugins first, then byte-compile
  them.
- Compare every possible transformation when determining if plugins are
  standalone.
- Get the name of the package and use it for comparison.

The first method did not work because the current `byteCompileLuaDrv`
implementation does not support symlinks to directories. The second
method appears too fragile. This commit implements the third method, as
it requires minimal code changes and is straightforward. The downside is
that it might exclude multiple packages with the same name, although
this should be rare.
This commit is contained in:
Stanislav Asunkin 2025-05-25 16:14:07 +03:00
parent 6c456efc96
commit 65d35db5ca
2 changed files with 41 additions and 24 deletions

View file

@ -8,7 +8,7 @@ let
let
# 'build.extraFiles' must not be combined, so exclude it from counting
plugins = builtins.filter (
p: p != config.build.extraFiles
p: lib.getName p != lib.getName config.build.extraFiles
) config.build.nvimPackage.packpathDirs.myNeovimPackages.${type};
numPlugins = builtins.length plugins;
in
@ -203,11 +203,30 @@ in
];
};
# Test if plenary.filetype is working
plenary-nvim = {
performance.combinePlugins.enable = true;
extraPlugins = [ pkgs.vimPlugins.plenary-nvim ];
extraConfigLuaPost = ''
-- Plenary filetype detection is usable
assert(require("plenary.filetype").detect(".bashrc") == "sh", "plenary.filetype is not working")
'';
};
}
//
# Test that config.build.extraFiles is not combined
files-plugin =
# with or without byteCompileLua.enable = true
lib.genAttrs [ "files-plugin" "files-plugin-byte-compiled" ] (
name:
{ config, ... }:
{
performance.combinePlugins.enable = true;
performance = {
combinePlugins.enable = true;
byteCompileLua = lib.optionalAttrs (lib.hasSuffix "byte-compiled" name) {
enable = true;
plugins = true;
};
};
extraPlugins = with pluginStubs; [
plugin1
plugin2
@ -242,10 +261,13 @@ in
assertions = [
(expectOneStartPlugin config)
];
};
}
)
//
# Test that standalonePlugins option works
standalone-plugins =
# with or without byteCompileLua.enable = true
lib.genAttrs [ "standalone-plugins" "standalone-plugins-byte-compiled" ] (
name:
{ config, ... }:
let
standalonePlugins = [
@ -260,9 +282,15 @@ in
];
in
{
performance.combinePlugins = {
enable = true;
inherit standalonePlugins;
performance = {
combinePlugins = {
enable = true;
inherit standalonePlugins;
};
byteCompileLua = lib.optionalAttrs (lib.hasSuffix "byte-compiled" name) {
enable = true;
plugins = true;
};
};
extraPlugins = pluginStubs.pluginPack;
extraConfigLuaPost = ''
@ -295,15 +323,5 @@ in
# plugin-pack and 'standalonePlugins'
(expectNPlugins config "start" (builtins.length standalonePlugins + 1))
];
};
# Test if plenary.filetype is working
plenary-nvim = {
performance.combinePlugins.enable = true;
extraPlugins = [ pkgs.vimPlugins.plenary-nvim ];
extraConfigLuaPost = ''
-- Plenary filetype detection is usable
assert(require("plenary.filetype").detect(".bashrc") == "sh", "plenary.filetype is not working")
'';
};
}
}
)