From 0154d0ae465df896f90f48cb3eefbd13a4a6ce35 Mon Sep 17 00:00:00 2001 From: Alexander Nortung Date: Mon, 16 Jan 2023 23:05:34 +0100 Subject: [PATCH] helpers: added package option to mkPlugin --- plugins/helpers.nix | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/plugins/helpers.nix b/plugins/helpers.nix index ab6a9866..70c85d77 100644 --- a/plugins/helpers.nix +++ b/plugins/helpers.nix @@ -69,6 +69,7 @@ rec { mkPlugin = { config, lib, ... }: { name, description, + package ? null, extraPlugins ? [], extraPackages ? [], options ? {}, @@ -81,13 +82,23 @@ rec { name = opt.global; value = if cfg.${name} != null then opt.value cfg.${name} else null; }) options; + # does this evaluate package? + packageOption = if package == null then { } else { + package = mkOption { + type = types.package; + default = package; + description = "Plugin to use for ${name}"; + }; + }; in { options.plugins.${name} = { enable = mkEnableOption description; - } // pluginOptions; + } // packageOption // pluginOptions; config = mkIf cfg.enable { - inherit extraPlugins extraPackages globals; + inherit extraPackages globals; + # does this evaluate package? it would not be desired to evaluate pacakge if we use another package. + extraPlugins = extraPlugins ++ optional (package != null) cfg.package; }; };