From 217c0a8e4ce15d1e5da8b96183733bd530453df3 Mon Sep 17 00:00:00 2001 From: Casey Link Date: Wed, 10 Apr 2024 15:41:33 +0200 Subject: [PATCH] feat: add virtualisation.user.quadlet.autoUpdate to home-manager module --- home-manager-module.nix | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/home-manager-module.nix b/home-manager-module.nix index b0355d5..af3ceee 100644 --- a/home-manager-module.nix +++ b/home-manager-module.nix @@ -18,6 +18,16 @@ let in { options.virtualisation.user.quadlet = { + autoUpdate = { + enable = lib.mkOption { + type = lib.types.bool; + default = false; + }; + calendar = lib.mkOption { + type = lib.types.str; + default = "*-*-* 00:00:00"; + }; + }; containers = lib.mkOption { type = lib.types.attrsOf containerOpts; default = { }; @@ -59,5 +69,32 @@ in }; }) allObjects ); + systemd.user.services.podman-auto-update = lib.mkIf cfg.autoUpdate.enable { + Unit = { + Description = "Podman auto-update service"; + Documentation = "man:podman-auto-update(1)"; + Wants = [ "network-online.target" ]; + After = [ "network-online.target" ]; + }; + Service = { + Type = "oneshot"; + Environment = "PATH=/run/wrappers/bin:/run/current-system/sw/bin"; + ExecStart = "${pkgs.podman}/bin/podman auto-update"; + ExecStartPost = "${pkgs.podman}/bin/podman image prune -f"; + TimeoutStartSec = "900s"; + TimeoutStopSec = "10s"; + }; + }; + systemd.user.timers.podman-auto-update = lib.mkIf cfg.autoUpdate.enable { + Unit = { + Description = "Podman auto-update timer"; + Documentation = "man:podman-auto-update(1)"; + }; + Timer = { + OnCalendar = cfg.autoUpdate.calendar; + Persistent = true; + }; + Install.WantedBy = [ "timers.target" ]; + }; }; }