{ config, pkgs, ... }:

let
  NODE_OPTIONS = "--max_old_space_size=8192";
in
{
  age.secrets.forgejo-runner-token-home-docker.file = ./forgejo-runner-token-home-docker.age;

  virtualisation.docker.enable = true;

  services.gitea-actions-runner = {
    package = pkgs.unstable.forgejo-runner;
    instances = {
      home-docker = {
        enable = true;
        name = "home-docker";
        url = "https://git.pleshevski.ru";
        labels = [
          "docker:docker://node:20-bullseye"
          "ubuntu-22.04:docker://node:20-bullseye"
        ];
        tokenFile = config.age.secrets.forgejo-runner-token-home-docker.path;
        settings = {
          runner = {
            envs = { inherit NODE_OPTIONS; };

            timeout = "1h";
          };
        };
      };
    };
  };
}