From e8b7b0c6b6e9269d2744fb135b09c8ecd4ba9cd3 Mon Sep 17 00:00:00 2001 From: "Thing-han, Lim" <15379156+potsrevennil@users.noreply.github.com> Date: Tue, 20 Oct 2026 14:20:17 +0800 Subject: [PATCH] refactor(git): include the agent config instead of replacing the global one Load users/home/git/agent.gitconfig through an env-provided include.path (GIT_CONFIG_COUNT/KEY/VALUE in ~/.claude/settings.json) instead of GIT_CONFIG_GLOBAL. The normal global config keeps loading, a missing file is skipped rather than dropping the whole global config and identity with it, and `git config --global` writes the normal config. That makes the Nix store copy at ~/.config/git-agent unnecessary, so the file stays in the version-controlled ~/.config/git folder symlink. Co-Authored-By: Claude Opus 5.5 --- users/home.nix | 2 -- users/home/git/agent.gitconfig | 17 +++++++---------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/users/home.nix b/users/home.nix index 810ffb1..fd63049 100644 --- a/users/home.nix +++ b/users/home.nix @@ -124,8 +124,6 @@ xdg.configFile = { "git".source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/git"; - # A store copy, not out-of-store: see the header of the file. - "git-agent/config".source = ./home/git/agent.gitconfig; "nvim".source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/kapi-vim"; } // pkgs.lib.optionalAttrs (! lite) { "wezterm".source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/wezterm"; diff --git a/users/home/git/agent.gitconfig b/users/home/git/agent.gitconfig index 8112873..ba8e3a0 100644 --- a/users/home/git/agent.gitconfig +++ b/users/home/git/agent.gitconfig @@ -1,15 +1,12 @@ -# Git config for AI agent sessions: everything from the normal config, with output trimmed -# for token cost. Claude Code selects it via GIT_CONFIG_GLOBAL in ~/.claude/settings.json; -# interactive shells never read it. +# Git config for AI agent sessions: output trimmed for token cost, layered over the normal +# config. Claude Code includes it from ~/.claude/settings.json: # -# home-manager links a Nix store copy to ~/.config/git-agent/config (users/home.nix), so it -# exists whatever branch the main checkout is on, and `git config --global` from an agent -# fails instead of editing this tracked file. Edits take effect after `make home`. +# "env": {"GIT_CONFIG_COUNT": "1", "GIT_CONFIG_KEY_0": "include.path", +# "GIT_CONFIG_VALUE_0": "~/.config/git/agent.gitconfig"} # -# GIT_CONFIG_GLOBAL replaces both global files, so include both (a missing one is skipped). -[include] - path = ~/.config/git/config - path = ~/.gitconfig +# An include, not GIT_CONFIG_GLOBAL: the normal global config still loads, a missing file +# (an older branch checked out) is skipped instead of dropping identity, and +# `git config --global` writes the normal config as usual. Interactive shells never read it. # Short status with the branch line, instead of the long form with hint paragraphs. [status]