nixos/home-assistant: add extraComponents option

It simply should not be required to override the package for such a
common use case, especially since the module usually adds another
override on top to inherit extraComponents.
This commit is contained in:
Martin Weinelt 2022-01-30 02:35:34 +01:00
parent 59a367bcab
commit 4a0b964b34
No known key found for this signature in database
GPG key ID: 87C1E9888F856759

View file

@ -49,14 +49,17 @@ let
useComponent = component:
hasAttrByPath (splitString "." component) cfg.config
|| useComponentPlatform component
|| useExplicitComponent component;
|| useExplicitComponent component
|| builtins.elem component cfg.extraComponents;
# Final list of components passed into the package to include required dependencies
extraComponents = filter useComponent availableComponents;
package = (cfg.package.override {
inherit extraComponents;
});
package = (cfg.package.override (oldArgs: {
# Respect overrides that already exist in the passed package and
# concat it with values passed via the module.
extraComponents = oldArgs.extraComponents ++ extraComponents;
}));
in {
imports = [
@ -82,6 +85,31 @@ in {
description = "The config directory, where your <filename>configuration.yaml</filename> is located.";
};
extraComponents = mkOption {
type = types.listOf (types.enum availableComponents);
default = [
# List of components required to complete the onboarding
"default_config"
"met"
"esphome"
];
example = literalExpression ''
[
"analytics"
"default_config"
"esphome"
"my"
"shopping_list"
"wled"
]
'';
description = ''
List of <link xlink:href="https://www.home-assistant.io/integrations/">components</link> that have their dependencies included in the package.
The component name can be found in the URL, for example <literal>https://www.home-assistant.io/integrations/ffmpeg/</literal> would map to <literal>ffmpeg</literal>.
'';
};
config = mkOption {
type = types.submodule {
freeformType = format.type;