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 { name
, sourceType , sourceType
, description ? "Enable ${name} source, for null-ls." , description ? "Enable ${name} source, for null-ls."
, packages ? [ ] , package ? null
, extraPackages ? [ ]
, ... , ...
}: }:
# returns a module # returns a module
@ -13,6 +14,14 @@
let let
helpers = import ../helpers.nix args; helpers = import ../helpers.nix args;
cfg = config.plugins.null-ls.sources.${sourceType}.${name}; 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 in
{ {
options.plugins.null-ls.sources.${sourceType}.${name} = { options.plugins.null-ls.sources.${sourceType}.${name} = {
@ -28,10 +37,11 @@
# '\'{ extra_args = { "--no-semi", "--single-quote", "--jsx-single-quote" } }'\' # '\'{ extra_args = { "--no-semi", "--single-quote", "--jsx-single-quote" } }'\'
# ''; # '';
}; };
}; } // packageOption;
config = mkIf cfg.enable { config = mkIf cfg.enable {
extraPackages = packages; # Does this evaluate package?
extraPackages = packages ++ optional (package != null) cfg.package;
# Add source to list of sources # Add source to list of sources
plugins.null-ls.sourcesItems = plugins.null-ls.sourcesItems =

View file

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