summaryrefslogtreecommitdiff
path: root/shared/home-manager/git/default.nix
blob: 748025d1abb0613e2ff80da5648b44ac7c04550b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
{
  pkgs,
  lib,
  ...
}: let
  inherit (lib) optional;
  inherit (pkgs.stdenv.hostPlatform) isDarwin;
in {
  imports = [
    ./ignore.nix
    ./aliases.nix
  ];

  programs.git = {
    enable = true;

    # Set privacy-respecting user information.
    userName = "Linnnus";
    userEmail = "[email protected]";

    extraConfig = {
      init.defaultBranch = "master";

      help.autoCorrect = "prompt";

      # Make sure we don't accidentally update submodules with changes that are only available locally.
      # See: https://git-scm.com/book/en/v2/Git-Tools-Submodules
      push.recurseSubmodules = "check";

      # It seems like a de facto standard to have a file with this name in the
      # project root containing all the commits that should be ignored when
      # running `git blame`.
      blame.ignoreRevsFile = ".git-blame-ignore-revs";

      credential = {
        "https://github.com/" = {
          username = "linnnus";
          helper = "${pkgs.gh}/bin/gh auth git-credential";
        };
        helper = (optional isDarwin "osxkeychain") ++ ["cache"];
      };
    };
  };

  home.packages = with pkgs; [
    # Add the GitHub CLI for authentication.
    gh
  ];
}