Archived
Fix nix-cache retry storms and lxc creation in create-proxmox-resource.sh
Two independent problems found while actually running the script: 1. nix build/nix-shell retry each unreachable substituter/builder up to 5x with backoff, per store path -- with nix-cache down this compounds into minutes of noise. scripts/env.sh gains nix_extra_opts(), which probes http://nix-cache and nixremote@nix-cache:22 once via plain curl/TCP (bypassing Nix's own retry logic entirely -- confirmed nix store ping still retries 5x even with a short connect-timeout) and exports the decision so create-proxmox-resource.sh and the sync-host-keys.sh subprocess it shells out to both reuse it instead of probing independently. 2. The actual failure: "archive contains no configuration file". pct restore expects a vzdump backup archive with embedded config; config.system.build.tarball is a plain CT template tarball -- wrong Proxmox mechanism entirely. Fixed to pct create against it as a vztmpl template instead, uploaded to /var/lib/vz/template/cache/ rather than /var/lib/vz/dump/. This same wrong claim had propagated into docs/auto-installer.md, README.md, and CLAUDE.md from when the script was first written -- corrected everywhere. Also: checks for an already-uploaded image on the node (fixed <flake_target>.tar.xz/.raw naming) before building, skipping build+upload entirely if found (--force-rebuild to always rebuild). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01La55Nsss8jZ7ZuzUV9mfot
This commit is contained in:
+20
-4
@@ -34,10 +34,26 @@ container image, no install step at all:
|
||||
nix build .#nixosConfigurations.lxc-minimal.config.system.build.tarball
|
||||
```
|
||||
|
||||
Then, on the Proxmox host, `pct restore` (or the GUI's "Create CT" → upload
|
||||
template flow) that tarball directly as a new container. First boot runs
|
||||
`boot.postBootCommands` (registers the Nix store DB and system profile) —
|
||||
there's no separate activation step to run yourself.
|
||||
This is a plain rootfs tarball, not a `vzdump` backup archive — restoring it
|
||||
with `pct restore` fails ("archive contains no configuration file"), since
|
||||
that command expects backup-archive metadata this tarball doesn't have. Use
|
||||
it as a CT *template* instead: drop it under Proxmox's template storage
|
||||
(conventionally `/var/lib/vz/template/cache/` for the `local` storage, or
|
||||
the GUI's "Create CT" → upload-as-template flow) and create a container
|
||||
from it, supplying all config on the command line since a template has none
|
||||
of its own:
|
||||
|
||||
```sh
|
||||
pct create <vmid> local:vztmpl/<file>.tar.xz \
|
||||
--rootfs local-lvm:8 --hostname <name> --cores 2 --memory 2048 \
|
||||
--net0 name=eth0,bridge=vmbr0,ip=dhcp
|
||||
pct start <vmid>
|
||||
```
|
||||
|
||||
First boot runs `boot.postBootCommands` (registers the Nix store DB and
|
||||
system profile) — there's no separate activation step to run yourself.
|
||||
`scripts/create-proxmox-resource.sh --type lxc --host <name>` automates all
|
||||
of this (build, host-key handling, upload, `pct create`) — see its `--help`.
|
||||
|
||||
Host keys still need pre-seeding the same way as any other host (see "Host
|
||||
keys" below) — the sops-nix activation-vs-first-boot race is identical
|
||||
|
||||
Reference in New Issue
Block a user