mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +02:00
lib/plugins: introduce mkMetaModule
This commit is contained in:
parent
e908e344f4
commit
1a5f1b4393
3 changed files with 47 additions and 20 deletions
|
@ -5,7 +5,7 @@
|
||||||
{
|
{
|
||||||
name,
|
name,
|
||||||
maintainers,
|
maintainers,
|
||||||
url ? throw "default",
|
url ? null,
|
||||||
imports ? [ ],
|
imports ? [ ],
|
||||||
description ? null,
|
description ? null,
|
||||||
# deprecations
|
# deprecations
|
||||||
|
@ -62,15 +62,6 @@ let
|
||||||
luaConfigAtLocation = utils.mkConfigAt configLocation cfg.luaConfig.content;
|
luaConfigAtLocation = utils.mkConfigAt configLocation cfg.luaConfig.content;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
meta = {
|
|
||||||
inherit maintainers;
|
|
||||||
nixvimInfo = {
|
|
||||||
inherit description;
|
|
||||||
url = args.url or opts.package.default.meta.homepage;
|
|
||||||
path = loc;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
options = lib.setAttrByPath loc (
|
options = lib.setAttrByPath loc (
|
||||||
{
|
{
|
||||||
enable = lib.mkEnableOption packPathName;
|
enable = lib.mkEnableOption packPathName;
|
||||||
|
@ -168,6 +159,14 @@ in
|
||||||
++ [
|
++ [
|
||||||
module
|
module
|
||||||
(utils.mkPluginPackageModule { inherit loc packPathName package; })
|
(utils.mkPluginPackageModule { inherit loc packPathName package; })
|
||||||
|
(utils.mkMetaModule {
|
||||||
|
inherit
|
||||||
|
loc
|
||||||
|
maintainers
|
||||||
|
description
|
||||||
|
url
|
||||||
|
;
|
||||||
|
})
|
||||||
]
|
]
|
||||||
++ lib.optional deprecateExtraOptions (
|
++ lib.optional deprecateExtraOptions (
|
||||||
lib.mkRenamedOptionModule (loc ++ [ "extraOptions" ]) settingsPath
|
lib.mkRenamedOptionModule (loc ++ [ "extraOptions" ]) settingsPath
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
name,
|
name,
|
||||||
url ? throw "default",
|
url ? null,
|
||||||
maintainers,
|
maintainers,
|
||||||
imports ? [ ],
|
imports ? [ ],
|
||||||
description ? null,
|
description ? null,
|
||||||
|
@ -55,15 +55,6 @@ let
|
||||||
opts = lib.getAttrFromPath loc options;
|
opts = lib.getAttrFromPath loc options;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
meta = {
|
|
||||||
inherit maintainers;
|
|
||||||
nixvimInfo = {
|
|
||||||
inherit description;
|
|
||||||
url = args.url or opts.package.default.meta.homepage;
|
|
||||||
path = loc;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
options = lib.setAttrByPath loc (
|
options = lib.setAttrByPath loc (
|
||||||
{
|
{
|
||||||
enable = lib.mkEnableOption packPathName;
|
enable = lib.mkEnableOption packPathName;
|
||||||
|
@ -100,6 +91,14 @@ in
|
||||||
++ [
|
++ [
|
||||||
module
|
module
|
||||||
(lib.nixvim.plugins.utils.mkPluginPackageModule { inherit loc packPathName package; })
|
(lib.nixvim.plugins.utils.mkPluginPackageModule { inherit loc packPathName package; })
|
||||||
|
(lib.nixvim.plugins.utils.mkMetaModule {
|
||||||
|
inherit
|
||||||
|
loc
|
||||||
|
maintainers
|
||||||
|
description
|
||||||
|
url
|
||||||
|
;
|
||||||
|
})
|
||||||
]
|
]
|
||||||
++ lib.optional (deprecateExtraConfig && createSettingsOption) (
|
++ lib.optional (deprecateExtraConfig && createSettingsOption) (
|
||||||
lib.mkRenamedOptionModule (loc ++ [ "extraConfig" ]) settingsPath
|
lib.mkRenamedOptionModule (loc ++ [ "extraConfig" ]) settingsPath
|
||||||
|
|
|
@ -82,4 +82,33 @@
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Produce a module that defines a plugin's metadata.
|
||||||
|
*/
|
||||||
|
mkMetaModule =
|
||||||
|
{
|
||||||
|
loc,
|
||||||
|
maintainers,
|
||||||
|
description,
|
||||||
|
url ? null,
|
||||||
|
}@args:
|
||||||
|
{ options, ... }:
|
||||||
|
let
|
||||||
|
opts = lib.getAttrFromPath loc options;
|
||||||
|
url =
|
||||||
|
if args.url or null == null then
|
||||||
|
opts.package.default.meta.homepage or (throw "unable to get URL for `${lib.showOption loc}`.")
|
||||||
|
else
|
||||||
|
args.url;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
meta = {
|
||||||
|
inherit maintainers;
|
||||||
|
nixvimInfo = {
|
||||||
|
inherit description url;
|
||||||
|
path = loc;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue