plugins/lsp/servers: use lib.mkPackageOption

This commit is contained in:
Matt Sturgeon 2024-09-01 09:43:53 +01:00
parent 0b86bf519b
commit 9c11b54065
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299
2 changed files with 113 additions and 78 deletions

View file

@ -4,24 +4,24 @@
#
# Helper function that returns the Nix module `plugins.lsp.servers.<name>`.
#
{ pkgs, ... }:
{
name,
description ? "Enable ${name}.",
serverName ? name,
package ? pkgs.${name},
url ? package.meta.homepage or null,
package ? name,
url ? null,
cmd ? (cfg: null),
settings ? (cfg: cfg),
settingsOptions ? { },
extraConfig ? cfg: { },
extraOptions ? { },
...
}:
}@args:
# returns a module
{
pkgs,
config,
options,
helpers,
lib,
...
@ -29,11 +29,12 @@
with lib;
let
cfg = config.plugins.lsp.servers.${name};
opt = options.plugins.lsp.servers.${name};
in
{
meta.nixvimInfo = {
# TODO: description
inherit url;
url = args.url or opt.package.default.meta.homepage or null;
path = [
"plugins"
"lsp"
@ -46,11 +47,14 @@ in
plugins.lsp.servers.${name} = {
enable = mkEnableOption description;
package = mkOption {
default = package;
type = types.nullOr types.package;
description = "Which package to use for ${name}.";
};
package =
if lib.isOption package then
package
else
lib.mkPackageOption pkgs name {
nullable = true;
default = package;
};
cmd = mkOption {
type = with types; nullOr (listOf str);