null-ls/servers: package option

This commit is contained in:
Alexander Nortung 2023-01-17 22:14:07 +01:00
parent ac8293d806
commit 22f6cd1ad9
2 changed files with 23 additions and 13 deletions

View file

@ -4,7 +4,8 @@
{ name
, sourceType
, description ? "Enable ${name} source, for null-ls."
, packages ? [ ]
, package ? null
, extraPackages ? [ ]
, ...
}:
# returns a module
@ -13,6 +14,14 @@
let
helpers = import ../helpers.nix args;
cfg = config.plugins.null-ls.sources.${sourceType}.${name};
# does this evaluate package?
packageOption = if package == null then { } else {
package = mkOption {
type = types.package;
default = package;
description = "Package to use for ${name} by null-ls";
};
};
in
{
options.plugins.null-ls.sources.${sourceType}.${name} = {
@ -28,10 +37,11 @@
# '\'{ extra_args = { "--no-semi", "--single-quote", "--jsx-single-quote" } }'\'
# '';
};
};
} // packageOption;
config = mkIf cfg.enable {
extraPackages = packages;
# Does this evaluate package?
extraPackages = packages ++ optional (package != null) cfg.package;
# Add source to list of sources
plugins.null-ls.sourcesItems =

View file

@ -8,36 +8,36 @@ let
completion = { };
diagnostics = {
flake8 = {
packages = [ pkgs.python3Packages.flake8 ];
package = pkgs.python3Packages.flake8;
};
shellcheck = {
packages = [ pkgs.shellcheck ];
package = pkgs.shellcheck;
};
};
formatting = {
phpcbf = {
packages = [ pkgs.phpPackages.phpcbf ];
package = pkgs.phpPackages.phpcbf;
};
alejandra = {
packages = [ pkgs.alejandra ];
package = pkgs.alejandra;
};
nixfmt = {
packages = [ pkgs.nixfmt ];
package = pkgs.nixfmt;
};
prettier = {
packages = [ pkgs.nodePackages.prettier ];
package = pkgs.nodePackages.prettier;
};
black = {
packages = [ pkgs.python3Packages.black ];
package = pkgs.python3Packages.black;
};
beautysh = {
packages = [ inputs.beautysh.packages.${pkgs.system}.beautysh-python38 ];
package = inputs.beautysh.packages.${pkgs.system}.beautysh-python38;
};
fourmolu = {
packages = [ pkgs.haskellPackages.fourmolu ];
package = pkgs.haskellPackages.fourmolu;
};
fnlfmt = {
packages = [ pkgs.fnlfmt ];
package = pkgs.fnlfmt;
};
};
};