From af0fe5bdfddd2ab3eac6fb6eb810edfd1c04a7dd Mon Sep 17 00:00:00 2001 From: beatzaplenty Date: Mon, 20 Jul 2026 15:09:57 +0000 Subject: [PATCH] Wire configure-nix-cache-client.sh into create-proxmox-resource.sh's tooling bootstrap Run it once, right after a node's first-time Nix bootstrap (not on every invocation, and not inside codex-setup.sh/codex-maintenance.sh themselves), so a freshly-bootstrapped Proxmox node substitutes from and can offload builds to nix-cache on every subsequent run. Non-fatal on failure -- the build still proceeds, just without nix-cache. Co-Authored-By: Claude Sonnet 5 --- CLAUDE.md | 7 ++++++- scripts/create-proxmox-resource.sh | 17 ++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 43018cf..0c613bb 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -97,7 +97,12 @@ Beyond `codex-setup.sh`/`codex-maintenance.sh` above, `scripts/` also has: Refuses to create a target whose host identity already exists live on the node (checked directly via `qm`/`pct`, not any file in this repo) unless `--allow-duplicate-host` is passed. `--dry-run` throughout both - modes. + modes. The first time it has to bootstrap build tooling on a node (i.e. + `nix` wasn't already on its `PATH`), it also runs + `scripts/configure-nix-cache-client.sh` there (non-fatally — a failure + just falls back to building from source / `cache.nixos.org`) so the + node substitutes from and can offload builds to nix-cache on every + subsequent run, not just this one. - `scripts/env.sh` — shared config (`PROXMOX_HOST`, storage pool, bridge, default cores/memory) sourced by `create-proxmox-resource.sh`. Add new cross-script config here instead of duplicating it per-script. diff --git a/scripts/create-proxmox-resource.sh b/scripts/create-proxmox-resource.sh index 6d303df..e4fb715 100755 --- a/scripts/create-proxmox-resource.sh +++ b/scripts/create-proxmox-resource.sh @@ -524,7 +524,7 @@ ensure_remote_repo() { echo echo "==> Ensuring ${remote_repo_dir} exists and is current on ${node}..." if [[ "$dry_run" -eq 1 ]]; then - echo "[dry-run] would ensure ${remote_repo_dir} exists on ${node} (clone if missing, git pull if present), and would verify/bootstrap build tooling there (scripts/codex-setup.sh) if \`nix\` isn't already on PATH" + echo "[dry-run] would ensure ${remote_repo_dir} exists on ${node} (clone if missing, git pull if present), and would verify/bootstrap build tooling there (scripts/codex-setup.sh) if \`nix\` isn't already on PATH -- and if that bootstrap actually ran, would also configure ${node} as a nix-cache client (scripts/configure-nix-cache-client.sh)" return fi @@ -571,6 +571,21 @@ ensure_remote_repo() { else echo "==> Bootstrapping build tooling on ${node} (scripts/codex-setup.sh)..." ssh "$ssh_target" "cd '${remote_repo_dir}' && bash scripts/codex-setup.sh" + + # Only on this first-time bootstrap, not every run -- a node that + # already has tooling either already went through this once, or had + # it configured some other way, and re-running is harmless but + # pointless. Non-fatal: this only makes the node's own builds faster + # (substitute from nix-cache instead of building from source) and + # offloadable to it as a remote builder -- worth trying, not worth + # aborting the image build over if nix-cache happens to be down right + # now. Needs ensure_nix_profile first, same as the tooling_check_cmd + # above -- ssh's non-interactive command execution won't have picked + # up a freshly single-user-installed `nix` otherwise. + echo "==> Configuring ${node} as a nix-cache substituter/remote-builder client..." + if ! ssh "$ssh_target" "cd '${remote_repo_dir}' && . scripts/lib/nix-bootstrap.sh && ensure_nix_profile && bash scripts/configure-nix-cache-client.sh"; then + echo "WARNING: configure-nix-cache-client.sh failed on ${node} -- continuing without it (${node} will build from source / against cache.nixos.org only)." >&2 + fi fi }