Skip to content

linux-builder-vz: fix nixdb retention; harden registration against gc - #557239

Merged
booxter merged 8 commits into
NixOS:staging-nixosfrom
booxter:vz-gc-destroyed
Sep 19, 2026
Merged

booxter merged 8 commits into
NixOS:staging-nixosfrom
booxter:vz-gc-destroyed

Conversation

@booxter

@booxter booxter commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

The primary goal of this PR is to fix the following VZ builder issue:

  1. Registration file is gc'd because it doesn't register itself.
  2. Builder reboots.
  3. Since /nix/var is not persistent across reboots, database is lost.
  4. Registration fails because its file is gone.
  5. Still, machine boots because registration service is not blocking.
  6. Later, another gc wipes everything else, including system closure.
  7. Another reboot fails because init is gone.

This is not theoretical: I am drive-testing this builder for a few weeks and
I hit sudden builder inaccessibility due to this issue - where I couldn't ssh
into the builder, even after I reboot it. Disk image inspection revealed lots
of whiteouts on expected store paths.


The core changes are:

  1. Persist complete /nix out of tmpfs, making store state survive reboot.
  2. Load registration file from .ro-store that is whiteout-resistant.

The rest are just hardening adjustments for the registration service.

The branch also includes a new nixos test designed to catch regressions for
a configuration that resembles -vz builder (but using qemu), as well as a few
small refactoring patches to make it possible.

Things done

Otherwise on reboot the builder "forgets" about any store paths present
under /nix/store that are not part of the initial registration.
While nix-store --load-db should create missing directories itself, it's
better to let tmpfiles service to prepare directories before
registration.
Otherwise, if gc later decides to remove registration derivation from
its store, consequent reboots will point to a missing registration file.

(As of this patch, this is not fatal because registration service
failure doesn't fail builder boot; a later patch in the series makes
registration service required, making sure we never boot with db that is
not populated.)
nixpkgs-branch-check[bot]

This comment was marked as outdated.

@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-nixos-tests This PR causes rebuilds for all NixOS tests and should normally target the staging branches. 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` labels Aug 28, 2026
If there's no store, there's no registration path contained in it.
This guarantees that the builder will never boot without prepared nixdb.
@booxter
booxter changed the base branch from master to staging-nixos August 29, 2026 02:35
@nixpkgs-ci nixpkgs-ci Bot closed this Aug 29, 2026
@nixpkgs-ci nixpkgs-ci Bot reopened this Aug 29, 2026
@booxter
booxter marked this pull request as ready for review August 29, 2026 02:38
Assisted-by: Codex, gpt-5.6-sol medium
Assisted-by: Codex, gpt-5.6-sol medium
This is a qemu based nixos test that attempts to cover configuration
resembling real linux-builder-vz disk layout. The test validates that
store path referred in kernel cmdline survive gc as well as reboot.
(It was actually broken for this builder before recent fixes.)

Assisted-by: Codex, gpt-5.6-sol medium
@nixpkgs-branch-check
nixpkgs-branch-check Bot dismissed their stale review August 29, 2026 02:49

Review dismissed automatically

@nixpkgs-ci
nixpkgs-ci Bot requested a review from RaitoBezarius August 29, 2026 02:50
@nixpkgs-ci nixpkgs-ci Bot added the llm-assisted Contributions that include code generation with LLMs label Aug 29, 2026
@booxter

booxter commented Aug 29, 2026

Copy link
Copy Markdown
Contributor Author

@tfc

@tfc

tfc commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

@booxter thank you for coming up with this fix! As mentioned in matrix and the vzvm repo, i am completely buried in nixcon preparations.

If someone else can help look into this i'm all in for merging, it's just that i don't want to blindly merge it without having ample time to look into it.

Maybe @arianvp has capacity to look into this PR?

@nixpkgs-ci nixpkgs-ci Bot added the 12.approvals: 1 This PR was reviewed and approved by one person. label Sep 12, 2026
@booxter
booxter added this pull request to the merge queue Sep 19, 2026
Merged via the queue into NixOS:staging-nixos with commit 0bce973 Sep 19, 2026
31 of 33 checks passed
@booxter
booxter deleted the vz-gc-destroyed branch September 19, 2026 02:23
tfc added a commit to applicative-systems/vzvm that referenced this pull request Oct 18, 2026
tfc added a commit to applicative-systems/vzvm that referenced this pull request Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-nixos-tests This PR causes rebuilds for all NixOS tests and should normally target the staging branches. 12.approvals: 1 This PR was reviewed and approved by one person. llm-assisted Contributions that include code generation with LLMs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants