I was referring to nixos wiki for home-assistant, and came with the following config. I need to allow my hass server to be accessible on the port its configured on.
{ config, pkgs, ... }:
{
services.home-assistant = {
enable = true;
openFirewall = true;
package = pkgs.unstable.home-assistant;
extraComponents = [
"apple_tv"
"met"
"lastfm_scrobbler"
"hacs"
"divoom_pixoo"
"isal"
];
config = {
default_config = { };
http = {
trusted_proxies = [
"::1"
"127.0.0.1"
];
use_x_forwarded_for = true;
};
"automation ui" = "!include automations.yaml";
"scene ui" = "!include scenes.yaml";
"script ui" = "!include scripts.yaml";
recorder.db_url = "postgresql://@/hass";
};
extraPackages = ps: with ps; [ psycopg2 ];
};
services.postgresql = {
enable = true;
ensureDatabases = [ "hass" ];
ensureUsers = [{
name = "hass";
ensureDBOwnership = true;
}];
};
networking.firewall.allowedTCPPorts = [
config.services.home-assistant.config.http.server_port
1883
];
systemd.tmpfiles.rules = [
"f ${config.services.home-assistant.configDir}/automations.yaml 0755 hass hass"
];
services.mosquitto = {
enable = true;
listeners = [
{
acl = [ "pattern readwrite #" ];
omitPasswordAuth = true;
settings.allow_anonymous = true;
}
];
};
}
Upon running home-manager switch --flake .#username@hostname
I get the following error
error: attribute 'home-assistant' missing
at /nix/store/i0f9rldmf3vx4pxc3qjgiawwm5w3bp72-source/home-manager/homelab/hass.nix:42:5:
41| networking.firewall.allowedTCPPorts = [
42| config.services.home-assistant.config.http.server_port
| ^
43| 1883
I am pretty new to nixos configuration so any help would be amazing.
note that I am using the starter configs for organizing my nix configs from here nix-starter-configs/standard at main · Misterio77/nix-starter-configs · GitHub
I have imports configured ofc. Here is a tree output of my home-manager config (home.nix, imports homelab, where i have hass imported into default.nix)
home-manager/
├── homelab
│ ├── default.nix
│ └── hass.nix
├── home.nix