Home

infra @main - refs - log -
-
https://git.jolheiser.com/infra.git
My NixOS infrastructure
tree log patch
gunpowder: pull HA and restart nightly Signed-off-by: jolheiser <git@jolheiser.com>
Signature
-----BEGIN SSH SIGNATURE----- U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgBTEvCQk6VqUAdN2RuH6bj1dNkY oOpbPWj+jw4ua1B1cAAAADZ2l0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5 AAAAQOiymMEO6oaDCK1pbt+r5J5bv7z9qSg5mKIxPmX7Gf6dGc5RsPLgGNPVQlSKgnYXDS XJSxVMVpHmKK64iQX+rAE= -----END SSH SIGNATURE-----
jolheiser <git@jolheiser.com>
1 week ago
1 changed files, 30 additions(+), 2 deletions(-)
jasmine/services/homeassistant.nix
M jasmine/services/homeassistant.nix -> jasmine/services/homeassistant.nix
 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
51
52
53
54
diff --git a/jasmine/services/homeassistant.nix b/jasmine/services/homeassistant.nix
index eaf9461fd3b11bf30e511f366c474728bcd68e11..e2ea5c372169f2100ef0e8111d8588dfd4ce9a30 100644
--- a/jasmine/services/homeassistant.nix
+++ b/jasmine/services/homeassistant.nix
@@ -1,6 +1,8 @@
-{ lib, ... }:
+{ lib, pkgs, ... }:
 let
   enable = true;
+  version = "2026.9";
+  image = "ghcr.io/home-assistant/home-assistant:${version}";
 in
 lib.mkIf enable {
   virtualisation.oci-containers = {
@@ -8,7 +10,7 @@     backend = "podman";
     containers.homeassistant = {
       volumes = [ "home-assistant:/config" ];
       environment.TZ = "America/Chicago";
-      image = "ghcr.io/home-assistant/home-assistant:stable";
+      inherit image;
       extraOptions = [
         "--network=host"
         "--device=/dev/ttyUSB0:/dev/ttyUSB0"
@@ -19,4 +21,30 @@   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;
+      };
+    };
+  };
 }