diff options
author | Robert Schütz <robert.schuetz@stud.uni-heidelberg.de> | 2018-02-01 13:42:07 +0100 |
---|---|---|
committer | Robert Schütz <robert.schuetz@stud.uni-heidelberg.de> | 2018-02-02 09:48:50 +0100 |
commit | 78c2ca326e4320ca9b53d2dc7eca8b385d2681af (patch) | |
tree | e2c1bf9db14fca3f3fd81c474066ee34630bdcbe /nixos/modules | |
parent | 356b5532392a0d6df2c99f28964803d989e31f89 (diff) | |
download | nixlib-78c2ca326e4320ca9b53d2dc7eca8b385d2681af.tar nixlib-78c2ca326e4320ca9b53d2dc7eca8b385d2681af.tar.gz nixlib-78c2ca326e4320ca9b53d2dc7eca8b385d2681af.tar.bz2 nixlib-78c2ca326e4320ca9b53d2dc7eca8b385d2681af.tar.lz nixlib-78c2ca326e4320ca9b53d2dc7eca8b385d2681af.tar.xz nixlib-78c2ca326e4320ca9b53d2dc7eca8b385d2681af.tar.zst nixlib-78c2ca326e4320ca9b53d2dc7eca8b385d2681af.zip |
home-assistant: compute extraComponents from config
Diffstat (limited to 'nixos/modules')
-rw-r--r-- | nixos/modules/services/misc/home-assistant.nix | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/nixos/modules/services/misc/home-assistant.nix b/nixos/modules/services/misc/home-assistant.nix index bc463d3e670c..4fbf5a412d12 100644 --- a/nixos/modules/services/misc/home-assistant.nix +++ b/nixos/modules/services/misc/home-assistant.nix @@ -6,6 +6,19 @@ let cfg = config.services.home-assistant; configFile = pkgs.writeText "configuration.yaml" (builtins.toJSON cfg.config); + + availableComponents = pkgs.home-assistant.availableComponents; + + # Returns whether component is used in config + useComponent = component: hasAttrByPath (splitString "." component) cfg.config; + + # List of components used in config + extraComponents = filter useComponent availableComponents; + + package = if cfg.autoExtraComponents + then (cfg.package.override { inherit extraComponents; }) + else cfg.package; + in { meta.maintainers = with maintainers; [ dotlambda ]; @@ -29,6 +42,7 @@ in { }; frontend = { }; http = { }; + feedreader.urls = [ "https://nixos.org/blogs.xml" ]; } ''; description = '' @@ -48,10 +62,22 @@ in { ''; description = '' Home Assistant package to use. - Most Home Assistant components require additional dependencies, - which are best specified by overriding <literal>pkgs.home-assistant</literal>. - You can find the dependencies by searching for failed imports in your log or by looking at this list: - <link xlink:href="https://github.com/home-assistant/home-assistant/blob/master/requirements_all.txt"/> + Override <literal>extraPackages</literal> in order to add additional dependencies. + ''; + }; + + autoExtraComponents = mkOption { + default = true; + type = types.bool; + description = '' + If set to <literal>true</literal>, the components used in <literal>config</config> + are set as the specified package's <literal>extraComponents</literal>. + This in turn adds all packaged dependencies to the derivation. + You might still see import errors in your log. + In this case, you will need to package the necessary dependencies yourself + or ask for someone else to package them. + If a dependency is packaged but not automatically added to this list, + you might need to specify it in <literal>extraPackages</literal>. ''; }; }; @@ -67,7 +93,7 @@ in { ''; serviceConfig = { ExecStart = '' - ${cfg.package}/bin/hass --config "${cfg.configDir}" + ${package}/bin/hass --config "${cfg.configDir}" ''; User = "hass"; Group = "hass"; |