From d1250e63eb734b56cba9102f40a67f9e061d84bd Mon Sep 17 00:00:00 2001 From: Jake Hillion Date: Sat, 5 Dec 2026 18:46:34 +0000 Subject: [PATCH] claude: deploy settings and skills as managed policy in /etc Claude Code's user settings were a home-manager symlink into the Nix store, so anything Claude Code saved there, such as a default model or a /config toggle, was lost when the process exited. Moved the declared settings to /etc/claude-code/managed-settings.json and the skills to /etc/claude-code/.claude/skills, Claude Code's managed locations on Linux. Managed settings and skills take precedence over the user's own, so attribution, the Bash hook, the retry environment and the plugin stay enforced, while ~/.claude/settings.json becomes a real file in the persisted ~/.claude that Claude Code can write. Auto mode is also made the default permission mode, since choosing it with Shift+Tab lasts only for the session. Test plan: - CI - Built maverick's toplevel: /etc/claude-code holds managed-settings.json with the declared keys and the five skills --- modules/home/claude/default.nix | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/modules/home/claude/default.nix b/modules/home/claude/default.nix index e7b83ef8..eb0a7f49 100644 --- a/modules/home/claude/default.nix +++ b/modules/home/claude/default.nix @@ -5,6 +5,7 @@ let claudeSettings = { remoteControlAtStartup = false; + permissions.defaultMode = "auto"; attribution = { commit = ""; pr = ""; @@ -57,19 +58,20 @@ in mode = "0400"; }; + # Managed settings and skills take precedence over the user's own, which + # leaves ~/.claude/settings.json for Claude Code to save its choices in. + environment.etc = { + "claude-code/managed-settings.json".text = builtins.toJSON claudeSettings; + "claude-code/.claude/skills/commit/SKILL.md".source = ./commit-skill/SKILL.md; + "claude-code/.claude/skills/github-fetch/SKILL.md".source = ./github-fetch-skill/SKILL.md; + "claude-code/.claude/skills/megamerge/SKILL.md".source = ./megamerge-skill/SKILL.md; + "claude-code/.claude/skills/megamerge-sync/SKILL.md".source = ./megamerge-sync-skill/SKILL.md; + "claude-code/.claude/skills/megamerge-place/SKILL.md".source = ./megamerge-place-skill/SKILL.md; + }; + home-manager.users.${user} = { home.file.".claude/CLAUDE.md".source = ./global-instructions.md; - # Deploy skills - home.file.".claude/skills/commit/SKILL.md".source = ./commit-skill/SKILL.md; - home.file.".claude/skills/github-fetch/SKILL.md".source = ./github-fetch-skill/SKILL.md; - home.file.".claude/skills/megamerge/SKILL.md".source = ./megamerge-skill/SKILL.md; - home.file.".claude/skills/megamerge-sync/SKILL.md".source = ./megamerge-sync-skill/SKILL.md; - home.file.".claude/skills/megamerge-place/SKILL.md".source = ./megamerge-place-skill/SKILL.md; - - # Deploy settings with hooks configuration - home.file.".claude/settings.json".text = builtins.toJSON claudeSettings; - # Merge Context7 MCP server into ~/.claude.json at activation time home.activation.claude-mcp-servers = '' apiKey=$(${pkgs.coreutils}/bin/cat ${lib.escapeShellArg config.age.secrets."claude/context7-api-key".path}) -- 2.56.1