diff --git a/modules/cloonar-assistant/home-assistant/default.nix b/modules/cloonar-assistant/home-assistant/default.nix index 8653b24..58ccd59 100644 --- a/modules/cloonar-assistant/home-assistant/default.nix +++ b/modules/cloonar-assistant/home-assistant/default.nix @@ -7,80 +7,68 @@ let rev = "18dd725c29603f582cf1900e0d25f9f1063dbf11"; }) {}; - haOld = config.services.home-assistant; - haClean = builtins.removeAttrs haOld [ "autoExtraComponents" "applyDefaultConfig" ]; + ha-extraComponents = config.services.home-assistant.extraComponents ++ [ + "mobile_app" + "backup" + ]; - home-assistant-config = lib.recursiveUpdate haClean { - package = pkgs-with-home-assistant.home-assistant; - extraComponents = [ - "mobile_app" - "backup" + ha-config = lib.recursiveUpdate config.services.home-assistant.config let + hiddenEntities = [ + "sensor.last_boot" + "sensor.date" ]; + in { + recorder = { + db_url = "mysql://hass@localhost/hass?unix_socket=/var/run/mysqld/mysqld.sock"; + }; + homeassistant = { + name = "Home"; + latitude = "!secret home_latitude"; + longitude = "!secret home_longitude"; + elevation = "!secret home_elevation"; + unit_system = "metric"; + currency = "EUR"; + country = "AT"; + time_zone = "Europe/Vienna"; + external_url = "https://${domain}"; + }; + zone = { + name = "Home"; + latitude = "!secret home_latitude"; + longitude = "!secret home_longitude"; + radius = 35; + icon = "mdi:account-multiple"; - extraPackages = ps: with ps; [ - mysqlclient - ]; + }; + automation = "!include automations.yaml"; + frontend = { }; + http = { + use_x_forwarded_for = true; + trusted_proxies = [ + "127.0.0.1" + "::1" + ]; + }; + api = { }; + history.exclude = { + entities = hiddenEntities; + domains = [ + "automation" + "updater" + ]; + }; + "map" = { }; + # logbook.exclude.entities = "hiddenEntities"; + logger = { + default = "warning"; + }; - config = - let - hiddenEntities = [ - "sensor.last_boot" - "sensor.date" - ]; - in - { - recorder = { - db_url = "mysql://hass@localhost/hass?unix_socket=/var/run/mysqld/mysqld.sock"; - }; - homeassistant = { - name = "Home"; - latitude = "!secret home_latitude"; - longitude = "!secret home_longitude"; - elevation = "!secret home_elevation"; - unit_system = "metric"; - currency = "EUR"; - country = "AT"; - time_zone = "Europe/Vienna"; - external_url = "https://${domain}"; - }; - zone = { - name = "Home"; - latitude = "!secret home_latitude"; - longitude = "!secret home_longitude"; - radius = 35; - icon = "mdi:account-multiple"; - - }; - automation = "!include automations.yaml"; - frontend = { }; - http = { - use_x_forwarded_for = true; - trusted_proxies = [ - "127.0.0.1" - "::1" - ]; - }; - api = { }; - history.exclude = { - entities = hiddenEntities; - domains = [ - "automation" - "updater" - ]; - }; - "map" = { }; - # logbook.exclude.entities = "hiddenEntities"; - logger = { - default = "warning"; - }; - - network = { }; - zeroconf = { }; - system_health = { }; - default_config = { }; - system_log = { }; - }; - }; + network = { }; + zeroconf = { }; + system_health = { }; + default_config = { }; + system_log = { }; + } uid = config.ids.uids.hass; gid = config.ids.gids.hass; @@ -91,7 +79,6 @@ in createHome = true; group = "hass"; uid = uid; - isSystemUser = true; extraGroups = [ "dialout" ]; }; users.groups.hass.gid = gid; @@ -164,7 +151,16 @@ in pkgs.mariadb ]; - services.home-assistant = home-assistant-config; + services.home-assistant = { + package = pkgs-with-home-assistant.home-assistant; + extraComponents = ha-extraComponents; + + extraPackages = ps: with ps; [ + mysqlclient + ]; + + config = ha-config; + }; systemd.services.install-hacs = { description = "Install HACS";