From 1060339a93a4917cc684473f4d54d854e1adc0de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kier=C3=A1n=20Meinhardt?= Date: Fri, 19 Dec 2025 11:56:02 +0100 Subject: [PATCH] home-assistant: auto-update container --- systems/zaatar/home-assistant.nix | 34 +++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/systems/zaatar/home-assistant.nix b/systems/zaatar/home-assistant.nix index 74879f1..980125d 100644 --- a/systems/zaatar/home-assistant.nix +++ b/systems/zaatar/home-assistant.nix @@ -74,6 +74,40 @@ in { hardware.bluetooth.enable = true; + systemd.services.update-containers = { + startAt = "Mon 02:00"; + script = '' + images=$(${pkgs.podman}/bin/podman ps -a --format="{{.Image}}" | sort -u) + + for image in $images; do + ${pkgs.podman}/bin/podman pull "$image" + done + ''; + serviceConfig = { + Type = "oneshot"; + Restart = "on-failure"; + RestartSec = "1h"; + }; + }; + + systemd.services.restart-homeassistant = { + startAt = "Tue 02:00"; + script = '' + ${pkgs.systemd}/bin/systemctl try-restart podman-homeassistant.service + ''; + serviceConfig = { + Type = "oneshot"; + }; + }; + + virtualisation.podman = { + enable = true; + autoPrune = { + enable = true; + flags = ["--all"]; + }; + }; + virtualisation.oci-containers = { backend = "podman"; containers.homeassistant = {