summaryrefslogtreecommitdiffstats
path: root/nixos
diff options
context:
space:
mode:
authorFrederik Rietdijk <freddyrietdijk@fridh.nl>2018-02-03 08:01:50 +0000
committerGitHub <noreply@github.com>2018-02-03 08:01:50 +0000
commitdb58049f75a979a233403bc097746df005d9f305 (patch)
treea654f9dfa60140f206b4ce2e19f5820c1062ac18 /nixos
parentc2b84b27ec38604afd851afe4cad28cfc0754522 (diff)
parent78c2ca326e4320ca9b53d2dc7eca8b385d2681af (diff)
Merge pull request #34494 from dotlambda/home-assistant
home-assistant: compute extraComponents from config
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/misc/home-assistant.nix36
-rw-r--r--nixos/tests/home-assistant.nix7
2 files changed, 37 insertions, 6 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";
diff --git a/nixos/tests/home-assistant.nix b/nixos/tests/home-assistant.nix
index 0e2fee8e808d..5d7e0ec65e73 100644
--- a/nixos/tests/home-assistant.nix
+++ b/nixos/tests/home-assistant.nix
@@ -17,13 +17,16 @@ in {
homeassistant = {
name = "Home";
time_zone = "UTC";
+ latitude = "0.0";
+ longitude = "0.0";
+ elevation = 0;
};
frontend = { };
http = { };
};
};
};
- };
+ };
testScript = ''
startAll;
@@ -37,5 +40,7 @@ in {
$hass->waitForOpenPort(8123);
$hass->succeed("curl --fail http://localhost:8123/states");
$hass->succeed("curl --fail http://localhost:8123/api/ | grep 'API running'");
+
+ $hass->fail("cat ${configDir}/home-assistant.log | grep -qF ERROR");
'';
})