Merge pull request #148086 from mweinelt/hass-consider-extracomponents

This commit is contained in:
Martin Weinelt 2021-12-01 19:43:33 +01:00 committed by GitHub
commit 0804405afb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 3 deletions

View file

@ -24,6 +24,8 @@ let
availableComponents = cfg.package.availableComponents;
explicitComponents = cfg.package.extraComponents;
usedPlatforms = config:
if isAttrs config then
optional (config ? platform) config.platform
@ -42,10 +44,13 @@ let
# } ];
useComponentPlatform = component: elem component (usedPlatforms cfg.config);
# Returns whether component is used in config
useExplicitComponent = component: elem component explicitComponents;
# Returns whether component is used in config or explicitly passed into package
useComponent = component:
hasAttrByPath (splitString "." component) cfg.config
|| useComponentPlatform component;
|| useComponentPlatform component
|| useExplicitComponent component;
# List of components used in config
extraComponents = filter useComponent availableComponents;

View file

@ -24,6 +24,11 @@ in {
services.home-assistant = {
inherit configDir;
enable = true;
package = (pkgs.home-assistant.override {
extraComponents = [ "zha" ];
}).overrideAttrs (oldAttrs: {
doInstallCheck = false;
});
config = {
homeassistant = {
name = "Home";
@ -87,6 +92,8 @@ in {
with subtest("Check that capabilities are passed for emulated_hue to bind to port 80"):
hass.wait_for_open_port(80)
hass.succeed("curl --fail http://localhost:80/description.xml")
with subtest("Check extra components are considered in systemd unit hardening"):
hass.succeed("systemctl show -p DeviceAllow home-assistant.service | grep -q char-ttyUSB")
with subtest("Print log to ease debugging"):
output_log = hass.succeed("cat ${configDir}/home-assistant.log")
print("\n### home-assistant.log ###\n")

View file

@ -888,7 +888,7 @@ in with py.pkgs; buildPythonApplication rec {
'';
passthru = {
inherit availableComponents;
inherit availableComponents extraComponents;
python = py;
tests = {
inherit (nixosTests) home-assistant;