{ config, lib, pkgs, ... }: let cfg = config.git; inherit (lib) mkEnableOption mkIf mkOption; types = lib.types; name = "Yadunand Prem"; email = "yadunand@yadunut.com"; in { options.git = { enable = mkEnableOption "Git"; gpgProgram = mkOption { default = null; type = types.nullOr types.str; }; signingKey = mkOption { type = types.nullOr types.str; default = null; }; }; config = mkIf cfg.enable { home.packages = with pkgs; [ git lazygit jujutsu delta ]; programs.zsh.shellAliases = { lg = "lazygit"; js = "jj status"; jd = "jj diff"; jn = "jj new"; jf = "jj git fetch"; jp = "jj git push"; }; programs.git = { ignores = [ ".DS_Store" ".direnv/" ".envrc" "**/.claude/settings.local.json" ]; enable = true; userEmail = email; userName = name; delta.enable = true; lfs.enable = true; extraConfig = lib.mkMerge [ { init.defaultBranch = "main"; pull.rebase = true; pull.autostash = true; rebase.autostash = true; rebase.autosquash = true; push.autoSetupRemote = true; commit.gpgsign = true; commit.verbose = true; # merge.conflictstyle = "zdiff2"; diff.colorMoved = true; diff.algorithm = "histogram"; feature.experimental = true; branch.sort = "committerdate"; diff.mnemonicPrefix = true; fetch.all = true; column.ui = "auto"; tags.sort = "version:refname"; push.followTags = true; rerere.enabled = true; rerere.autoupdate = true; rebase.updateRefs = true; credential.helper = [ "${pkgs.git-credential-oauth}/bin/git-credential-oauth" ]; gpg.format = "ssh"; credential = { "https://git.yadunut.dev" = { oauthClientId = "a4792ccc-144e-407e-86c9-5e7d8d9c3269"; oauthScopes = "read:repository write:repository"; oauthAuthURL = "/login/oauth/authorize"; oauthTokenURL = "/login/oauth/access_token"; }; }; } (mkIf (cfg.gpgProgram != null) { gpg.ssh.program = cfg.gpgProgram; }) (mkIf (cfg.signingKey != null) { user.signingkey = cfg.signingKey; }) ]; }; programs.jujutsu = { enable = true; settings = { user = { name = name; email = email; }; ui.default-command = "log"; }; }; programs.gh.enable = true; }; }