# modules/home/git.nix — git, from the flake (was ~/.gitconfig written by the
# bootstrap script plus the dotfiles' .config/git, which is not linked).
#
# Identity: name, email and signing key come from modules/hosts/laptop/_identity.nix;
# every commit and tag is signed with the GPG main key (modules/home/gpg.nix).
# Credentials for https remotes come from gh / glab; clones use ssh anyway.
# delta paints diffs (Rosé Pine, from the dotfiles' git config).
{ ... }:
{
flake.homeModules.git =
{ identity, ... }:
{
programs.git = {
enable = true;
signing = {
key = identity.gpgFingerprint;
format = "openpgp";
signByDefault = true; # commit.gpgSign and tag.gpgSign
};
settings = {
user = {
inherit (identity) name email;
};
alias = {
co = "checkout";
br = "branch";
ci = "commit";
st = "status";
lg = "log --oneline --graph --decorate -20";
};
init.defaultBranch = "main";
pull.rebase = true;
push.autoSetupRemote = true;
diff = {
algorithm = "histogram";
colorMoved = "default";
mnemonicPrefix = true;
};
commit.verbose = true;
column.ui = "auto";
branch.sort = "-committerdate";
tag.sort = "-version:refname";
rerere = {
enabled = true;
autoupdate = true;
};
merge.conflictstyle = "zdiff3";
core = {
autocrlf = "input";
safecrlf = "warn";
};
credential = {
"https://github.com".helper = "!gh auth git-credential";
"https://gist.github.com".helper = "!gh auth git-credential";
"https://gitlab.com".helper = "!glab auth git-credential";
};
};
};
programs.delta = {
enable = true;
enableGitIntegration = true;
options = {
navigate = true;
light = false;
line-numbers = true;
side-by-side = false;
hyperlinks = true;
syntax-theme = "none";
minus-style = "\"#eb6f92\" \"#26233a\"";
minus-emph-style = "bold \"#eb6f92\" \"#403d52\"";
plus-style = "\"#9ccfd8\" \"#26233a\"";
plus-emph-style = "bold \"#31748f\" \"#403d52\"";
line-numbers-minus-style = "\"#eb6f92\"";
line-numbers-plus-style = "\"#31748f\"";
line-numbers-zero-style = "\"#6e6a86\"";
file-style = "\"#31748f\" bold";
file-decoration-style = "\"#c4a7e7\" ul";
hunk-header-style = "\"#eb6f92\" bold";
hunk-header-decoration-style = "\"#6e6a86\" box";
};
};
}
;
}