{ config, ... }: { services.home-assistant = { enable = true; config = { default_config = { }; http = { server_host = [ "127.0.0.1" "::1" ]; use_x_forwarded_for = true; trusted_proxies = [ "127.0.0.1" "::1" ]; }; }; }; systemd.services.tailscale-serve-home-assistant = { description = "Tailscale Serve for Home Assistant"; after = [ "home-assistant.service" "tailscaled.service" "tailscaled-autoconnect.service" "tailscaled-set.service" ]; wants = [ "home-assistant.service" "tailscaled.service" ]; wantedBy = [ "multi-user.target" ]; serviceConfig = { Type = "oneshot"; RemainAfterExit = true; Restart = "on-failure"; RestartSec = "1s"; ExecStartPre = "-${config.services.tailscale.package}/bin/tailscale serve clear svc:home"; ExecStart = "${config.services.tailscale.package}/bin/tailscale serve --bg --service svc:home --https=443 http://127.0.0.1:8123"; ExecStop = "-${config.services.tailscale.package}/bin/tailscale serve clear svc:home"; }; }; }