From ccdfcd1912b904f52bfbce1f00eef17e0feeac3a Mon Sep 17 00:00:00 2001 From: matt1432 Date: Wed, 4 Sep 2024 10:46:47 -0400 Subject: [PATCH] fix(hass): fix compilation of ESP firmware --- devices/homie/modules/home-assistant.nix | 36 ++++++++++++++++++------ 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/devices/homie/modules/home-assistant.nix b/devices/homie/modules/home-assistant.nix index 0fe6a4c9..5a3bce41 100644 --- a/devices/homie/modules/home-assistant.nix +++ b/devices/homie/modules/home-assistant.nix @@ -1,4 +1,6 @@ { + config, + lib, pkgs, self, wakewords-src, @@ -43,7 +45,7 @@ mode = "yaml"; }; - # Wanted defaults + # `default_config` enables too much stuff. this is what I want from it assist_pipeline = {}; config = {}; conversation = {}; @@ -59,13 +61,6 @@ }; }; - esphome = { - enable = true; - address = "100.64.0.10"; - port = 6052; - }; - - # Needs manual setting in GUI wyoming = { piper.servers."en" = { enable = true; @@ -95,4 +90,29 @@ }; }; }; + + services.esphome = { + enable = true; + address = "100.64.0.10"; + port = 6052; + }; + + # FIXME: https://github.com/NixOS/nixpkgs/issues/339557 + systemd.services.esphome = let + inherit (lib) mkForce; + + cfg = config.services.esphome; + stateDir = "/var/lib/private/esphome"; + esphomeParams = + if cfg.enableUnixSocket + then "--socket /run/esphome/esphome.sock" + else "--address ${cfg.address} --port ${toString cfg.port}"; + in { + environment.PLATFORMIO_CORE_DIR = mkForce "/var/lib/private/esphome/.platformio"; + + serviceConfig = { + ExecStart = mkForce "${cfg.package}/bin/esphome dashboard ${esphomeParams} ${stateDir}"; + WorkingDirectory = mkForce stateDir; + }; + }; }