mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-20 16:15:43 +02:00
modules/performance: ensure all lua dependencies are byte-compiled
This commit replaces custom lua plugins in tests with shared stub plugins from utils module. After this change the test has started to fail. Debugging this issue I found out that dependencies of plugins weren't processed. This commit improves the test assertion to detect duplicated dependencies in this case and fixes the underlying issue by also processing dependencies.
This commit is contained in:
parent
2210d7bb10
commit
9474ce916a
2 changed files with 65 additions and 55 deletions
|
@ -9,20 +9,35 @@ let
|
|||
builders = lib.nixvim.builders.withPkgs pkgs;
|
||||
inherit (import ./utils.nix lib) mapNormalizedPlugins;
|
||||
|
||||
luaPackages = pkgs.neovim-unwrapped.lua.pkgs;
|
||||
|
||||
# Applies a function to the derivation, but only if it's a lua module,
|
||||
# otherwise returns it as is
|
||||
mapLuaModule = f: drv: if luaPackages.luaLib.hasLuaModule drv then f drv else drv;
|
||||
|
||||
# Byte-compile only lua dependencies
|
||||
byteCompileDeps =
|
||||
drv:
|
||||
drv.overrideAttrs (
|
||||
prev:
|
||||
lib.optionalAttrs (prev ? propagatedBuildInputs) {
|
||||
propagatedBuildInputs = map byteCompile prev.propagatedBuildInputs;
|
||||
}
|
||||
);
|
||||
lib.pipe drv [
|
||||
(
|
||||
drv:
|
||||
if drv.dependencies or [ ] != [ ] then
|
||||
drv.overrideAttrs { dependencies = map byteCompileDeps drv.dependencies; }
|
||||
else
|
||||
drv
|
||||
)
|
||||
(
|
||||
drv:
|
||||
if drv.propagatedBuildInputs or [ ] != [ ] then
|
||||
drv.overrideAttrs { propagatedBuildInputs = map byteCompile drv.propagatedBuildInputs; }
|
||||
else
|
||||
drv
|
||||
)
|
||||
# 'toLuaModule' updates requiredLuaModules attr
|
||||
# It works without it, but update it anyway for consistency
|
||||
(mapLuaModule luaPackages.toLuaModule)
|
||||
];
|
||||
# Byte-compile derivation (but only if it's a lua module) and its dependencies
|
||||
byteCompile =
|
||||
drv:
|
||||
byteCompileDeps (
|
||||
if pkgs.luaPackages.luaLib.hasLuaModule drv then builders.byteCompileLuaDrv drv else drv
|
||||
);
|
||||
byteCompile = drv: byteCompileDeps (mapLuaModule builders.byteCompileLuaDrv drv);
|
||||
in
|
||||
mapNormalizedPlugins byteCompileDeps
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue