nixos/home-assistant: consider extraComponents in hardening

Previously the extraComponents added to an overriden package would not
have been considered in hardening measures enforced by the module.

Home Assistant is warning the user about component definitions having
moved away from YAML, so using an override to include support for a
component might become the better way moving forward.
This commit is contained in:
Martin Weinelt 2021-12-01 01:09:52 +01:00
parent ab5a3f8226
commit 254dd2a102
2 changed files with 8 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

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