nvf/modules/plugins/dashboard/alpha/config.nix
Nikita 3c52dbfd72
dashboard/alpha: configure with nix (#699)
Co-authored-by: raf <me@notashelf.dev>
2025-03-10 08:56:50 +00:00

46 lines
1 KiB
Nix

{
config,
lib,
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.dashboard.alpha;
themeDefined = cfg.theme != null;
layoutDefined = cfg.layout != [];
in {
config = mkIf cfg.enable {
vim.startPlugins = [
"alpha-nvim"
"nvim-web-devicons"
];
vim.pluginRC.alpha = let
setupOpts =
if themeDefined
then lib.generators.mkLuaInline "require'alpha.themes.${cfg.theme}'.config"
else {
inherit (cfg) layout opts;
};
in ''
require('alpha').setup(${toLuaObject setupOpts})
'';
assertions = [
{
assertion = themeDefined || layoutDefined;
message = ''
One of 'theme' or 'layout' should be defined in Alpha configuration.
'';
}
{
assertion = !(themeDefined && layoutDefined);
message = ''
'theme' and 'layout' cannot be defined at the same time.
'';
}
];
};
}