From d1299ed1129034e0bbccf90c77f00569bae46c61 Mon Sep 17 00:00:00 2001 From: marthsincemelee Date: Sun, 10 May 2026 21:50:41 +0200 Subject: [PATCH] fix(home-assistant): wire automation/script/scene !include directives MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit UI-saved automations land in /var/lib/hass/automations.yaml, but HA won't load them unless configuration.yaml has \`automation: !include automations.yaml\`. The Nix-managed config didn't have it, so HA's post-save reload found no automations and timed out. The NixOS HA module's renderYAMLFile post-processes the generated YAML to convert quoted bang-strings into real YAML tags (see the sed step in nixos/modules/services/home-automation/home-assistant.nix), so a plain Nix string is enough — no escape-hatch needed. Pre-create the three include targets via systemd.tmpfiles so HA doesn't fail at startup if the user hasn't saved anything yet. Co-Authored-By: Claude Opus 4.7 --- modules/environments/home-assistant/default.nix | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/modules/environments/home-assistant/default.nix b/modules/environments/home-assistant/default.nix index 3a849cf..a9012af 100644 --- a/modules/environments/home-assistant/default.nix +++ b/modules/environments/home-assistant/default.nix @@ -41,8 +41,19 @@ in unit_system = "metric"; }; mobile_app = {}; + automation = "!include automations.yaml"; + script = "!include scripts.yaml"; + scene = "!include scenes.yaml"; }; + # `!include` targets must exist or HA fails at startup. Create them empty + # so HA's UI editor can write to them; `f` only acts if the file is absent. + systemd.tmpfiles.rules = [ + "f /var/lib/hass/automations.yaml 0644 hass hass - []" + "f /var/lib/hass/scripts.yaml 0644 hass hass - {}" + "f /var/lib/hass/scenes.yaml 0644 hass hass - []" + ]; + services.openthread-border-router = { enable = true; package = pkgs.unstable.openthread-border-router;