mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +02:00
lib/plugins: extract common logic for package
options
Adds `mkPluginPackageModule`.
This commit is contained in:
parent
896f6be694
commit
690fc895b5
3 changed files with 58 additions and 72 deletions
|
@ -45,12 +45,7 @@ let
|
|||
];
|
||||
|
||||
module =
|
||||
{
|
||||
config,
|
||||
options,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
{ config, options, ... }:
|
||||
let
|
||||
cfg = lib.getAttrFromPath loc config;
|
||||
opts = lib.getAttrFromPath loc options;
|
||||
|
@ -77,30 +72,6 @@ let
|
|||
{
|
||||
enable = lib.mkEnableOption packPathName;
|
||||
lazyLoad = lib.nixvim.mkLazyLoadOption packPathName;
|
||||
package =
|
||||
if lib.isOption package then
|
||||
package
|
||||
else
|
||||
lib.mkPackageOption pkgs packPathName {
|
||||
default =
|
||||
if builtins.isList package then
|
||||
package
|
||||
else
|
||||
[
|
||||
"vimPlugins"
|
||||
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;
|
||||
};
|
||||
}
|
||||
// lib.optionalAttrs hasSettings {
|
||||
settings = lib.nixvim.mkSettingsOption {
|
||||
|
@ -126,12 +97,7 @@ let
|
|||
lib.mkIf cfg.enable (
|
||||
lib.mkMerge (
|
||||
[
|
||||
{
|
||||
inherit extraPackages;
|
||||
extraPlugins = extraPlugins ++ [
|
||||
(cfg.packageDecorator cfg.package)
|
||||
];
|
||||
}
|
||||
{ inherit extraPackages extraPlugins; }
|
||||
|
||||
(lib.optionalAttrs (isColorscheme && colorscheme != null) {
|
||||
colorscheme = lib.mkDefault colorscheme;
|
||||
|
@ -194,7 +160,10 @@ in
|
|||
settingsPath = loc ++ [ "settings" ];
|
||||
in
|
||||
imports
|
||||
++ [ module ]
|
||||
++ [
|
||||
module
|
||||
(lib.nixvim.plugins.utils.mkPluginPackageModule { inherit loc packPathName package; })
|
||||
]
|
||||
++ lib.optional deprecateExtraOptions (
|
||||
lib.mkRenamedOptionModule (loc ++ [ "extraOptions" ]) settingsPath
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue