From 5f6553e5bc637d269508d98c62218a9570b9af26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Schr=C3=B6ter?= Date: Thu, 29 Dec 2022 14:13:40 +0100 Subject: [PATCH] feat: add ESPHome dashboard --- home-server.nix | 2 ++ services/esphome.nix | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 services/esphome.nix diff --git a/home-server.nix b/home-server.nix index 452d174..4afae25 100644 --- a/home-server.nix +++ b/home-server.nix @@ -24,6 +24,7 @@ in with builtins; { ./services/mosquitto.nix ./services/genie.nix ./services/home-assistant.nix + ./services/esphome.nix ./services/watchtower.nix ./services/owntracks.nix ./services/immich.nix @@ -82,6 +83,7 @@ in with builtins; { passwordFile = config.age.secrets.cloudflare.path; domains = [ "home.felschr.com" + "esphome.felschr.com" "cloud.felschr.com" "office.felschr.com" "media.felschr.com" diff --git a/services/esphome.nix b/services/esphome.nix new file mode 100644 index 0000000..2f696c6 --- /dev/null +++ b/services/esphome.nix @@ -0,0 +1,32 @@ +{ config, pkgs, ... }: + +with pkgs; + +let + port = 6052; + inherit (config.services.home-assistant) configDir; +in { + services.nginx = { + virtualHosts."esphome.felschr.com" = { + enableACME = true; + forceSSL = true; + locations."/" = { + proxyPass = "http://[::1]:${toString port}"; + proxyWebsockets = true; + }; + }; + }; + + systemd.services.esphome = { + description = "ESPHome"; + after = [ "network.target" ]; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + User = "hass"; + Group = "hass"; + Restart = "on-failure"; + WorkingDirectory = configDir; + ExecStart = "${pkgs.esphome}/bin/esphome dashboard ${configDir}/esphome"; + }; + }; +}