{ pkgs, lib, config, ... }:
let
  cfg = config.mods.server.git;
  port = config.mods.server.nginx.ports.git;
in with lib; {
  options.mods.server = {
    git = {
      enable = mkEnableOption {
        default = false;
        description = "enables forgejo server";
      };
    };
  };

  config = mkIf cfg.enable {
    services.forgejo = {
      enable = true;
      lfs.enable = true;
      settings.server = {
        HTTP_ADDR = "0.0.0.0";
        HTTP_PORT = port;
        SSH_PORT = 22917;
        DOMAIN = "git.muon.host";
        ROOT_URL = "https://git.muon.host";
      };
    };
  };
}
