lib/{vim,neovim}-plugin: installPackage -> packageDecorator

Replace `mkNeovimPlugin`'s `installPackage` parameter with a new
internal module option: `packageDecorator`.

The option is a function that applies some transformation to
`cfg.package`'s value before it is installed.
This commit is contained in:
Matt Sturgeon 2024-11-15 17:28:47 +00:00
parent 1d78aee791
commit de99f2938f
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299
3 changed files with 30 additions and 10 deletions

View file

@ -91,15 +91,26 @@
package
];
};
packageDecorator = lib.mkOption {
type = lib.types.functionTo lib.types.package;
default = lib.id;
defaultText = lib.literalExpression "x: x";
description = ''
Additional transformations to apply to the final installed package.
The result of these transformations is **not** visible in the `package` option's value.
'';
internal = true;
};
} // settingsOption // extraOptions;
config = lib.mkIf cfg.enable (
lib.mkMerge [
{
inherit extraPackages;
extraPlugins = extraPlugins ++ [
(cfg.packageDecorator cfg.package)
];
globals = lib.mapAttrs' (n: lib.nameValuePair (globalPrefix + n)) (cfg.settings or { });
# does this evaluate package? it would not be desired to evaluate package if we use another package.
extraPlugins = extraPlugins ++ lib.optional (cfg.package != null) cfg.package;
}
(lib.optionalAttrs (isColorscheme && (colorscheme != null)) {
colorscheme = lib.mkDefault colorscheme;