main
 1{
 2  flake.modules.homeManager.dev = {
 3    config,
 4    lib, # Use inner lib for home-manager's overlay
 5    ...
 6  }: {
 7    # `programs.git` will generate the config file: ~/.config/git/config
 8    # to make git use this config file, `~/.gitconfig` should not exist!
 9    #
10    #    https://git-scm.com/docs/git-config#Documentation/git-config.txt---global
11    home.activation.removeExistingGitconfig = lib.hm.dag.entryBefore ["checkLinkTargets"] ''
12      rm -f ${config.home.homeDirectory}/.gitconfig
13    '';
14
15    programs.git = {
16      enable = true;
17      lfs.enable = true;
18
19      signing = {
20        signByDefault = true;
21        format = "openpgp";
22      };
23
24      settings = {
25        user = {
26          name = "HPCesia";
27          email = "me@hpcesia.com";
28        };
29
30        init.defaultBranch = "main";
31        trim.bases = "develop,master,main"; # for git-trim
32        push.autoSetupRemote = true;
33        pull.rebase = true;
34
35        # replace https with ssh
36        url = {
37          "ssh://git@github.com/HPCesia" = {
38            insteadOf = "https://github.com/HPCesia";
39          };
40          "ssh://git@codeberg.org/HPCesia" = {
41            insteadOf = "https://codeberg.org/HPCesia";
42          };
43          "ssh://git@repo.hpcesia.com:2233/HPCesia" = {
44            insteadOf = "https://repo.hpcesia.com/HPCesia";
45          };
46        };
47      };
48    };
49
50    # A syntax-highlighting pager in Rust(2019 ~ Now)
51    programs.delta = {
52      enable = true;
53      enableGitIntegration = true;
54      options = {
55        diff-so-fancy = true;
56        line-numbers = true;
57        true-color = "always";
58      };
59    };
60  };
61}