nix-community.nixvim/modules/top-level/plugins/default.nix
Stanislav Asunkin 75f2c1b1f1 modules/performance: ensure dependencies of lua packages also compiled
Previously only extraLuaPackages themselves were byte-compiled, not
theirs dependencies. This commit fixes that by compiling lua packages
recursively. It uses byte-compile-lua-lib.nix shared file.
Also this commit uses the shared stub lua libraries for extraLuaPackages
byte-compiling test.
2025-05-12 17:39:01 +03:00

57 lines
1.6 KiB
Nix

{
lib,
config,
pkgs,
...
}:
let
inherit (import ./utils.nix lib)
normalizedPluginType
normalizePlugins
;
byteCompileCfg = config.performance.byteCompileLua;
in
{
options = {
build.plugins = lib.mkOption {
visible = false;
internal = true;
readOnly = true;
type = lib.types.listOf normalizedPluginType;
description = ''
Final list of (normalized) plugins that will be passed to the wrapper.
It notably implements:
- byte-compilation (performance.byteCompileLua) -> ./byte-compile-plugins.nix
- plugins combining (performance.combinePlugins) -> ./combine-plugins.nix
'';
};
};
config = {
build.plugins =
let
shouldCompilePlugins = byteCompileCfg.enable && byteCompileCfg.plugins;
byteCompilePlugins = import ./byte-compile-plugins.nix { inherit lib pkgs; };
shouldCompileLuaLib = byteCompileCfg.enable && byteCompileCfg.luaLib;
inherit (import ./byte-compile-lua-lib.nix { inherit lib pkgs; }) byteCompilePluginDeps;
shouldCombinePlugins = config.performance.combinePlugins.enable;
combinePlugins = import ./combine-plugins.nix {
inherit lib pkgs;
inherit (config.performance.combinePlugins)
standalonePlugins
pathsToLink
;
};
in
lib.pipe config.extraPlugins (
[ normalizePlugins ]
++ lib.optionals shouldCompilePlugins [ byteCompilePlugins ]
++ lib.optionals shouldCompileLuaLib [ byteCompilePluginDeps ]
++ lib.optionals shouldCombinePlugins [ combinePlugins ]
);
};
}