profiles/runestone/home-assistant.nix (view raw)
1{ config, ... }:
2{
3 services.home-assistant = {
4 enable = true;
5
6 config = {
7 default_config = { };
8
9 http = {
10 server_host = [
11 "127.0.0.1"
12 "::1"
13 ];
14 use_x_forwarded_for = true;
15 trusted_proxies = [
16 "127.0.0.1"
17 "::1"
18 ];
19 };
20 };
21 };
22
23 systemd.services.tailscale-serve-home-assistant = {
24 description = "Tailscale Serve for Home Assistant";
25 after = [
26 "home-assistant.service"
27 "tailscaled.service"
28 "tailscaled-autoconnect.service"
29 "tailscaled-set.service"
30 ];
31 wants = [
32 "home-assistant.service"
33 "tailscaled.service"
34 ];
35 wantedBy = [ "multi-user.target" ];
36
37 serviceConfig = {
38 Type = "oneshot";
39 RemainAfterExit = true;
40 Restart = "on-failure";
41 RestartSec = "1s";
42 ExecStartPre = "-${config.services.tailscale.package}/bin/tailscale serve clear svc:home";
43 ExecStart = "${config.services.tailscale.package}/bin/tailscale serve --bg --service svc:home --https=443 http://127.0.0.1:8123";
44 ExecStop = "-${config.services.tailscale.package}/bin/tailscale serve clear svc:home";
45 };
46 };
47}