https://git.jolheiser.com/infra.git
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
{ lib, pkgs, ... }: let enable = true; version = "2026.9"; image = "ghcr.io/home-assistant/home-assistant:${version}"; in lib.mkIf enable { virtualisation.oci-containers = { backend = "podman"; containers.homeassistant = { volumes = [ "home-assistant:/config" ]; environment.TZ = "America/Chicago"; inherit image; extraOptions = [ "--network=host" "--device=/dev/ttyUSB0:/dev/ttyUSB0" ]; }; }; networking.firewall.allowedTCPPorts = [ 4001 8123 ]; systemd = { services.homeassistant-update = { description = "Pull homeassistant image and restart the container if it changed"; after = [ "network-online.target" ]; wants = [ "network-online.target" ]; serviceConfig.Type = "oneshot"; script = '' old=$(${pkgs.podman}/bin/podman image inspect --format '{{.Id}}' ${image} 2>/dev/null || true) ${pkgs.podman}/bin/podman pull ${image} new=$(${pkgs.podman}/bin/podman image inspect --format '{{.Id}}' ${image}) if [ "$old" != "$new" ]; then systemctl restart podman-homeassistant.service fi ''; }; timers.homeassistant-update = { description = "Nightly homeassistant image pull"; wantedBy = [ "timers.target" ]; timerConfig = { OnCalendar = "*-*-* 00:00:00"; Persistent = true; }; }; }; }