aboutsummaryrefslogtreecommitdiff
path: root/modules/users/git/default.nix
blob: f1f555ed54eda260b54e0a44d174f0ea020bdc71 (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
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
{
  config,
  lib,
  ...
}:
let
  cfg = config.nx.git;
  inherit (lib) mkOption mkIf types;
in
{
  options.nx.git = {
    enable = mkOption {
      description = "Enable git";
      type = types.bool;
      default = false;
    };

    userName = mkOption {
      description = "Git username";
      type = types.str;
      default = "Leander Scherer";
    };

    userEmail = mkOption {
      description = "Git email";
      type = types.str;
      default = "leander@schererleander.de";
    };

    signKey = mkOption {
      description = "Sign key";
      type = types.nullOr types.str;
      default = "A3502B180BC1D41A";
    };

    signFlavor = mkOption {
      description = "Sign key flavor";
      type = types.enum [
        "ssh"
        "openpgp"
      ];
      default = "openpgp";
    };
  };

  config = mkIf cfg.enable {
    programs.git = {
      enable = true;

      signing = mkIf (cfg.signKey != null) {
        key = cfg.signKey;
        signByDefault = true;
      };

      ignores = [
        "*~"
        ".DS_Store"
        ".direnv"
        ".envrc"
      ];

      settings = {
        user.name = cfg.userName;
        user.email = cfg.userEmail;
        help.autocorrect = 20;
        alias = {
          st = "status";
          co = "checkout";
          br = "branch";
        };
        pull.rebase = true;
        gpg.format = cfg.signFlavor;
        url."git@github.com:".insteadOf = "https://github.com";
      };
    };
    programs.diff-highlight = {
      enable = true;
      enableGitIntegration = true;
    };
  };
}