# Claude Code, configured declaratively via home-manager. Wanted on every host.
#
# The STATIC config is managed here: the global CLAUDE.md (persona/context), the
# custom output style, and the auto-memory directory. settings.json is
# deliberately left UNMANAGED -- Claude Code rewrites it at runtime (interactive
# permission grants, /config), and a read-only /nix/store symlink would break
# those writes.
#
# Memory is the source of truth in this repo (./claude/memory). It is symlinked
# read-only into ~/.claude/memory, so the runtime "save a memory" path no longer
# writes there -- recall still works, but new/changed memories must be added to
# this repo and rebuilt. CLAUDE.md instructs Claude to do exactly that.
{ ... }:
{
  programs.claude-code = {
    enable = true;
    # package defaults to pkgs.claude-code (tracked to unstable via the flake
    # overlay); installs the CLI on every host.

    # ~/.claude/CLAUDE.md -- global instructions / persona / memory workflow.
    context = ./claude/CLAUDE.md;
  };

  home.file = {
    # Custom output style. The module has no option for output-styles/, so place
    # it directly; selection (settings.json `outputStyle`) stays mutable.
    ".claude/output-styles/soviet-engineer.md".source = ./claude/output-styles/soviet-engineer.md;

    # Auto-memory directory, Nix-managed (read-only). Edit ./claude/memory in
    # this repo and rebuild to change what Claude remembers.
    ".claude/memory".source = ./claude/memory;
  };
}
