{ pkgs, lib, config, ... }: let cfg = config.py.programs.git; in { options.py.programs.git = { enable = lib.mkEnableOption "git configuration"; lazygit.enable = lib.mkEnableOption "lazygit configuration"; gh.enable = lib.mkEnableOption "gh configuration"; }; config = { catppuccin = { lazygit.enable = cfg.lazygit.enable; }; programs = { git = lib.mkIf cfg.enable { enable = true; package = pkgs.git; aliases = { a = "add -p"; co = "checkout"; cob = "checkout -b"; f = "fetch -p"; c = "commit"; p = "push"; ba = "branch -a"; bd = "branch -d"; bD = "branch -D"; d = "diff"; dc = "diff --cached"; ds = "diff --staged"; r = "restore"; rs = "restore --staged"; st = "status -sb"; # reset soft = "reset --soft"; hard = "reset --hard"; s1ft = "soft HEAD~1"; h1rd = "hard HEAD~1"; # logging lg = "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"; plog = "log --graph --pretty='format:%C(red)%d%C(reset) %C(yellow)%h%C(reset) %ar %C(green)%aN%C(reset) %s'"; tlog = "log --stat --since='1 Day Ago' --graph --pretty=oneline --abbrev-commit --date=relative"; rank = "shortlog -sn --no-merges"; # delete merged branches bdm = "!git branch --merged | grep -v '*' | xargs -n 1 git branch -d"; wt = "worktree"; }; delta = { enable = true; options.line-numbers = true; }; extraConfig = { branch.sort = "-committerdate"; column.ui = "auto"; core.editor = lib.getExe pkgs.py.nvim; "credential \"https://git.pyrox.dev\"".username = "pyrox"; credential.helper = "rbw"; diff = { algorithm = "histogram"; colorMoved = "plain"; mnemonicPrefix = true; renames = true; }; fetch = { all = true; prune = true; pruneTags = true; }; gpg.ssh.allowedSignersFile = "~/.ssh/authorized_signatures"; init.defaultBranch = "main"; pull.rebase = false; push = { autoSetupRemote = true; followTags = true; }; rebase.updateRefs = true; tag.sort = "version:refname"; }; lfs = { enable = true; skipSmudge = false; }; signing = { key = "~/.ssh/main.pub"; format = "ssh"; signByDefault = true; }; userEmail = "pyrox@pyrox.dev"; userName = "dish"; }; lazygit = lib.mkIf cfg.lazygit.enable { enable = true; settings = { gui = { nerdFontsVersion = "3"; showRandomTip = false; theme.selectedLineBgColor = [ "default" ]; }; git.paging = { pager = "${lib.getExe pkgs.delta} --dark --paging=never"; colorArg = "always"; }; services = { "git.pyrox.dev" = "gitea:git.pyrox.dev"; "git.dn42.dev" = "gitea:git.dn42.dev"; "codeberg.org" = "gitea:codeberg.org"; }; }; }; gh = lib.mkIf cfg.gh.enable { enable = true; gitCredentialHelper.enable = true; settings = { editor = lib.getExe pkgs.py.nvim; git_protocol = "https"; browser = lib.mkIf config.py.gui.enable pkgs.firefox; prompt = "enabled"; }; }; }; }; }