plugins/efmls: use mkPackageOption

This commit is contained in:
Matt Sturgeon 2024-09-03 16:15:48 +01:00
parent 2ef974182e
commit a8a7e405f4
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299
3 changed files with 153 additions and 119 deletions

View file

@ -1,4 +1,4 @@
pkgs: { lib: {
# efmls-configs tools that have no corresponding nixpkgs package # efmls-configs tools that have no corresponding nixpkgs package
unpackaged = [ unpackaged = [
"blade_formatter" "blade_formatter"
@ -27,115 +27,149 @@ pkgs: {
]; ];
# Mapping from a efmls-configs tool name to the corresponding nixpkgs package # Mapping from a efmls-configs tool name to the corresponding nixpkgs package
packaged = with pkgs; { packaged =
inherit let
actionlint # TODO: move these helpers to a shared location so that none-ls can also use them
alejandra topLevel = names: lib.genAttrs names lib.id;
ameba scoped = lib.concatMapAttrs (
astyle scope: v:
bashate if builtins.isAttrs v then
beautysh lib.mapAttrs (_: loc: [ scope ] ++ loc) (scoped v)
biome else
black lib.genAttrs (lib.toList v) (name: [
buf scope
cbfmt name
checkmake ])
clazy );
codespell in
cppcheck # Top-level packages
cpplint topLevel [
dfmt "actionlint"
djlint "alejandra"
dmd "ameba"
dprint "astyle"
fish "bashate"
flawfinder "beautysh"
fnlfmt "biome"
gcc "black"
gitlint "buf"
gofumpt "cbfmt"
golines "checkmake"
golint "clazy"
hadolint "codespell"
isort "cppcheck"
joker "cpplint"
jq "dfmt"
languagetool "djlint"
mypy "dmd"
php "dprint"
prettypst "fish"
proselint "flawfinder"
protolint "fnlfmt"
pylint "gcc"
rubocop "gitlint"
ruff "gofumpt"
rustfmt "golines"
scalafmt "golint"
selene "hadolint"
shellcheck "isort"
shellharden "joker"
shfmt "jq"
smlfmt "languagetool"
sqlfluff "mypy"
statix "php"
stylua "prettypst"
taplo "proselint"
typstfmt "protolint"
typstyle "pylint"
uncrustify "rubocop"
vale "ruff"
yamllint "rustfmt"
yapf "scalafmt"
; "selene"
inherit (python3.pkgs) "shellcheck"
autopep8 "shellharden"
flake8 "shfmt"
mdformat "smlfmt"
vulture "sqlfluff"
; "statix"
inherit (nodePackages) "stylua"
eslint_d "taplo"
prettier "typstfmt"
alex "typstyle"
sql-formatter "uncrustify"
stylelint "vale"
textlint "yamllint"
; "yapf"
inherit (phpPackages) phan phpstan psalm; ]
inherit (luaPackages) luacheck; # Scoped packages
inherit (haskellPackages) fourmolu; // scoped {
ansible_lint = ansible-lint; python3.pkgs = [
chktex = texliveMedium; "autopep8"
clang_format = clang-tools; "flake8"
clang_tidy = clang-tools; "mdformat"
clj_kondo = clj-kondo; "vulture"
cmake_lint = cmake-format; ];
dartfmt = dart; nodePackages = [
dotnet_format = dotnet-runtime; "eslint" # FIXME: No way to have a transition fallback...
# TODO: Added 2024-08-31; remove 2024-11-31 "eslint_d"
# eslint was moved out of nodePackages set without alias "prettier"
# Using fallback as a transition period "alex"
eslint = pkgs.eslint or pkgs.nodePackages.eslint; "sql-formatter"
fish_indent = fish; "stylelint"
gofmt = go; "textlint"
goimports = go-tools; ];
golangci_lint = golangci-lint; phpPackages = [
google_java_format = google-java-format; "phan"
go_revive = revive; "phpstan"
latexindent = texliveMedium; "psalm"
lua_format = luaformatter; ];
markdownlint = markdownlint-cli; luaPackages = [
mcs = mono; "luacheck"
nixfmt = nixfmt-classic; ];
phpcbf = phpPackages.php-codesniffer; haskellPackages = [
php_cs_fixer = phpPackages.php-cs-fixer; "fourmolu"
phpcs = phpPackages.php-codesniffer; ];
prettier_d = prettierd; }
slither = slither-analyzer; # Packages where the name is different
staticcheck = go-tools; // {
terraform_fmt = terraform; ansible_lint = "ansible-lint";
vint = vim-vint; chktex = "texliveMedium";
write_good = write-good; clang_format = "clang-tools";
yq = yq-go; clang_tidy = "clang-tools";
clj_kondo = "clj-kondo";
cmake_lint = "cmake-format";
dartfmt = "dart";
dotnet_format = "dotnet-runtime";
fish_indent = "fish";
gofmt = "go";
goimports = "go-tools";
golangci_lint = "golangci-lint";
google_java_format = "google-java-format";
go_revive = "revive";
latexindent = "texliveMedium";
lua_format = "luaformatter";
markdownlint = "markdownlint-cli";
mcs = "mono";
nixfmt = "nixfmt-classic";
phpcbf = [
"phpPackages"
"php-codesniffer"
];
php_cs_fixer = [
"phpPackages"
"php-cs-fixer"
];
phpcs = [
"phpPackages"
"php-codesniffer"
];
prettier_d = "prettierd";
slither = "slither-analyzer";
staticcheck = "go-tools";
terraform_fmt = "terraform";
vint = "vim-vint";
write_good = "write-good";
yq = "yq-go";
}; };
} }

View file

@ -7,7 +7,7 @@
}: }:
let let
tools = import ../../../generated/efmls-configs.nix; tools = import ../../../generated/efmls-configs.nix;
inherit (import ./efmls-configs-pkgs.nix pkgs) packaged; inherit (import ./efmls-configs-pkgs.nix lib) packaged;
in in
{ {
options.plugins.efmls-configs = { options.plugins.efmls-configs = {
@ -26,10 +26,10 @@ in
toolPackages = lib.pipe packaged [ toolPackages = lib.pipe packaged [
# Produce package a option for each tool # Produce package a option for each tool
(lib.attrsets.mapAttrs ( (lib.attrsets.mapAttrs (
tool: pkg: name: loc:
helpers.mkPackageOption { lib.mkPackageOption pkgs name {
name = tool; nullable = true;
default = pkg; default = loc;
} }
)) ))
# Filter package defaults that are not compatible with the current platform # Filter package defaults that are not compatible with the current platform
@ -38,7 +38,7 @@ in
if lib.meta.availableOn pkgs.stdenv.hostPlatform opt.default then if lib.meta.availableOn pkgs.stdenv.hostPlatform opt.default then
opt opt
else else
opt // { default = null; } builtins.removeAttrs opt [ "defaultText" ] // { default = null; }
)) ))
]; ];

View file

@ -54,7 +54,7 @@ let
declared = declared =
let let
inherit (import ../plugins/lsp/language-servers/efmls-configs-pkgs.nix pkgs) packaged unpackaged; inherit (import ../plugins/lsp/language-servers/efmls-configs-pkgs.nix lib) packaged unpackaged;
in in
unpackaged ++ lib.attrsets.attrNames packaged; unpackaged ++ lib.attrsets.attrNames packaged;