Skip to content

Commit

Permalink
plugins/none-ls: combine packaged+unpackaged lists
Browse files Browse the repository at this point in the history
We can just make `packaged` nullable again.
  • Loading branch information
MattSturgeon committed Jul 13, 2024
1 parent d8f3113 commit 4f3cd9f
Show file tree
Hide file tree
Showing 3 changed files with 223 additions and 226 deletions.
6 changes: 3 additions & 3 deletions flake-modules/updates/none-ls.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
pkgs,
}:
let
inherit (import ../../plugins/none-ls/packages.nix pkgs) packaged noPackage unpackaged;
inherit (import ../../plugins/none-ls/packages.nix pkgs) packaged noPackage;

builtinSources = lib.trivial.importJSON "${vimPlugins.none-ls-nvim.src}/doc/builtins.json";

Expand All @@ -14,11 +14,11 @@ let
toolNames = lib.unique (lib.flatten (lib.attrValues builtinSourceNames));

undeclaredTool = lib.filter (
name: !(lib.hasAttr name packaged || lib.elem name noPackage || lib.elem name unpackaged)
name: !(lib.hasAttr name packaged || lib.elem name noPackage)
) toolNames;

uselesslyDeclaredTool = lib.filter (name: !(lib.elem name toolNames)) (
unpackaged ++ noPackage ++ (lib.attrNames packaged)
noPackage ++ (lib.attrNames packaged)
);
in
writeText "efmls-configs-sources.nix" (
Expand Down
41 changes: 19 additions & 22 deletions plugins/none-ls/_mk-source-plugin.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ sourceType: sourceName:
...
}:
let
inherit (import ./packages.nix pkgs) packaged unpackaged;
inherit (import ./packages.nix pkgs) packaged;
pkg = packaged.${sourceName};

cfg = config.plugins.none-ls;
cfg' = config.plugins.none-ls.sources.${sourceType}.${sourceName};
Expand All @@ -22,27 +23,23 @@ in
'';
}
# Only declare a package option if a package is required
// lib.optionalAttrs (packaged ? ${sourceName} || lib.elem sourceName unpackaged) {
package =
let
pkg = packaged.${sourceName} or null;
in
lib.mkOption (
{
type = lib.types.nullOr lib.types.package;
description =
"Package to use for ${sourceName}."
+ (lib.optionalString (pkg == null) (
"\n\n"
+ ''
Currently not packaged in nixpkgs.
Either set this to `null` and install ${sourceName} outside of nix,
or set this to a custom nix package.
''
));
}
// lib.optionalAttrs (pkg != null) { default = pkg; }
);
// lib.optionalAttrs (packaged ? ${sourceName}) {
package = lib.mkOption (
{
type = lib.types.nullOr lib.types.package;
description =
"Package to use for ${sourceName}."
+ (lib.optionalString (pkg == null) (
"\n\n"
+ ''
Currently not packaged in nixpkgs.
Either set this to `null` and install ${sourceName} outside of nix,
or set this to a custom nix package.
''
));
}
// lib.optionalAttrs (pkg != null) { default = pkg; }
);
};

config = lib.mkIf (cfg.enable && cfg'.enable) {
Expand Down
Loading

0 comments on commit 4f3cd9f

Please sign in to comment.