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

{
	options.tools.git = {
		enable = lib.mkEnableOption "Enables git.";
		username = lib.mkOption {
			type = lib.types.str;
			description = "Github username.";
		};
		email = lib.mkOption {
			type = lib.types.str;
			description = "Github email.";
		};
	};

	config = lib.mkIf config.tools.git.enable {
		programs.git = {
			enable = true;
			settings = {
				user.name = config.tools.git.username;
				user.email = config.tools.git.email;
				credential.helper = "store --file ${config.xdg.cacheHome}/git/credential";
				core.askPass = "";
			};
		};

		# The base directory of the credential file must exist
		home.activation.createGitCacheDirectory
			= lib.hm.dag.entryAfter
				[ "writeBoundary" ]
				"mkdir -p ${config.xdg.cacheHome}/git";
	};
}