about summary refs log tree commit diff stats
path: root/modules/by-name/gi/git/module.nix
blob: 8e413e8a6db333a79c54f8017357e866475181a1 (plain) (blame)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
{
  lib,
  config,
  ...
}: let
  cfg = config.soispha.programs.git;

  gitIgnoreFile = ./git_ignore.git;
  gitTemplateFile = ./git_template.git;
in {
  options.soispha.programs.git = {
    enable = lib.mkEnableOption "an opinionated git config";
    defaultBranchName = lib.mkOption {
      type = lib.types.str;
      description = "The Name of the default branch.";
      default = "prime";
    };
  };

  config = lib.mkIf cfg.enable {
    home-manager.users.soispha = {
      programs.git = {
        enable = true;
        #package = pkgs.gitAndTools.gitFull; # TODO: for git send-email support
        aliases = import ./aliases.nix {
          inherit lib;
          inherit (cfg) defaultBranchName;
        };
        extraConfig = {
          core = {
            excludesFile = "${gitIgnoreFile}";
          };
          rebase = {
            autoStash = true;
            autoSquash = true;
          };
          init = {
            defaultBranch = cfg.defaultBranchName;
          };
          user = {
            name = "Benedikt Peetz";
            email = "benedikt.peetz@b-peetz.de";
            # signingKey = "[is down below]";
          };
          help = {
            autocorrect = 5;
          };
          push = {
            gpgSign = "if-asked";
          };
          commit = {
            template = "${gitTemplateFile}";
          };
          diff = {
            colorMoved = "default";
            # Usually leads to better results
            algorithm = "patience";
            bin = {
              textconv = "hexdump -v -C";
            };
          };
          # Makes it a bit more readable
          blame = {
            coloring = "repeatedLines";
            markIgnoredLines = true;
            markUnblamables = true;
          };
          merge = {
            conflictstyle = "zdiff3";
          };
          url = {
            "git@codeberg.org:" = {
              insteadOf = "@cb:";
            };
            "https://codeberg.org/" = {
              insteadOf = "cb://";
            };

            "git@github.com:" = {
              insteadOf = "@gh:";
            };
            "https://github.com/" = {
              insteadOf = "gh://";
            };

            "git@gitlab.com:" = {
              insteadOf = "@gl:";
            };
            "https://gitlab.com/" = {
              insteadOf = "gl://";
            };
          };
        };
        delta = {
          enable = true;
          options = {
            decorations = {
              commit-decoration-style = "bold yellow box ul";
              file-decoration-style = "none";
              file-style = "bold yellow ul";
            };
            keep-plus-minus-markers = true;
            features = "decorations";
            whitespace-error-style = "22 reverse";
          };
        };
        signing = {
          key = "8321ED3A8DB999A51F3BF80FF2682914EA42DE26";
          signByDefault = true;
        };
      };
    };
  };
}