37 lines
837 B
Nix
Executable File
37 lines
837 B
Nix
Executable File
{
|
|
config,
|
|
lib,
|
|
namespace,
|
|
...
|
|
}:
|
|
with lib;
|
|
let
|
|
cfg = config.${namespace}.services.home-assistant;
|
|
in
|
|
{
|
|
config = mkIf cfg.enable {
|
|
virtualisation.oci-containers.containers.esphome = {
|
|
autoStart = true;
|
|
image = "ghcr.io/esphome/esphome";
|
|
ports = [ "6052:6052" ];
|
|
devices = [
|
|
"/dev/ttyUSB0"
|
|
];
|
|
privileged = true;
|
|
volumes = [
|
|
"/esphome:/config"
|
|
# Persist the PlatformIO core dir (penv, packages, platforms) so the
|
|
# pioarduino penv_setup.py dependency install only runs once rather
|
|
# than on every container restart.
|
|
"/esphome/.platformio:/root/.platformio"
|
|
];
|
|
environment = {
|
|
TZ = "America/Chicago";
|
|
};
|
|
};
|
|
|
|
# Open the ESPHome dashboard port
|
|
networking.firewall.allowedTCPPorts = [ 6052 ];
|
|
};
|
|
}
|