lib/options: introduce new mkPackageOption for dependencies

This commit is contained in:
Gaetan Lepage 2024-05-17 14:39:55 +02:00 committed by Gaétan Lepage
parent 26367692da
commit 7c4fe30f81
15 changed files with 51 additions and 85 deletions

View file

@ -155,6 +155,26 @@ rec {
mkNullable nixvimTypes.highlight default (if desc == "" then "Highlight settings." else desc);
};
mkPackageOption =
{
name ? null, # Can be null if a custom description is given.
default,
description ? null,
example ? null,
}:
mkOption {
type = with types; nullOr package;
inherit default example;
description =
if description == null then
''
Which package to use for `${name}`.
Set to `null` to disable its automatic installation.
''
else
description;
};
mkPluginPackageOption =
name: default:
mkOption {

View file

@ -2,6 +2,7 @@
lib,
config,
pkgs,
helpers,
...
}:
with lib;
@ -12,14 +13,9 @@ in
meta.maintainers = [ maintainers.GaetanLepage ];
options.plugins.cmp-fish = {
fishPackage = mkOption {
type = with types; nullOr package;
fishPackage = helpers.mkPackageOption {
name = "fish";
default = pkgs.fish;
example = "null";
description = ''
Which package to use for `fish`.
Set to `null` to disable its automatic installation.
'';
};
};

View file

@ -281,13 +281,9 @@ helpers.neovim-plugin.mkNeovimPlugin config {
];
extraOptions = {
gitPackage = mkOption {
type = with types; nullOr package;
gitPackage = helpers.mkPackageOption {
name = "git";
default = pkgs.git;
description = ''
Which package to use for `git`.
Set to `null` to prevent the installation.
'';
};
};

View file

@ -64,24 +64,14 @@ helpers.vim-plugin.mkVimPlugin config {
};
extraOptions = {
gitPackage = mkOption {
type = with types; nullOr package;
gitPackage = helpers.mkPackageOption {
name = "git";
default = pkgs.git;
example = null;
description = ''
The `git` package to use.
Set to `null` to not install any package.
'';
};
lazygitPackage = mkOption {
type = with types; nullOr package;
lazygitPackage = helpers.mkPackageOption {
name = "lazygit";
default = pkgs.lazygit;
example = null;
description = ''
The `lazygit` package to use.
Set to `null` to not install any package.
'';
};
};

View file

@ -15,13 +15,9 @@ helpers.vim-plugin.mkVimPlugin config {
maintainers = [ maintainers.GaetanLepage ];
extraOptions = {
godotPackage = mkOption {
type = with types; nullOr package;
godotPackage = helpers.mkPackageOption {
name = "godot";
default = pkgs.godot_4;
description = ''
Which package to use for `godot`.
Set to `null` to prevent the installation.
'';
};
};

View file

@ -15,11 +15,9 @@ in
package = helpers.mkPluginPackageOption "lean-nvim" pkgs.vimPlugins.lean-nvim;
leanPackage = mkOption {
type = with types; nullOr package;
leanPackage = helpers.mkPackageOption {
name = "lean";
default = pkgs.lean4;
description = "Which package to use for lean.";
example = null;
};
lsp = helpers.defaultNullOpts.mkNullable (

View file

@ -46,13 +46,9 @@ mkVimPlugin config {
];
extraOptions = {
ledgerPackage = mkOption {
type = with types; nullOr package;
ledgerPackage = helpers.mkPackageOption {
name = "ledger";
default = pkgs.ledger;
description = ''
The package to install for `ledger`.
Set to `null` for disabling installation.
'';
};
};

View file

@ -13,10 +13,9 @@ in
options.plugins.rust-tools = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "rust tools plugins";
package = helpers.mkPluginPackageOption "rust-tools" pkgs.vimPlugins.rust-tools-nvim;
serverPackage = mkOption {
type = with types; nullOr package;
serverPackage = helpers.mkPackageOption {
name = "rust-analyzer";
default = pkgs.rust-analyzer;
description = "Package to use for rust-analyzer. rust-analyzer will not be installed if this is set to `null`";
};
executor = helpers.defaultNullOpts.mkEnumFirstDefault [

View file

@ -17,14 +17,9 @@ in
package = helpers.mkPluginPackageOption "rustaceanvim" pkgs.vimPlugins.rustaceanvim;
rustAnalyzerPackage = mkOption {
type = with types; nullOr package;
rustAnalyzerPackage = helpers.mkPackageOption {
name = "rust-analyzer";
default = pkgs.rust-analyzer;
description = ''
Which package to use for `rust-analyzer`.
Set to `null` to disable its automatic installation.
'';
example = null;
};
tools =

View file

@ -16,14 +16,9 @@ helpers.vim-plugin.mkVimPlugin config {
maintainers = [ maintainers.nickhu ];
extraOptions = {
texpressoPackage = mkOption {
type = with types; nullOr package;
texpressoPackage = helpers.mkPackageOption {
name = "texpresso";
default = pkgs.texpresso;
example = null;
description = ''
The `texpresso` package to use.
Set to `null` to not install any package.
'';
};
};

View file

@ -37,10 +37,8 @@ in
description = "Either \"all\" or a list of languages";
};
gccPackage = mkOption {
type = with types; nullOr package;
gccPackage = helpers.mkPackageOption {
default = if cfg.nixGrammars then null else pkgs.gcc;
example = null;
description = ''
Which package (if any) to be added as the GCC compiler.
This is required to build grammars if you are not using `nixGrammars`.

View file

@ -56,14 +56,9 @@ helpers.vim-plugin.mkVimPlugin config {
};
extraOptions = {
texlivePackage = mkOption {
type = with types; nullOr package;
texlivePackage = helpers.mkPackageOption {
name = "texlive";
default = pkgs.texlive.combined.scheme-medium;
example = null;
description = ''
The package to install for `textlive.
Set to `null` for not installing `texlive` at all.
'';
};
};

View file

@ -41,13 +41,9 @@ helpers.neovim-plugin.mkNeovimPlugin config {
inherit settingsOptions settingsExample;
extraOptions = {
fzfPackage = mkOption {
type = with types; nullOr package;
fzfPackage = helpers.mkPackageOption {
name = "fzf";
default = pkgs.fzf;
description = ''
The fzf package to use.
Set to `null` to not install any package.
'';
example = pkgs.skim;
};

View file

@ -246,8 +246,7 @@ helpers.neovim-plugin.mkNeovimPlugin config {
replaceDefaultPackage = replacePackages.${toString userCommandSettings.replace.cmd} or null;
in
{
findPackage = mkOption {
type = with types; nullOr package;
findPackage = helpers.mkPackageOption {
default = findDefaultPackage;
description = ''
Which package to install for the find command.
@ -257,8 +256,7 @@ helpers.neovim-plugin.mkNeovimPlugin config {
'';
};
replacePackage = mkOption {
type = with types; nullOr package;
replacePackage = helpers.mkPackageOption {
default = replaceDefaultPackage;
description = ''
Which package to install for the find command.

View file

@ -30,10 +30,8 @@ in
package = helpers.mkPluginPackageOption "todo-comments" pkgs.vimPlugins.todo-comments-nvim;
ripgrepPackage = mkOption {
type = with types; nullOr package;
ripgrepPackage = helpers.mkPackageOption {
default = pkgs.ripgrep;
example = null;
description = "Which package (if any) to be added for file search support in todo-comments.";
};