From 0db6e86e8dd9468be40472ba647d87a71ac6ab63 Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Thu, 29 Aug 2024 09:54:31 -0500 Subject: [PATCH] plugins/alpha: use iconsPackage --- plugins/utils/alpha.nix | 26 ++++++++++++++++++++-- tests/test-sources/plugins/utils/alpha.nix | 9 +++++++- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/plugins/utils/alpha.nix b/plugins/utils/alpha.nix index 2febc284..dbb5fb91 100644 --- a/plugins/utils/alpha.nix +++ b/plugins/utils/alpha.nix @@ -2,6 +2,7 @@ lib, helpers, config, + options, pkgs, ... }: @@ -55,10 +56,16 @@ in package = helpers.mkPluginPackageOption "alpha-nvim" pkgs.vimPlugins.alpha-nvim; + # TODO: deprecated 2024-08-29 remove after 24.11 iconsEnabled = mkOption { type = types.bool; description = "Toggle icon support. Installs nvim-web-devicons."; - default = true; + visible = false; + }; + + iconsPackage = helpers.mkPackageOption { + name = "nvim-web-devicons"; + default = pkgs.vimPlugins.nvim-web-devicons; }; theme = mkOption { @@ -139,9 +146,24 @@ in let layoutDefined = cfg.layout != [ ]; themeDefined = cfg.theme != null; + + opt = options.plugins.alpha; in mkIf cfg.enable { - extraPlugins = [ cfg.package ] ++ (optional cfg.iconsEnabled pkgs.vimPlugins.nvim-web-devicons); + # TODO: deprecated 2024-08-29 remove after 24.11 + warnings = lib.mkIf opt.iconsEnabled.isDefined [ + '' + nixvim (plugins.alpha): + The option definition `plugins.alpha.iconsEnabled' in ${showFiles opt.iconsEnabled.files} has been deprecated; please remove it. + You should use `plugins.alpha.iconsPackage' instead. + '' + ]; + + extraPlugins = + [ cfg.package ] + ++ lib.optional ( + cfg.iconsPackage != null && (opt.iconsEnabled.isDefined && cfg.iconsEnabled) + ) cfg.iconsPackage; assertions = [ { diff --git a/tests/test-sources/plugins/utils/alpha.nix b/tests/test-sources/plugins/utils/alpha.nix index 77534a43..9eedf9c4 100644 --- a/tests/test-sources/plugins/utils/alpha.nix +++ b/tests/test-sources/plugins/utils/alpha.nix @@ -34,7 +34,6 @@ plugins.alpha = { enable = true; - iconsEnabled = true; layout = [ { type = "padding"; @@ -100,4 +99,12 @@ }; }; }; + + no-packages = { + plugins.alpha = { + enable = true; + theme = "dashboard"; + iconsPackage = null; + }; + }; }