{
  config,
  lib,
  pkgs,
  ...
}:
let
  inherit (lib) mkIf;
  inherit (config.modules.meta) hostname;

  cfg = config.services.forgejo;
in
{
  config = mkIf cfg.enable {
    services.gitea-actions-runner = {
      package = pkgs.forgejo-runner;

      instances."${hostname}" = {
        enable = true;
        name = "${hostname}";
        tokenFile = config.age.secrets.forgejo-runner-token.path;
        url = "https://git.ccnlc.eu";

        labels = [
          "debian-latest:docker://node:18-bullseye"
          "ubuntu-latest:docker://node:18-bullseye"
        ];

        settings = {
          runner = {
            capacity = 2;
            timeout = "2h";

            shutdown_timeout = "5s";
          };

          cache.enabled = true;

          container = {
            force_pull = false;
            force_rebuild = false;
          };
        };
      };
    };

    virtualisation.docker.enable = true;
  };
}
