mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-20 16:15:43 +02:00
lib/pkg-lists: move to common location
Extract the helper functions defined in `efmls-configs-pkgs` to a common location where they can also be used by none-ls's package list.
This commit is contained in:
parent
d2aad1071f
commit
cdb2e79e51
3 changed files with 49 additions and 41 deletions
23
lib/pkg-lists.nix
Normal file
23
lib/pkg-lists.nix
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
# This file isn't (currently) part of `lib.nixvim`, but is used directly by `efmls` and `none-ls` pkg lists
|
||||||
|
lib: rec {
|
||||||
|
# Produces an attrset of { ${name} = name; }
|
||||||
|
topLevel = names: lib.genAttrs names lib.id;
|
||||||
|
|
||||||
|
# Produces an attrset of { ${name} = null; }
|
||||||
|
nullAttrs = names: lib.genAttrs names (_: null);
|
||||||
|
|
||||||
|
# Produces an attrset of { ${name} = [ scope name ]; }
|
||||||
|
# Where the "scope" is the (nested) attr names,
|
||||||
|
# and "name" is the value.
|
||||||
|
# If the name value is a list, it will be expanded into multiple attrs.
|
||||||
|
scoped = lib.concatMapAttrs (
|
||||||
|
scope: v:
|
||||||
|
if builtins.isAttrs v then
|
||||||
|
lib.mapAttrs (_: loc: [ scope ] ++ loc) (scoped v)
|
||||||
|
else
|
||||||
|
lib.genAttrs (lib.toList v) (name: [
|
||||||
|
scope
|
||||||
|
name
|
||||||
|
])
|
||||||
|
);
|
||||||
|
}
|
|
@ -1,4 +1,8 @@
|
||||||
lib: {
|
lib:
|
||||||
|
let
|
||||||
|
inherit (import ../../../lib/pkg-lists.nix lib) topLevel scoped;
|
||||||
|
in
|
||||||
|
{
|
||||||
# efmls-configs tools that have no corresponding nixpkgs package
|
# efmls-configs tools that have no corresponding nixpkgs package
|
||||||
unpackaged = [
|
unpackaged = [
|
||||||
"blade_formatter"
|
"blade_formatter"
|
||||||
|
@ -28,20 +32,6 @@ lib: {
|
||||||
|
|
||||||
# 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 =
|
packaged =
|
||||||
let
|
|
||||||
# TODO: move these helpers to a shared location so that none-ls can also use them
|
|
||||||
topLevel = names: lib.genAttrs names lib.id;
|
|
||||||
scoped = lib.concatMapAttrs (
|
|
||||||
scope: v:
|
|
||||||
if builtins.isAttrs v then
|
|
||||||
lib.mapAttrs (_: loc: [ scope ] ++ loc) (scoped v)
|
|
||||||
else
|
|
||||||
lib.genAttrs (lib.toList v) (name: [
|
|
||||||
scope
|
|
||||||
name
|
|
||||||
])
|
|
||||||
);
|
|
||||||
in
|
|
||||||
# Top-level packages
|
# Top-level packages
|
||||||
topLevel [
|
topLevel [
|
||||||
"actionlint"
|
"actionlint"
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
lib: {
|
lib:
|
||||||
|
let
|
||||||
|
inherit (import ../../lib/pkg-lists.nix lib) topLevel scoped nullAttrs;
|
||||||
|
in
|
||||||
|
{
|
||||||
# builtin sources that don't require a package
|
# builtin sources that don't require a package
|
||||||
noPackage = [
|
noPackage = [
|
||||||
"gitrebase"
|
"gitrebase"
|
||||||
|
@ -20,7 +24,7 @@ lib: {
|
||||||
# nixpkgs packages for a given source
|
# nixpkgs packages for a given source
|
||||||
packaged =
|
packaged =
|
||||||
# Top-level packages
|
# Top-level packages
|
||||||
lib.genAttrs [
|
topLevel [
|
||||||
"actionlint"
|
"actionlint"
|
||||||
"alejandra"
|
"alejandra"
|
||||||
"asmfmt"
|
"asmfmt"
|
||||||
|
@ -94,29 +98,20 @@ lib: {
|
||||||
"yapf"
|
"yapf"
|
||||||
"zprint"
|
"zprint"
|
||||||
"zsh"
|
"zsh"
|
||||||
] lib.id
|
]
|
||||||
# Scoped packages
|
# Scoped packages
|
||||||
//
|
// scoped {
|
||||||
lib.concatMapAttrs
|
nodePackages = [
|
||||||
(
|
"alex"
|
||||||
scope: names:
|
"prettier"
|
||||||
lib.genAttrs names (name: [
|
];
|
||||||
scope
|
phpPackages = [
|
||||||
name
|
"phpmd"
|
||||||
])
|
"phpstan"
|
||||||
)
|
];
|
||||||
{
|
rubyPackages = "htmlbeautifier";
|
||||||
nodePackages = [
|
ocamlPackages = "ocamlformat";
|
||||||
"alex"
|
}
|
||||||
"prettier"
|
|
||||||
];
|
|
||||||
phpPackages = [
|
|
||||||
"phpmd"
|
|
||||||
"phpstan"
|
|
||||||
];
|
|
||||||
rubyPackages = [ "htmlbeautifier" ];
|
|
||||||
ocamlPackages = [ "ocamlformat" ];
|
|
||||||
}
|
|
||||||
# Packages where the name is different
|
# Packages where the name is different
|
||||||
// {
|
// {
|
||||||
ansiblelint = "ansible-lint";
|
ansiblelint = "ansible-lint";
|
||||||
|
@ -229,7 +224,7 @@ lib: {
|
||||||
xmllint = "libxml2";
|
xmllint = "libxml2";
|
||||||
}
|
}
|
||||||
# builtin sources that are not packaged in nixpkgs
|
# builtin sources that are not packaged in nixpkgs
|
||||||
// lib.genAttrs [
|
// nullAttrs [
|
||||||
"blade_formatter"
|
"blade_formatter"
|
||||||
"bsfmt"
|
"bsfmt"
|
||||||
"bslint"
|
"bslint"
|
||||||
|
@ -268,5 +263,5 @@ lib: {
|
||||||
"textlint"
|
"textlint"
|
||||||
"twigcs"
|
"twigcs"
|
||||||
"vacuum"
|
"vacuum"
|
||||||
] (_: null);
|
];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue