0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-14 06:00:33 +03:00

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; availableComponents = cfg.package.availableComponents;
explicitComponents = cfg.package.extraComponents;
usedPlatforms = config: usedPlatforms = config:
if isAttrs config then if isAttrs config then
optional (config ? platform) config.platform optional (config ? platform) config.platform
@ -42,10 +44,13 @@ let
# } ]; # } ];
useComponentPlatform = component: elem component (usedPlatforms cfg.config); 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: useComponent = component:
hasAttrByPath (splitString "." component) cfg.config hasAttrByPath (splitString "." component) cfg.config
|| useComponentPlatform component; || useComponentPlatform component
|| useExplicitComponent component;
# List of components used in config # List of components used in config
extraComponents = filter useComponent availableComponents; extraComponents = filter useComponent availableComponents;

View file

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