modules/performance: add performance.byteCompileLua option

* add `performance.byteCompileLua.enable` toggle to enable or disable
  all byte compiling features
* add `performance.byteCompileLua.initLua` toggle to enable or
  disable byte compiling of init.lua
* add `writeByteCompiledLua` helper for saving byte compiled lua source
  code to the nix store
* `nixvim-print-init` utility is always pointed to uncompiled init.lua
* add tests
This commit is contained in:
Stanislav Asunkin 2024-07-25 13:25:13 +03:00 committed by GaetanLepage
parent 3789c69658
commit 17e8904992
4 changed files with 183 additions and 2 deletions

View file

@ -26,4 +26,26 @@
--indent-width 4 \
"$out"
'';
/*
Write a byte compiled lua file to the nix store.
# Type
```
writeByteCompiledLua :: String -> String -> Derivation
```
# Arguments
- [name] The name of the derivation
- [text] The content of the lua file
*/
writeByteCompiledLua =
name: text:
pkgs.runCommandLocal name { inherit text; } ''
echo -n "$text" > "$out"
${lib.getExe' pkgs.luajit "luajit"} -bd -- "$out" "$out"
'';
}