All checks were successful
nixos / nixos (push) Successful in 40s
Its stop step is `podman stop --all`. A deploy that changes the unit, such as a Podman update, would restart it and so stop XMPP, running CI jobs and every app, only to start them again. It does its work at boot; leave it alone on a switch. Assisted-by: Claude:opus-5-5
55 lines
2.3 KiB
Nix
55 lines
2.3 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";
|
|
|
|
# Containers started outside systemd (compose stacks, `docker run`) come
|
|
# back after a reboot only through this unit, which Podman ships but
|
|
# does not enable: the Docker daemon used to do it. It starts every
|
|
# container whose restart policy says so (always, unless-stopped).
|
|
systemd.services.podman-restart = {
|
|
wantedBy = [ "multi-user.target" ];
|
|
after = [ "network-online.target" ];
|
|
wants = [ "network-online.target" ];
|
|
# Its stop step stops every container: a deploy that changes the unit
|
|
# (a Podman update) must not take XMPP, CI jobs and the apps down.
|
|
# It only matters at boot.
|
|
restartIfChanged = false;
|
|
};
|
|
|
|
environment.systemPackages = [ pkgs.docker-client ];
|
|
# `podman` talks to the same system Podman too, for every admin without
|
|
# sudo (they are in group podman, which owns the socket); otherwise it
|
|
# would show each user's own, empty rootless store
|
|
environment.variables.CONTAINER_HOST = "unix:///run/podman/podman.sock";
|
|
# Podman's DNS for container networks, on each bridge's gateway. The
|
|
# NixOS module opens it on podman0 only; CI jobs and compose stacks get
|
|
# networks of their own (podman1, podman2, ...).
|
|
networking.firewall.interfaces."podman*" = {
|
|
allowedUDPPorts = [ 53 ];
|
|
allowedTCPPorts = [ 53 ];
|
|
};
|
|
asxpio.security.ports = [
|
|
"tcp/53/aardvark-dns"
|
|
"udp/53/aardvark-dns"
|
|
];
|
|
environment.variables.DOCKER_HOST = "unix:///run/podman/podman.sock";
|
|
}
|