misc: allow null in extraPackages

This commit is contained in:
Gaetan Lepage 2024-04-23 16:41:27 +02:00 committed by Gaétan Lepage
parent c826d146c6
commit f2f97d844b
13 changed files with 22 additions and 39 deletions

View file

@ -1,7 +1,6 @@
{ {
lib, lib,
config, config,
pkgs,
... ...
}: }:
with lib; let with lib; let
@ -34,9 +33,10 @@ in {
}; };
extraPackages = mkOption { extraPackages = mkOption {
type = types.listOf types.package; type = with types; listOf (nullOr package);
default = []; default = [];
description = "Extra packages to be made available to neovim"; description = "Extra packages to be made available to neovim";
apply = builtins.filter (p: p != null);
}; };
extraPython3Packages = mkOption { extraPython3Packages = mkOption {

View file

@ -150,6 +150,6 @@ with lib;
`plugins.trouble.enable` is `false`. `plugins.trouble.enable` is `false`.
You should maybe enable the `trouble` plugin. You should maybe enable the `trouble` plugin.
''; '';
extraPackages = optional (cfg.gitPackage != null) cfg.gitPackage; extraPackages = [cfg.gitPackage];
}; };
} }

View file

@ -36,9 +36,6 @@ with lib;
}; };
extraConfig = cfg: { extraConfig = cfg: {
extraPackages = extraPackages = [cfg.godotPackage];
optional
(cfg.godotPackage != null)
cfg.godotPackage;
}; };
} }

View file

@ -252,7 +252,7 @@ in {
} }
]; ];
extraPackages = optional (cfg.leanPackage != null) cfg.leanPackage; extraPackages = [cfg.leanPackage];
extraConfigLua = let extraConfigLua = let
setupOptions = with cfg; setupOptions = with cfg;

View file

@ -48,7 +48,7 @@ with helpers.vim-plugin;
}; };
extraConfig = cfg: { extraConfig = cfg: {
extraPackages = optional (cfg.ledgerPackage != null) cfg.ledgerPackage; extraPackages = [cfg.ledgerPackage];
}; };
settingsOptions = { settingsOptions = {

View file

@ -133,7 +133,7 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
extraPlugins = with pkgs.vimPlugins; [nvim-lspconfig cfg.package]; extraPlugins = with pkgs.vimPlugins; [nvim-lspconfig cfg.package];
extraPackages = optional (cfg.serverPackage != null) cfg.serverPackage; extraPackages = [cfg.serverPackage];
plugins.lsp.postConfig = let plugins.lsp.postConfig = let
options = options =

View file

@ -238,10 +238,7 @@ in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
extraPlugins = [cfg.package]; extraPlugins = [cfg.package];
extraPackages = extraPackages = [cfg.rustAnalyzerPackage];
optional
(cfg.rustAnalyzerPackage != null)
cfg.rustAnalyzerPackage;
plugins.lsp.postConfig = let plugins.lsp.postConfig = let
globalOptions = with cfg; globalOptions = with cfg;

View file

@ -213,12 +213,11 @@ in {
if cfg.nixGrammars if cfg.nixGrammars
then [(cfg.package.withPlugins (_: cfg.grammarPackages))] then [(cfg.package.withPlugins (_: cfg.grammarPackages))]
else [cfg.package]; else [cfg.package];
extraPackages = with pkgs; extraPackages = with pkgs; [
[ tree-sitter
tree-sitter nodejs
nodejs cfg.gccPackage
] ];
++ optional (cfg.gccPackage != null) cfg.gccPackage;
opts = mkIf cfg.folding { opts = mkIf cfg.folding {
foldmethod = "expr"; foldmethod = "expr";

View file

@ -87,11 +87,9 @@ with lib;
.${cfg.settings.view_method} .${cfg.settings.view_method}
or []; or [];
in in
( [
optional
(cfg.texlivePackage != null)
cfg.texlivePackage cfg.texlivePackage
) ]
++ viewerPackages; ++ viewerPackages;
}; };
} }

View file

@ -86,10 +86,7 @@
config = config =
mkIf cfg.enable mkIf cfg.enable
{ {
extraPackages = extraPackages = [cfg.package];
optional
(cfg.package != null)
cfg.package;
plugins.lsp.enabledServers = [ plugins.lsp.enabledServers = [
{ {

View file

@ -363,11 +363,9 @@ in {
) )
enabledSources; enabledSources;
plugins.gitsigns.enable = mkIf gitsignsEnabled true; plugins.gitsigns.enable = mkIf gitsignsEnabled true;
extraPackages = builtins.filter (p: p != null) ( extraPackages =
builtins.map ( map
source: source.package or null (source: source.package or null)
) enabledSources;
enabledSources
);
}; };
} }

View file

@ -134,10 +134,7 @@ in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
extraPlugins = [cfg.package]; extraPlugins = [cfg.package];
extraPackages = extraPackages = [cfg.clipboardPackage];
optional
(cfg.clipboardPackage != null)
cfg.clipboardPackage;
extraConfigLua = let extraConfigLua = let
setupOptions = setupOptions =

View file

@ -271,7 +271,7 @@ in {
in in
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = [cfg.package]; extraPlugins = [cfg.package];
extraPackages = optional (cfg.ripgrepPackage != null) cfg.ripgrepPackage; extraPackages = [cfg.ripgrepPackage];
extraConfigLua = '' extraConfigLua = ''
require("todo-comments").setup${helpers.toLuaObject setupOptions} require("todo-comments").setup${helpers.toLuaObject setupOptions}
''; '';