plugins/none-ls: combine packaged+unpackaged lists

We can just make `packaged` nullable again.
This commit is contained in:
Matt Sturgeon 2024-07-11 22:52:53 +01:00
parent d8f3113e90
commit 4f3cd9f368
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299
3 changed files with 223 additions and 226 deletions

View file

@ -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};
@ -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) {