iac/nixos/modules/podman.nix
Sergei Poljanski fa46d26f89
nixos: app stacks on Podman, unchanged
The apps keep deploying themselves: their CI copies a compose file and
a .env and runs docker compose as user deploy. `docker` is now the real
Docker CLI against rootful Podman's socket, so compose, inspect and
logs behave as before and every user sees the same containers.

Their compose files still expect the storage stack's network and the
hosts postgres and garage. On ops every container resolves those two
names to the host, where the native services run, and an empty storage
network exists, so nothing in the app repositories has to change for
the move itself.

Tried on the rehearsal pair with the real asxpio and datacenterbingo
images on the restored database and Garage (mail and IndexNow
disabled): both serve through Traefik, and a local compose build works.

One thing does need the app repositories: Podman ignores the
HEALTHCHECK of OCI-format images, which is what the CI builds, so the
deploy's wait for "healthy" would time out. Declaring the healthcheck
in each compose file fixes it, also under Docker; see MIGRATION.md.

ops-data.sh now also moves the monitoring history, Traefik's
certificates and the app directories, and pulls the images again.

Assisted-by: Claude:opus-5-5
2026-11-17 05:11:17 +04:00

31 lines
1.1 KiB
Nix

# Containers, for what has no native NixOS service: Podman, no Docker
# daemon. Declared containers (virtualisation.oci-containers) become
# systemd units named podman-<name>.service.
#
# The `docker` command is the real Docker CLI (with compose and buildx)
# talking to rootful Podman's Docker-compatible socket, so the apps' CI
# deploys (`docker compose up -d`, `docker inspect`, `docker logs`) work
# unchanged, and root, deploy and the admins all see the same containers.
{ pkgs, ... }:
{
virtualisation.podman = {
enable = true;
dockerSocket.enable = true; # /run/docker.sock -> /run/podman/podman.sock
defaultNetwork.settings.dns_enabled = true;
# Every image update and CI job leaves an image behind
autoPrune = {
enable = true;
dates = "Mon 03:00";
flags = [ "--all" ];
};
};
virtualisation.oci-containers.backend = "podman";
environment.systemPackages = [ pkgs.docker-client ];
# Podman's DNS for container networks, on each bridge's gateway
asxpio.security.ports = [
"tcp/53/aardvark-dns"
"udp/53/aardvark-dns"
];
environment.variables.DOCKER_HOST = "unix:///run/podman/podman.sock";
}