# Auto-generated by compose2nix.

{ pkgs, lib, ... }:

{
  # Runtime
  virtualisation.docker = {
    enable = true;
    autoPrune.enable = true;
  };
  virtualisation.oci-containers.backend = "docker";

  # Containers
  virtualisation.oci-containers.containers."gitwatch-LillyOS" = {
    image = "ghcr.io/gitwatch/gitwatch:latest";
    environment = {
      "COMMIT_MSG" = "Auto-commit: %d";
      "COMMIT_ON_START" = "false";
      "DATE_FMT" = "+%Y-%m-%d %H:%M:%S";
      "EXCLUDE_PATTERN" = "";
      "GIT_BRANCH" = "main";
      "GIT_REMOTE" = "origin";
      "GIT_WATCH_DIR" = "/home/lilly/LillyOS";
      "PULL_BEFORE_PUSH" = "true";
      "SKIP_IF_MERGING" = "false";
      "SLEEP_TIME" = "2";
      "VERBOSE" = "false";
    };
    volumes = [
      "/home/lilly/.config/git/config:/root/.gitconfig:ro"
      "/home/lilly/.ssh/known_hosts:/root/.ssh/known_hosts"
      "/home/lilly/.ssh/id_ed25519:/root/.ssh/id_ed25519:ro"
      "/home/lilly/LillyOS:/home/lilly/LillyOS:rw"
    ];
    log-driver = "journald";
    extraOptions = [
      "--network-alias=gitwatch-LillyOS"
      "--network=gitwatch_default"
    ];
  };
  systemd.services."docker-gitwatch-LillyOS" = {
    serviceConfig = {
      Restart = lib.mkOverride 90 "always";
      RestartMaxDelaySec = lib.mkOverride 90 "1m";
      RestartSec = lib.mkOverride 90 "100ms";
      RestartSteps = lib.mkOverride 90 9;
    };
    after = [
      "docker-network-gitwatch_default.service"
    ];
    requires = [
      "docker-network-gitwatch_default.service"
    ];
    partOf = [
      "docker-compose-gitwatch-root.target"
    ];
    wantedBy = [
      "docker-compose-gitwatch-root.target"
    ];
  };

  virtualisation.oci-containers.containers."gitwatch-lilly-config" = {
    image = "ghcr.io/gitwatch/gitwatch:latest";
    environment = {
      "COMMIT_MSG" = "Auto-commit: %d";
      "COMMIT_ON_START" = "false";
      "DATE_FMT" = "+%Y-%m-%d %H:%M:%S";
      "EXCLUDE_PATTERN" = "vesktop/sessionData/*, Code/User/History/*";
      "GIT_BRANCH" = "main";
      "GIT_REMOTE" = "origin";
      "GIT_WATCH_DIR" = "/home/lilly/.config";
      "PULL_BEFORE_PUSH" = "true";
      "SKIP_IF_MERGING" = "false";
      "SLEEP_TIME" = "60";
      "VERBOSE" = "false";
    };
    volumes = [
      "/home/lilly/.config/git/config:/root/.gitconfig:ro"
      "/home/lilly/.ssh/known_hosts:/root/.ssh/known_hosts"
      "/home/lilly/.ssh/id_ed25519:/root/.ssh/id_ed25519:ro"
      "/home/lilly/.config:/home/lilly/.config:rw"
    ];
    log-driver = "journald";
    extraOptions = [
      "--network-alias=gitwatch-lilly-config"
      "--network=gitwatch_default"
    ];
  };
  systemd.services."docker-gitwatch-lilly-config" = {
    serviceConfig = {
      Restart = lib.mkOverride 90 "always";
      RestartMaxDelaySec = lib.mkOverride 90 "1m";
      RestartSec = lib.mkOverride 90 "100ms";
      RestartSteps = lib.mkOverride 90 9;
    };
    after = [
      "docker-network-gitwatch_default.service"
    ];
    requires = [
      "docker-network-gitwatch_default.service"
    ];
    partOf = [
      "docker-compose-gitwatch-root.target"
    ];
    wantedBy = [
      "docker-compose-gitwatch-root.target"
    ];
  };

  # Networks
  systemd.services."docker-network-gitwatch_default" = {
    path = [ pkgs.docker ];
    serviceConfig = {
      Type = "oneshot";
      RemainAfterExit = true;
      ExecStop = "docker network rm -f gitwatch_default";
    };
    script = ''
      docker network inspect gitwatch_default || docker network create gitwatch_default
    '';
    partOf = [ "docker-compose-gitwatch-root.target" ];
    wantedBy = [ "docker-compose-gitwatch-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."docker-compose-gitwatch-root" = {
    unitConfig = {
      Description = "Root target generated by compose2nix.";
    };
    wantedBy = [ "multi-user.target" ];
  };
}