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); 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 = mkPluginPackageOption =
name: default: name: default:
mkOption { mkOption {

View file

@ -2,6 +2,7 @@
lib, lib,
config, config,
pkgs, pkgs,
helpers,
... ...
}: }:
with lib; with lib;
@ -12,14 +13,9 @@ in
meta.maintainers = [ maintainers.GaetanLepage ]; meta.maintainers = [ maintainers.GaetanLepage ];
options.plugins.cmp-fish = { options.plugins.cmp-fish = {
fishPackage = mkOption { fishPackage = helpers.mkPackageOption {
type = with types; nullOr package; name = "fish";
default = pkgs.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 = { extraOptions = {
gitPackage = mkOption { gitPackage = helpers.mkPackageOption {
type = with types; nullOr package; name = "git";
default = pkgs.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 = { extraOptions = {
gitPackage = mkOption { gitPackage = helpers.mkPackageOption {
type = with types; nullOr package; name = "git";
default = pkgs.git; default = pkgs.git;
example = null;
description = ''
The `git` package to use.
Set to `null` to not install any package.
'';
}; };
lazygitPackage = mkOption { lazygitPackage = helpers.mkPackageOption {
type = with types; nullOr package; name = "lazygit";
default = pkgs.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 ]; maintainers = [ maintainers.GaetanLepage ];
extraOptions = { extraOptions = {
godotPackage = mkOption { godotPackage = helpers.mkPackageOption {
type = with types; nullOr package; name = "godot";
default = pkgs.godot_4; 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; package = helpers.mkPluginPackageOption "lean-nvim" pkgs.vimPlugins.lean-nvim;
leanPackage = mkOption { leanPackage = helpers.mkPackageOption {
type = with types; nullOr package; name = "lean";
default = pkgs.lean4; default = pkgs.lean4;
description = "Which package to use for lean.";
example = null;
}; };
lsp = helpers.defaultNullOpts.mkNullable ( lsp = helpers.defaultNullOpts.mkNullable (

View file

@ -46,13 +46,9 @@ mkVimPlugin config {
]; ];
extraOptions = { extraOptions = {
ledgerPackage = mkOption { ledgerPackage = helpers.mkPackageOption {
type = with types; nullOr package; name = "ledger";
default = pkgs.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 // { options.plugins.rust-tools = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "rust tools plugins"; enable = mkEnableOption "rust tools plugins";
package = helpers.mkPluginPackageOption "rust-tools" pkgs.vimPlugins.rust-tools-nvim; package = helpers.mkPluginPackageOption "rust-tools" pkgs.vimPlugins.rust-tools-nvim;
serverPackage = mkOption { serverPackage = helpers.mkPackageOption {
type = with types; nullOr package; name = "rust-analyzer";
default = pkgs.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 [ executor = helpers.defaultNullOpts.mkEnumFirstDefault [

View file

@ -17,14 +17,9 @@ in
package = helpers.mkPluginPackageOption "rustaceanvim" pkgs.vimPlugins.rustaceanvim; package = helpers.mkPluginPackageOption "rustaceanvim" pkgs.vimPlugins.rustaceanvim;
rustAnalyzerPackage = mkOption { rustAnalyzerPackage = helpers.mkPackageOption {
type = with types; nullOr package; name = "rust-analyzer";
default = pkgs.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 = tools =

View file

@ -16,14 +16,9 @@ helpers.vim-plugin.mkVimPlugin config {
maintainers = [ maintainers.nickhu ]; maintainers = [ maintainers.nickhu ];
extraOptions = { extraOptions = {
texpressoPackage = mkOption { texpressoPackage = helpers.mkPackageOption {
type = with types; nullOr package; name = "texpresso";
default = pkgs.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"; description = "Either \"all\" or a list of languages";
}; };
gccPackage = mkOption { gccPackage = helpers.mkPackageOption {
type = with types; nullOr package;
default = if cfg.nixGrammars then null else pkgs.gcc; default = if cfg.nixGrammars then null else pkgs.gcc;
example = null;
description = '' description = ''
Which package (if any) to be added as the GCC compiler. Which package (if any) to be added as the GCC compiler.
This is required to build grammars if you are not using `nixGrammars`. This is required to build grammars if you are not using `nixGrammars`.

View file

@ -56,14 +56,9 @@ helpers.vim-plugin.mkVimPlugin config {
}; };
extraOptions = { extraOptions = {
texlivePackage = mkOption { texlivePackage = helpers.mkPackageOption {
type = with types; nullOr package; name = "texlive";
default = pkgs.texlive.combined.scheme-medium; 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; inherit settingsOptions settingsExample;
extraOptions = { extraOptions = {
fzfPackage = mkOption { fzfPackage = helpers.mkPackageOption {
type = with types; nullOr package; name = "fzf";
default = pkgs.fzf; default = pkgs.fzf;
description = ''
The fzf package to use.
Set to `null` to not install any package.
'';
example = pkgs.skim; example = pkgs.skim;
}; };

View file

@ -246,8 +246,7 @@ helpers.neovim-plugin.mkNeovimPlugin config {
replaceDefaultPackage = replacePackages.${toString userCommandSettings.replace.cmd} or null; replaceDefaultPackage = replacePackages.${toString userCommandSettings.replace.cmd} or null;
in in
{ {
findPackage = mkOption { findPackage = helpers.mkPackageOption {
type = with types; nullOr package;
default = findDefaultPackage; default = findDefaultPackage;
description = '' description = ''
Which package to install for the find command. Which package to install for the find command.
@ -257,8 +256,7 @@ helpers.neovim-plugin.mkNeovimPlugin config {
''; '';
}; };
replacePackage = mkOption { replacePackage = helpers.mkPackageOption {
type = with types; nullOr package;
default = replaceDefaultPackage; default = replaceDefaultPackage;
description = '' description = ''
Which package to install for the find command. 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; package = helpers.mkPluginPackageOption "todo-comments" pkgs.vimPlugins.todo-comments-nvim;
ripgrepPackage = mkOption { ripgrepPackage = helpers.mkPackageOption {
type = with types; nullOr package;
default = pkgs.ripgrep; default = pkgs.ripgrep;
example = null;
description = "Which package (if any) to be added for file search support in todo-comments."; description = "Which package (if any) to be added for file search support in todo-comments.";
}; };