Skip to content

nixos/doc: document systemd-nspawn test containers#479968

Merged
vcunat merged 1 commit into
NixOS:staging-nextfrom
applicative-systems:nixos-test-containers-docs
Mar 19, 2026
Merged

nixos/doc: document systemd-nspawn test containers#479968
vcunat merged 1 commit into
NixOS:staging-nextfrom
applicative-systems:nixos-test-containers-docs

Conversation

@kmein

@kmein kmein commented Jan 14, 2026

Copy link
Copy Markdown
Member

This PR adds and adjusts documentation for the newly introduced systemd-nspawn backend for the NixOS test driver (added in #478109). It ensures that developers know how to:

  • Decide between VM tests and container tests based on their inherent properties.
  • Configure their systems to run container-based tests (e.g., auto-allocate-uids).
  • Write new container-based tests.
  • Debug container-based tests.

See the relevant sections rendered by running: xdg-open "file://$(nix-build nixos/release.nix -A manual.x86_64-linux --no-out-link)/share/doc/nixos/index.html#sec-writing-nixos-tests"

@NixOS/documentation-team

Things done

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

Add a 👍 reaction to pull requests you find important.

Copilot AI review requested due to automatic review settings January 14, 2026 08:12
@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: 0 This PR does not cause any 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/` 6.topic: testing Tooling for automated testing of packages and modules 8.has: documentation This PR adds or changes documentation labels Jan 14, 2026
@kmein kmein force-pushed the nixos-test-containers-docs branch from fbd2cc9 to bd731a2 Compare January 14, 2026 08:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds comprehensive documentation for the newly introduced systemd-nspawn backend for the NixOS test driver. The documentation helps developers understand when to use containers versus VMs for tests, configure their systems appropriately, write container-based tests, and debug them.

Changes:

  • Adds two example tests demonstrating container functionality (test-containers.nix and test-containers-bittorrent.nix)
  • Implements systemd-nspawn container support in the test driver with a new NspawnMachine class alongside the existing QemuMachine class
  • Refactors networking and test infrastructure to support both VMs and containers through shared abstractions
  • Adds extensive documentation covering container vs. VM trade-offs, configuration options, and debugging approaches

Reviewed changes

Copilot reviewed 30 out of 30 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
nixos/tests/test-containers.nix Example test demonstrating container networking and VLAN connectivity
nixos/tests/test-containers-bittorrent.nix Complex test showing BitTorrent functionality across containers and VMs
nixos/tests/all-tests.nix Registers the new container tests
nixos/modules/virtualisation/qemu-vm.nix Moves shared networking options to common module
nixos/modules/virtualisation/nspawn-container/* Implements systemd-nspawn container module and run-nspawn Python package
nixos/modules/virtualisation/guest-networking-options.nix Shared networking options for both VMs and containers
nixos/modules/testing/test-instrumentation.nix Disables backdoor for containers (uses nsenter instead)
nixos/lib/testing/* Refactors test infrastructure to support both VMs and containers
nixos/lib/test-driver/* Implements BaseMachine abstraction with QemuMachine and NspawnMachine implementations
nixos/doc/manual/development/*.section.md Comprehensive documentation for writing and debugging container tests
nixos/doc/manual/redirects.json Adds redirects for new documentation sections

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread nixos/lib/test-driver/src/test_driver/__init__.py Outdated
Comment thread nixos/tests/test-containers.nix Outdated
Comment thread nixos/tests/test-containers.nix Outdated
Comment thread nixos/lib/test-script-prepend.py Outdated
Comment thread nixos/lib/test-script-prepend.py
Comment thread nixos/lib/test-driver/src/test_driver/machine/__init__.py
@kmein kmein force-pushed the nixos-test-containers-docs branch from bd731a2 to bfdcc7c Compare January 14, 2026 08:37
Comment thread nixos/doc/manual/redirects.json
@nixpkgs-ci nixpkgs-ci Bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Jan 17, 2026
@mdaniels5757 mdaniels5757 changed the base branch from master to staging-nixos January 18, 2026 03:22
@nixpkgs-ci nixpkgs-ci Bot closed this Jan 18, 2026
@nixpkgs-ci nixpkgs-ci Bot reopened this Jan 18, 2026
@kmein kmein force-pushed the nixos-test-containers-docs branch from bfdcc7c to 8acd6dc Compare January 21, 2026 07:47
github-actions[bot]

This comment was marked as resolved.

@kmein kmein force-pushed the nixos-test-containers-docs branch from 8acd6dc to bfdcc7c Compare January 21, 2026 07:49
@github-actions github-actions Bot dismissed their stale review January 21, 2026 07:50

Review dismissed automatically

@kmein kmein force-pushed the nixos-test-containers-docs branch from bfdcc7c to 77a3346 Compare January 28, 2026 14:46

- Virtual machines run a separate kernel, which allows testing kernel features
(kernel modules, etc.).
- Virtual machines support testing graphical applications on X11.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the interactive driver seems to have been relegated to VMs in the documentation. should that be mentioned here as well?

@KiaraGrouwstra

Copy link
Copy Markdown
Contributor

not sure if/how this should be part of documentation, but one question coming to mind for me would be, could a single test contain a mix of the two? if so, would that affect whether/how these could interact with one another?

@kmein kmein force-pushed the nixos-test-containers-docs branch from 77a3346 to f8355f9 Compare February 6, 2026 16:49
@kmein

kmein commented Feb 6, 2026

Copy link
Copy Markdown
Member Author

not sure if/how this should be part of documentation, but one question coming to mind for me would be, could a single test contain a mix of the two? if so, would that affect whether/how these could interact with one another?

Thank you for the question! I have now added a section covering this.

@kmein kmein force-pushed the nixos-test-containers-docs branch from f8355f9 to 1cf9f75 Compare February 10, 2026 14:48
test script).

## Shell access in interactive mode {#sec-nixos-test-shell-access}
## Shell access to VMs in interactive mode {#sec-nixos-test-shell-access}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while shell_interact may be specific to VMs, use of socat appears relevant with nspawn containers now as well.
it would be good to make sure that the documentation reflects that.

@kmein kmein force-pushed the nixos-test-containers-docs branch from 1cf9f75 to 5a00c46 Compare March 19, 2026 10:55
@vcunat vcunat changed the base branch from staging-nixos to staging-next March 19, 2026 10:58
@nixpkgs-ci nixpkgs-ci Bot closed this Mar 19, 2026
@nixpkgs-ci nixpkgs-ci Bot reopened this Mar 19, 2026
@vcunat

vcunat commented Mar 19, 2026

Copy link
Copy Markdown
Member

Oops. Is it easy for you to solve conflicts with this base?

@kmein kmein force-pushed the nixos-test-containers-docs branch from 5a00c46 to c125bc7 Compare March 19, 2026 11:02
github-actions[bot]

This comment was marked as resolved.

@nixpkgs-ci nixpkgs-ci Bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Mar 19, 2026
@vcunat vcunat dismissed github-actions[bot]’s stale review March 19, 2026 11:08

Not important. It's just some commits from master.

@kmein kmein force-pushed the nixos-test-containers-docs branch from c125bc7 to 4e91a4a Compare March 19, 2026 11:14
@nixpkgs-ci nixpkgs-ci Bot removed the 8.has: module (update) This PR changes an existing module in `nixos/` label Mar 19, 2026
@vcunat vcunat added this pull request to the merge queue Mar 19, 2026
@vcunat

vcunat commented Mar 19, 2026

Copy link
Copy Markdown
Member

I know it's not a great approach, but let me just merge to unblock all the tests that depend on the NixOS manual.

@vcunat

vcunat commented Mar 19, 2026

Copy link
Copy Markdown
Member

Certainly feel free to continue reviewing and improving this.

Merged via the queue into NixOS:staging-next with commit b512496 Mar 19, 2026
28 of 31 checks passed
@vcunat

vcunat commented Mar 19, 2026

Copy link
Copy Markdown
Member

Actually, it seems like something else got worse by this merge?
https://hydra.nixos.org/build/324391570/nixlog/2/tail

@kmein

kmein commented Mar 19, 2026

Copy link
Copy Markdown
Member Author

Actually, it seems like something else got worse by this merge? https://hydra.nixos.org/build/324391570/nixlog/2/tail

Huh, didn't see that coming (and the CI didn't catch it either ...). Anyways, here's my fix for the errors that I'm seeing in the log: #501294.

@vcunat

vcunat commented Mar 19, 2026

Copy link
Copy Markdown
Member

The CI doesn't check much, though the manual build in particular was first spotted in CI...

@vcunat

vcunat commented Mar 19, 2026

Copy link
Copy Markdown
Member

The -small test-set is green again now 🎉 Thanks for quick fixups.

@Ma27 Ma27 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kmein the one thing I'm missing here is a note reflecting the differences in how the shell in the test node is invoked: #478109 (comment)

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 6.topic: testing Tooling for automated testing of packages and modules 8.has: documentation This PR adds or changes documentation 10.rebuild-darwin: 0 This PR does not cause any 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants