helpers: added package option to mkPlugin

This commit is contained in:
Alexander Nortung 2023-01-16 23:05:34 +01:00
parent 39261bff6b
commit 0154d0ae46

View file

@ -69,6 +69,7 @@ rec {
mkPlugin = { config, lib, ... }: { mkPlugin = { config, lib, ... }: {
name, name,
description, description,
package ? null,
extraPlugins ? [], extraPlugins ? [],
extraPackages ? [], extraPackages ? [],
options ? {}, options ? {},
@ -81,13 +82,23 @@ rec {
name = opt.global; name = opt.global;
value = if cfg.${name} != null then opt.value cfg.${name} else null; value = if cfg.${name} != null then opt.value cfg.${name} else null;
}) options; }) 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 { in {
options.plugins.${name} = { options.plugins.${name} = {
enable = mkEnableOption description; enable = mkEnableOption description;
} // pluginOptions; } // packageOption // pluginOptions;
config = mkIf cfg.enable { 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;
}; };
}; };