2022-12-29 14:13:40 +01:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
with pkgs;
|
|
|
|
|
|
|
|
let
|
|
|
|
port = 6052;
|
|
|
|
inherit (config.services.home-assistant) configDir;
|
2022-12-29 16:25:53 +01:00
|
|
|
passwordFile = config.age.secrets.esphome-password.path;
|
2024-05-26 16:45:38 +02:00
|
|
|
in
|
|
|
|
{
|
2022-12-29 20:25:07 +01:00
|
|
|
age.secrets.esphome-password.file = ../../secrets/esphome/password.age;
|
2022-12-29 16:25:53 +01:00
|
|
|
|
2022-12-29 14:13:40 +01:00
|
|
|
services.nginx = {
|
|
|
|
virtualHosts."esphome.felschr.com" = {
|
|
|
|
enableACME = true;
|
|
|
|
forceSSL = true;
|
|
|
|
locations."/" = {
|
2022-12-29 14:22:30 +01:00
|
|
|
proxyPass = "http://localhost:${toString port}";
|
2022-12-29 14:13:40 +01:00
|
|
|
proxyWebsockets = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.esphome = {
|
|
|
|
description = "ESPHome";
|
|
|
|
after = [ "network.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
2022-12-29 16:25:53 +01:00
|
|
|
serviceConfig.LoadCredential = [ "password:${passwordFile}" ];
|
|
|
|
script = ''
|
|
|
|
password="$(<"$CREDENTIALS_DIRECTORY/password")"
|
|
|
|
${pkgs.esphome}/bin/esphome dashboard ${configDir}/esphome --password "$password"
|
|
|
|
'';
|
2022-12-29 14:13:40 +01:00
|
|
|
};
|
|
|
|
}
|