{ config, pkgs, ... }:

{
  # https://nixos.wiki/wiki/Docker#Installation

  # TODO: rootless Docker. https://nixos.wiki/wiki/Docker#Rootless_docker
  # TODO: run as systemd services. https://nixos.wiki/wiki/Docker#docker_containers_as_systemd_services

  virtualisation = {
    docker = {
      enable = true;

      # As we use btrfs, we enable the according storageDriver option.
      storageDriver = "btrfs";

      # Run `docker system prune -f` every week.
      autoPrune.enable = true;
      autoPrune.dates = "weekly";
      # https://docs.docker.com/engine/reference/commandline/system_prune/#options
      autoPrune.flags = [
        "--all"
        "--volumes"
        # https://docs.docker.com/engine/reference/commandline/system_prune/#filter
        # https://pkg.go.dev/maze.io/x/duration#ParseDuration
        "--filter until=7d"
      ];
    };
  };
}
