···66 cfg = config.services.home-assistant;
7788 configFile = pkgs.writeText "configuration.yaml" (builtins.toJSON cfg.config);
99+1010+ availableComponents = pkgs.home-assistant.availableComponents;
1111+1212+ # Returns whether component is used in config
1313+ useComponent = component: hasAttrByPath (splitString "." component) cfg.config;
1414+1515+ # List of components used in config
1616+ extraComponents = filter useComponent availableComponents;
1717+1818+ package = if cfg.autoExtraComponents
1919+ then (cfg.package.override { inherit extraComponents; })
2020+ else cfg.package;
2121+922in {
1023 meta.maintainers = with maintainers; [ dotlambda ];
1124···2942 };
3043 frontend = { };
3144 http = { };
4545+ feedreader.urls = [ "https://nixos.org/blogs.xml" ];
3246 }
3347 '';
3448 description = ''
···4862 '';
4963 description = ''
5064 Home Assistant package to use.
5151- Most Home Assistant components require additional dependencies,
5252- which are best specified by overriding <literal>pkgs.home-assistant</literal>.
5353- You can find the dependencies by searching for failed imports in your log or by looking at this list:
5454- <link xlink:href="https://github.com/home-assistant/home-assistant/blob/master/requirements_all.txt"/>
6565+ Override <literal>extraPackages</literal> in order to add additional dependencies.
6666+ '';
6767+ };
6868+6969+ autoExtraComponents = mkOption {
7070+ default = true;
7171+ type = types.bool;
7272+ description = ''
7373+ If set to <literal>true</literal>, the components used in <literal>config</config>
7474+ are set as the specified package's <literal>extraComponents</literal>.
7575+ This in turn adds all packaged dependencies to the derivation.
7676+ You might still see import errors in your log.
7777+ In this case, you will need to package the necessary dependencies yourself
7878+ or ask for someone else to package them.
7979+ If a dependency is packaged but not automatically added to this list,
8080+ you might need to specify it in <literal>extraPackages</literal>.
5581 '';
5682 };
5783 };
···6793 '';
6894 serviceConfig = {
6995 ExecStart = ''
7070- ${cfg.package}/bin/hass --config "${cfg.configDir}"
9696+ ${package}/bin/hass --config "${cfg.configDir}"
7197 '';
7298 User = "hass";
7399 Group = "hass";