# Auto-generated using compose2nix v0.3.1.
{
  pkgs,
  lib,
  ...
}: {
  # Enable container name DNS for non-default Docker networks.
  # https://github.com/NixOS/nixpkgs/issues/226365
  networking.firewall.interfaces."docker+".allowedUDPPorts = [53];

  virtualisation.oci-containers.backend = "docker";

  # Containers
  virtualisation.oci-containers.containers."spaceclient-jank" = {
    image = "docker.io/compose2nix/spaceclient-jank";
    ports = [
      "9780:8080/tcp"
    ];
    log-driver = "journald";
    extraOptions = [
      "--network-alias=jank"
      "--network=spaceclient_default"
    ];
  };
  systemd.services."docker-spaceclient-jank" = {
    serviceConfig = {
      Restart = lib.mkOverride 90 "always";
    };
    after = [
      "docker-network-spaceclient_default.service"
    ];
    requires = [
      "docker-network-spaceclient_default.service"
    ];
    partOf = [
      "docker-compose-spaceclient-root.target"
    ];
    wantedBy = [
      "docker-compose-spaceclient-root.target"
    ];
  };

  # Networks
  systemd.services."docker-network-spaceclient_default" = {
    path = [pkgs.docker];
    serviceConfig = {
      Type = "oneshot";
      RemainAfterExit = true;
      ExecStop = "docker network rm -f spaceclient_default";
    };
    script = ''
      docker network inspect spaceclient_default || docker network create spaceclient_default
    '';
    partOf = ["docker-compose-spaceclient-root.target"];
    wantedBy = ["docker-compose-spaceclient-root.target"];
  };

  # Builds
  systemd.services."docker-build-spaceclient-jank" = {
    path = [pkgs.docker pkgs.git];
    serviceConfig = {
      Type = "oneshot";
      TimeoutSec = 300;
    };
    script = ''
      cd /home/mtgmonkey/spaceclient
      docker build -t compose2nix/spaceclient-jank .
    '';
  };

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