{ lib, config, pkgs, ... }: let cfg = config.my.home.git; in { options.my.home.git = with lib; { enable = mkEnableOption "git configuration"; }; config = lib.mkIf cfg.enable { programs.git = { enable = true; aliases = { s = "status --short --branch"; amend = "commit --amend --no-edit"; review = "push origin HEAD:refs/for/main"; }; extraConfig = { core.whitespace = "trailing-space,space-before-tab"; color.ui = "true"; # abort if the remote branch does not match the local one push.default = "simple"; init.defaultBranch = "main"; pull.rebase = true; rebase = { # Automatically create a temporary stash entry before the # operation begins, and apply it after the operation ends. autoStash = true; # Print a warning if some commits are removed missingCommitsCheck = "warn"; }; branch.autosetuprebase = "remote"; branch.sort = "authordate"; commit.template = "${config.xdg.dataHome}/git/commit.template"; commit.gpgsign = true; gpg.format = "ssh"; user.signingkey = "~/.ssh/fcuny_id_ed25519.pub"; gpg.ssh.allowedSignersFile = "${config.xdg.dataHome}/git/allowed_signers"; }; userName = "Franck Cuny"; userEmail = "franck@fcuny.net"; extraConfig = { "credential \"https://github.com\"" = { username = "fcuny"; }; "credential \"https://git.fcuny.net\"" = { username = "fcuny"; }; }; ignores = [ "*.elc" "*.iml" "*.o" "*.pyc" "*.pyo" "*pyc" "*~" ".DS_Store" ".\\#" ".dir-locals.el" ".direnv/*" ".idea" ".projectile" ".pytest_cache/" "/env/*" "Icon" "TAGS" "\\#*\\#" "tags" ]; }; xdg.dataFile."git/commit.template" = { source = ./commit.template; }; home.packages = with pkgs; [ tools.git-blame-stats gitAndTools.pre-commit ]; }; }