aboutsummaryrefslogtreecommitdiffstats
path: root/modules/programs/git/default.nix
blob: cfba093f3590b8a9880343d0ee9166114a880e90 (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
{
  config,
  lib,
  pkgs,
  ...
}:

# Git - Distributed version control system
let
  passCfg = config.programs.pass;
  passGitHelper = lib.getExe pkgs.pass-git-helper;
in
{
  options.programs.git = {
    username = lib.mkOption {
      type = lib.types.str;
      description = "Git username.";
    };
    email = lib.mkOption {
      type = lib.types.str;
      description = "Git email.";
    };
  };

  config = lib.mkIf config.programs.git.enable {
    programs.git = {
      settings =
        lib.recursiveUpdate
          {
            user = {
              name = config.programs.git.username;
              email = config.programs.git.email;
            };
            core.askPass = "";
          }
          (
            lib.optionalAttrs passCfg.enable {
              credential."https://github.com" = {
                username = passCfg.github.username;
                helper = passGitHelper;
              };
            }
          );
    };
  };
}