{ pkgs, common, ... }:

{
  home.packages = with pkgs; [
    git-crypt
    gitmoji-cli
  ];

  programs.git =
    let
      package = pkgs.git.override { withLibsecret = true; };
    in
    {
      enable = true;
      package = package;
      userName = "Martin Berg Alstad";
      userEmail = "git@${common.domain}";

      aliases = {
        amend = "commit --amend";
        cm = "commit";
        s = "status";
        p = "push";
      };

      signing.signByDefault = true;

      extraConfig = {
        init.defaultBranch = "main";
        advice.defaultBranchName = false;
        pull.rebase = true;
        push.autoSetupRemote = true;
        safe.directory = "/etc/nixos";
        credential.helper = "${package}/bin/git-credential-libsecret";
      };
    };
}
