My updated podman.nix
is below.
{config, pkgs, lib, ...}:
{
# Enable container support
virtualisation = {
podman = {
enable = true; # Needed to populate /run/user/1000/podman/podman.sock
};
};
# Set graphDriverName to btrfs
virtualisation.containers.storage.settings = {
storage = {
driver = "btrfs";
graphroot = "/var/lib/containers/storage";
runroot = "/run/containers/storage";
};
};
# add podman and podman-compose
environment.systemPackages = with pkgs; [ podman-compose slirp4netns fuse-overlayfs ];
# Allow non-root containers to access lower port numbers
boot.kernel.sysctl."net.ipv4.ip_unprivileged_port_start" = 80;
# Enable lingering so containers persist after ssh exit
users.users.<user-name>.linger = true;
# Automatically start containers on boot
systemd.services.podman-autostart = {
enable = true;
after = [ "podman.service" ];
wantedBy = [ "multi-user.target" ];
description = "Automatically start containers with --restart=always tag";
serviceConfig = {
Type = "idle";
User = "<user-name>";
ExecStartPre = ''${pkgs.coreutils}/bin/sleep 1'';
ExecStart = ''/run/current-system/sw/bin/podman start --all --filter restart-policy=always'';
};
};
}