From ed060a431a3e9af72a21854d5cd6089d96408747 Mon Sep 17 00:00:00 2001 From: Jake Hillion Date: Sat, 5 Dec 2026 20:14:24 +0000 Subject: [PATCH] claude: link ~/.claude.json straight to persistent storage Claude Code saves ~/.claude.json by writing a new file next to the target and renaming it over it, following a symlink only one level. The impermanence module persisted the file as a link to a home-manager store entry that links on to /data, so Claude Code tried to write into the read-only store and every save failed. The persisted file has not changed since it was created, so each session starts from stale state, including a cached model list that marks Fable as unavailable. Replaced the file persistence with an activation step that links ~/.claude.json directly to its file in persistent storage. One level of symlink leads Claude Code to write and rename within /data, and the existing file is kept. Test plan: - CI - Built maverick's toplevel: the activation links ~/.claude.json to /data/users/jake/.claude.json and home-manager no longer manages it --- modules/home/claude/default.nix | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/home/claude/default.nix b/modules/home/claude/default.nix index 26b2824b..fa25c4b9 100644 --- a/modules/home/claude/default.nix +++ b/modules/home/claude/default.nix @@ -40,7 +40,6 @@ in config = lib.mkIf cfg.enable { custom.impermanence = lib.mkIf config.custom.impermanence.enable { - userExtraFiles.${user} = [ ".claude.json" ]; userExtraDirs.${user} = [ ".claude" ]; }; @@ -63,9 +62,16 @@ in "claude-code/.claude/skills/megamerge-place/SKILL.md".source = ./megamerge-place-skill/SKILL.md; }; - home-manager.users.${user} = { + home-manager.users.${user} = { lib, ... }: { home.file.".claude/CLAUDE.md".source = ./global-instructions.md; + # Claude Code saves ~/.claude.json by renaming a new file over the target + # of a symlink it follows only once, so the link must point straight at + # persistent storage. + home.activation.claude-json = lib.mkIf config.custom.impermanence.enable (lib.hm.dag.entryAfter [ "linkGeneration" ] '' + run ${pkgs.coreutils}/bin/ln -sfn ${config.custom.impermanence.base}/users/${user}/.claude.json "$HOME/.claude.json" + ''); + # Disable zoxide cd hook inside Claude Code subshells to avoid cd breakage. # Claude Code sets CLAUDECODE=1 in all subprocesses it spawns (Bash tool, # hooks, MCP, etc.), so we check for that and strip the cd function back out -- 2.56.1