diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 0a5d2560..7f9e5e1e 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -3,6 +3,15 @@ # (first start, or a fresh/reset devhome volume) or when the image carries a # newer generation than the one the volume was activated with. +# home-manager's activate script records its profile under +# $XDG_STATE_HOME/nix/profiles only when that directory already exists; it +# otherwise falls back to /nix/var/nix/profiles/per-user/root. /nix is baked +# into the image, not a volume, so the fallback link is gone on every --rm and +# CURRENT never matched BAKED: activation re-ran on every single start, and any +# in-container `home-manager switch` was silently reverted by the next start. +# Creating the state dir first makes the profile land in the devhome volume, +# which is the path probed below. +mkdir -p /root/.local/state/nix/profiles CURRENT=$(readlink -f /root/.local/state/nix/profiles/home-manager 2>/dev/null) BAKED=$(readlink -f /opt/hm-activation) diff --git a/home-manager/modules/tools/agents.nix b/home-manager/modules/tools/agents.nix index 86590b1d..d1c134b7 100644 --- a/home-manager/modules/tools/agents.nix +++ b/home-manager/modules/tools/agents.nix @@ -82,11 +82,19 @@ let trap 'rm -f "$tmp" "$md.new"' EXIT # Strip the previous managed block, plus any bare import line an - # append-era generation left behind. Everything else is hand-edited. + # append-era generation left behind, plus the container doc that the + # Dockerfile and entrypoint used to copy into this file before #122 moved + # it to ~/.claude/rules/container-env.md. A claude-home volume keeps that + # old body forever otherwise, and it then loads twice per session with one + # copy stale. The legacy doc has only ## subsections, so skip from its H1 + # to the next H1 or EOF. Everything else is hand-edited. ${pkgs.gawk}/bin/awk ' /^