home-manager/modules/services/podman-linux/services.nix
Nicholas Hassan 14bbb67c08
podman: add new module 'podman'
Adds a new Podman module for creating user containers and networks as
systemd services. These are installed to the user's XDG_CONFIG/systemd/user directory.
2024-05-12 22:30:17 +09:30

61 lines
1.5 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.podman;
in {
options.services.podman = {
auto-update = {
enable = mkOption {
type = types.bool;
default = false;
description = "Automatically update the podman images.";
};
OnCalendar = mkOption {
type = types.str;
default = "Sun *-*-* 00:00";
description = "Systemd OnCalendar expression for the update";
};
};
};
config = mkMerge [
( mkIf cfg.auto-update.enable {
systemd.user.services."podman-auto-update" = {
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:${config.home.homeDirectory}/.nix-profile/bin";
ExecStart = "${pkgs.podman}/bin/podman auto-update";
ExecStartPost = "${pkgs.podman}/bin/podman image prune -f";
TimeoutStartSec = "300s";
TimeoutStopSec = "10s";
};
};
systemd.user.timers."podman-auto-update" = {
Unit = {
Description = "Podman auto-update timer";
};
Timer = {
OnCalendar = cfg.auto-update.OnCalendar;
RandomizedDelaySec = 300;
Persistent = true;
};
Install = {
WantedBy = [ "timers.target" ];
};
};
})
];
}