Skip to content

Commit 32db092

Browse files
Address Copilot review: idempotent git setup, honest nixpkgs wording
- setup-git.sh: stop truncating .gitconfig.local on every run. Use `git config --file --replace-all include.path` so other global keys a user writes inside the container (e.g. core.editor) are preserved, making the script genuinely idempotent. The no-host branch unsets a stale include instead of wiping the file. - Dockerfile: reword the nixpkgs registry comment — nixos-25.05 is a release branch, not a frozen revision; clarify it only governs container bootstrap tooling while the project toolchain is pinned via flake.nix/flake.lock. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent bbd4778 commit 32db092

2 files changed

Lines changed: 18 additions & 6 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,11 @@ RUN curl -fsSL "https://releases.nixos.org/nix/nix-${NIX_VERSION}/install" -o /t
4545

4646
ENV PATH=/home/vscode/.nix-profile/bin:/home/vscode/.npm-global/bin:$PATH
4747

48-
# Pin the `nixpkgs` flake to nixos-25.05 (matches the project's flake.nix), then
49-
# install only the container-level bootstrap/runtime tooling via Nix:
48+
# Point the `nixpkgs` flake registry at the nixos-25.05 release branch (matching
49+
# the project's flake.nix) — a stable channel, though not a frozen revision; it
50+
# only governs the container-level bootstrap tooling below, while the project
51+
# toolchain is pinned reproducibly via flake.nix/flake.lock. Then install only
52+
# that container-level bootstrap/runtime tooling via Nix:
5053
# - direnv + nix-direnv → auto-load and cache the flake's `nix develop` shell on
5154
# entry to /workspace; this is what actually provides the
5255
# project toolchain (python, uv, make, wabt, K Framework),

.devcontainer/setup-git.sh

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,23 @@ set -euo pipefail
1717
host_gitconfig="/home/vscode/.gitconfig"
1818
local_gitconfig="/home/vscode/.gitconfig.local"
1919

20+
# Ensure the writable global config exists without truncating it — a previous run
21+
# (or the user) may have written real settings here (e.g. core.editor), and this
22+
# script must not clobber them.
23+
touch "${local_gitconfig}"
24+
2025
if [ -f "${host_gitconfig}" ]; then
2126
# Host provided a ~/.gitconfig (bind-mounted as a regular file): inherit it.
22-
printf '[include]\n\tpath = %s\n' "${host_gitconfig}" > "${local_gitconfig}"
27+
# Set just the include.path key via `git config` so any other keys the user
28+
# already wrote to the global config are preserved. --replace-all collapses
29+
# the entry to a single value, keeping the operation idempotent across re-runs.
30+
git config --file "${local_gitconfig}" --replace-all include.path "${host_gitconfig}"
2331
echo "setup-git: global config includes host identity from ${host_gitconfig}"
2432
else
2533
# No host ~/.gitconfig — the missing bind source is materialized as an empty
26-
# directory, which must NOT be included. Leave an empty writable global.
27-
: > "${local_gitconfig}"
28-
echo "setup-git: no host ~/.gitconfig found; created empty ${local_gitconfig}"
34+
# directory, which must NOT be included. Drop any stale include.path we may
35+
# have added on an earlier run, but leave every other key untouched.
36+
git config --file "${local_gitconfig}" --unset-all include.path 2>/dev/null || true
37+
echo "setup-git: no host ~/.gitconfig found; using empty ${local_gitconfig}"
2938
echo "setup-git: set your identity with 'git config --global user.name ...' / user.email"
3039
fi

0 commit comments

Comments
 (0)