mirror of
https://github.com/nix-community/home-manager
synced 2024-11-23 11:39:46 +01:00
1743615b61
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.
65 lines
1.8 KiB
Nix
65 lines
1.8 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let cfg = config.services.podman;
|
|
in {
|
|
options.services.podman = {
|
|
autoUpdate = {
|
|
enable = mkOption {
|
|
type = types.bool;
|
|
default = false;
|
|
description = "Automatically update the podman images.";
|
|
};
|
|
|
|
onCalendar = mkOption {
|
|
type = types.str;
|
|
default = "Sun *-*-* 00:00";
|
|
description = ''
|
|
The systemd `OnCalendar` expression for the update. See
|
|
{manpage}`systemd.time(7)` for a description of the format.
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable (mkMerge [
|
|
(mkIf cfg.autoUpdate.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=${
|
|
builtins.concatStringsSep ":" [
|
|
"/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.autoUpdate.onCalendar;
|
|
RandomizedDelaySec = 300;
|
|
Persistent = true;
|
|
};
|
|
|
|
Install = { WantedBy = [ "timers.target" ]; };
|
|
};
|
|
})
|
|
]);
|
|
}
|