2025-05-09 11:48:06 +03:00
|
|
|
/*
|
|
|
|
Byte compiling of lua dependencies of normalized plugin list
|
|
|
|
|
|
|
|
Inputs: List of normalized plugins
|
|
|
|
Outputs: List of normalized plugins with all the propagatedBuildInputs byte-compiled
|
|
|
|
*/
|
|
|
|
{ lib, pkgs }:
|
|
|
|
let
|
|
|
|
builders = lib.nixvim.builders.withPkgs pkgs;
|
|
|
|
inherit (import ./utils.nix lib) mapNormalizedPlugins;
|
|
|
|
|
2025-05-10 22:07:02 +03:00
|
|
|
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;
|
|
|
|
|
2025-05-09 11:48:06 +03:00
|
|
|
# Byte-compile only lua dependencies
|
|
|
|
byteCompileDeps =
|
|
|
|
drv:
|
2025-05-10 22:07:02 +03:00
|
|
|
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)
|
|
|
|
];
|
2025-05-09 11:48:06 +03:00
|
|
|
# Byte-compile derivation (but only if it's a lua module) and its dependencies
|
2025-05-10 22:07:02 +03:00
|
|
|
byteCompile = drv: byteCompileDeps (mapLuaModule builders.byteCompileLuaDrv drv);
|
2025-05-09 11:48:06 +03:00
|
|
|
in
|
|
|
|
mapNormalizedPlugins byteCompileDeps
|