{
  path,
  lib,
  pkgs,
  config,
  ...
}: {
  age.secrets."fumoposting.env" = {
    file = path + /secrets/fumoposting-env.age;
    mode = "0640";
    owner = "minecraft";
    group = "minecraft";
  };
  # Containers
  virtualisation.oci-containers.containers."fumoposting_minecraft_production" = {
    image = "itzg/minecraft-server";
    environmentFiles = [
      "${config.age.secrets.fumoposting-env.path}"
    ];
    volumes = [
      "/var/lib/minecraft/fumoposting_production/data:/data:rw"
      "/var/lib/minecraft/server/patches/fumoposting:/data/patches:ro"
      "/var/lib/minecraft/server/whitelist.json:/data/whitelist.json:ro"
    ];
    ports = [
      "25565:25565/tcp"
      "25565:25565/udp"
      "35610:25575/tcp"
    ];
    dependsOn = [
      "fumoposting_mongodb_production"
    ];
    log-driver = "journald";
    extraOptions = [
      "--health-cmd='mc-health'"
      "--health-interval=5s"
      "--health-retries=5"
      "--health-start-period=1m0s"
      "--network-alias=minecraft"
      "--network=fumoposting-mc"
      "--network=fumoposting-mongodb"
    ];
  };
  systemd.services."podman-fumoposting_minecraft_production" = {
    serviceConfig = {
      Restart = lib.mkOverride 500 "always";
    };
    after = [
      "podman-network-fumoposting-mc.service"
      "podman-network-fumoposting-mongodb.service"
    ];
    requires = [
      "podman-network-fumoposting-mc.service"
      "podman-network-fumoposting-mongodb.service"
    ];
    partOf = [
      "podman-compose-fumoposting-root.target"
    ];
    unitConfig.UpheldBy = [
      "podman-fumoposting_mongodb_production.service"
    ];
    wantedBy = [
      "podman-compose-fumoposting-root.target"
    ];
  };
  virtualisation.oci-containers.containers."fumoposting_mongodb_production" = {
    image = "mongo";
    environmentFiles = [
      "${config.age.secrets.fumoposting-env.path}"
    ];
    volumes = [
      "/var/lib/minecraft/fumoposting_production/db:/data/db:rw"
    ];
    ports = [
      "127.0.0.1:47017:27017/tcp"
    ];
    cmd = ["--logpath" "/var/log/mongodb/mongod.log"];
    log-driver = "journald";
    extraOptions = [
      "--health-cmd='[\"mongosh\",\"--eval\",\"db.adminCommand('ping')\"]'"
      "--health-interval=15s"
      "--health-retries=5"
      "--health-start-period=3s"
      "--health-timeout=3s"
      "--network-alias=mongodb"
      "--network=fumoposting-mongodb"
    ];
  };
  systemd.services."podman-fumoposting_mongodb_production" = {
    serviceConfig = {
      Restart = lib.mkOverride 500 "always";
    };
    after = [
      "podman-network-fumoposting-mongodb.service"
    ];
    requires = [
      "podman-network-fumoposting-mongodb.service"
    ];
    partOf = [
      "podman-compose-fumoposting-root.target"
    ];
    wantedBy = [
      "podman-compose-fumoposting-root.target"
    ];
  };

  # Networks
  systemd.services."podman-network-fumoposting-mc" = {
    path = [pkgs.podman];
    serviceConfig = {
      Type = "oneshot";
      RemainAfterExit = true;
      ExecStop = "${pkgs.podman}/bin/podman network rm -f fumoposting-mc";
    };
    script = ''
      podman network inspect fumoposting-mc || podman network create fumoposting-mc --opt isolate=true
    '';
    partOf = ["podman-compose-fumoposting-root.target"];
    wantedBy = ["podman-compose-fumoposting-root.target"];
  };
  systemd.services."podman-network-fumoposting-mongodb" = {
    path = [pkgs.podman];
    serviceConfig = {
      Type = "oneshot";
      RemainAfterExit = true;
      ExecStop = "${pkgs.podman}/bin/podman network rm -f fumoposting-mongodb";
    };
    script = ''
      podman network inspect fumoposting-mongodb || podman network create fumoposting-mongodb --opt isolate=true
    '';
    partOf = ["podman-compose-fumoposting-root.target"];
    wantedBy = ["podman-compose-fumoposting-root.target"];
  };

  # Root service
  # When started, this will automatically create all resources and start
  # the containers. When stopped, this will teardown all resources.
  systemd.targets."podman-compose-fumoposting-root" = {
    unitConfig = {
      Description = "Root target generated by compose2nix.";
    };
    wantedBy = ["multi-user.target"];
  };
}
