{ config, lib, ... }:

with lib;

let
  cfg = config.settings.applications.git;
in {
  options = {
    settings.applications.git.enable = lib.mkOption {
      type = lib.types.bool;
      description = ''
        Enable git version control
      '';
    };

    settings.applications.git.lazygit.enable = lib.mkOption {
      type = lib.types.bool;
      description = ''
        Enable lazygit
      '';
      default = true;
    };
  };

  config = mkIf cfg.enable {
    programs.lazygit =  {
      enable = true;
      settings = {
        services = {
          "gitea.xeovalyte.dev" = "gitea:gitea.xeovalyte.dev";
        };
      };
    };

    programs.git = mkIf cfg.lazygit.enable {
      enable = true;
      userEmail = "me+gitea@xeovalyte.dev";
      userName = "Timo Boomers";
      extraConfig = {
        commit.gpgsign = true;
        gpg.format = "ssh";
        user.signingkey = "~/.ssh/gitea.pub";
      };
    };
  };
}
