nix-config/modules/home-manager/git.nix

91 lines
2.2 KiB
Nix
Raw Normal View History

2024-03-24 17:39:49 -05:00
{
config,
pgks,
2024-03-24 22:56:01 -05:00
lib,
2024-03-24 17:39:49 -05:00
...
}: {
2024-03-24 22:56:01 -05:00
options = {
user.git = {
enable = lib.mkEnableOption "enable git";
2024-05-09 17:47:54 -05:00
workProfile = {
enable = lib.mkEnableOption "git work profile";
email = lib.mkOption {
type = lib.types.str;
description = "email for work profile.";
};
2024-05-09 17:47:54 -05:00
};
profile = {
email = lib.mkOption {
type = lib.types.str;
description = "email for main profile";
};
name = lib.mkOption {
type = lib.types.str;
description = "name for main profile";
};
2024-03-24 17:39:49 -05:00
};
2024-03-24 22:56:01 -05:00
};
};
config = lib.mkIf config.user.git.enable {
2024-03-24 22:56:01 -05:00
programs.git = {
enable = true;
aliases = {
tree = "log-long-line --graph --topo-order --all --simplify-by-decoration";
hist = "log-long-line --graph --date-order --date=short ";
graph = "log-long-line --graph --topo-order --all";
log-long-line = "log --pretty=format:'%C(auto)%h %C(cyan)%an %C(blue)%ar %C(auto)%d %s'";
2024-03-24 22:56:01 -05:00
recent = "branch --sort=-committerdate --format='%(committerdate:relative)%09%(refname:short)'";
2024-03-24 17:39:49 -05:00
};
2024-03-28 13:31:11 -05:00
delta = {
enable = true;
options = {
side-by-side = true;
line-numbers = true;
};
};
2024-03-24 22:56:01 -05:00
# difftastic.enable=true;
# difftastic.background="dark";
userEmail = config.user.git.profile.email;
userName = config.user.git.profile.name;
2024-03-24 22:56:01 -05:00
extraConfig = {
init = {
defaultBranch = "main";
};
push = {
autoSetupRemote = true;
default = "current";
};
pull = {
ff = true;
};
merge = {
conflictstyle = "zdiff3";
};
rebase = {
autosquash = true;
};
help = {
autocorrect = "prompt";
};
branch = {
sort = "-committerdate";
};
status = {
submodulesummary = true;
};
2024-03-24 17:39:49 -05:00
};
2024-03-24 22:56:01 -05:00
includes =
if config.user.git.workProfile.enable
2024-03-24 22:56:01 -05:00
then [
{
2024-03-28 12:19:32 -05:00
condition = "gitdir:~/work/**";
contents.user.email = config.user.git.workProfile.email;
2024-03-24 22:56:01 -05:00
}
]
else [];
2024-03-24 17:39:49 -05:00
};
2024-03-24 22:56:01 -05:00
programs.lazygit.enable = true;
2024-03-24 17:39:49 -05:00
};
}