nixos/home-assistant: add openFirewallForComponents option and open sonos component specific ports when it is enabled

This commit is contained in:
Sandro Jäckel
2026-03-07 22:32:45 +01:00
parent 7a5d8e9551
commit 02080bb9b1

View File

@@ -569,7 +569,25 @@ in
openFirewall = mkOption {
default = false;
type = types.bool;
description = "Whether to open the firewall for the specified port.";
description = ''
Whether to open the firewall for the specified frontend port
:::{.note}
For components specific ports see {option}`services.home-assistant.openFirewallForComponents`.
:::
'';
};
openFirewallForComponents = mkOption {
default = false;
type = types.bool;
description = ''
Whether to open required firewall ports for enabled components.
:::{.note}
For the frontend see {option}`services.home-assistant.openFirewall`.
:::
'';
};
blueprints = mergeAttrsList (
@@ -620,7 +638,13 @@ in
}
];
networking.firewall.allowedTCPPorts = mkIf cfg.openFirewall [ cfg.config.http.server_port ];
networking.firewall.allowedTCPPorts = mkMerge [
(mkIf cfg.openFirewall [ cfg.config.http.server_port ])
(mkIf cfg.openFirewallForComponents
# https://www.home-assistant.io/integrations/sonos/#network-requirements
(optionals (useComponent "sonos") [ 1400 ])
)
];
# symlink the configuration to /etc/home-assistant
environment.etc = mkMerge [