modules/performance: add ability to byte compile lua plugins

This commit adds `performance.byteCompileLua.plugins` toggle that, if
enabled, byte compiles all lua files in plugins
This commit is contained in:
Stanislav Asunkin 2024-07-17 21:06:30 +03:00 committed by GaetanLepage
parent 44849233e0
commit 55ca9d235b
3 changed files with 92 additions and 2 deletions

View file

@ -87,8 +87,27 @@ in
defaultPlugin // (if p ? plugin then p else { plugin = p; });
normalizePluginList = plugins: map normalize plugins;
# Normalized plugin list
normalizedPlugins = normalizePluginList config.extraPlugins;
# Byte compiling of normalized plugin list
byteCompilePlugins =
plugins:
let
byteCompile =
p:
(helpers.byteCompileLuaDrv p).overrideAttrs (
prev: lib.optionalAttrs (prev ? dependencies) { dependencies = map byteCompile prev.dependencies; }
);
in
map (p: p // { plugin = byteCompile p.plugin; }) plugins;
# Normalized and optionally byte compiled plugin list
normalizedPlugins =
let
normalized = normalizePluginList config.extraPlugins;
in
if config.performance.byteCompileLua.enable && config.performance.byteCompileLua.plugins then
byteCompilePlugins normalized
else
normalized;
# Plugin list extended with dependencies
allPlugins =