Skip to content

nixos/qemu-vm: restore 9p support for darwin; add darwin.linux-builder back to release blocker - #562444

Merged
arianvp merged 2 commits into
NixOS:staging-nixosfrom
booxter:builder-9p
Sep 14, 2026
Merged

arianvp merged 2 commits into
NixOS:staging-nixosfrom
booxter:builder-9p

Conversation

@booxter

@booxter booxter commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Keep virtiofs for linux, but use 9p otherwise. This restores darwin support -
which is used both for darwin.linux-builder and build-vm nixpkgs VMs.

This patch does not restore removed options: their utility is not immediately
clear to me, and restoring the options would complicate the code for unclear
gains. Hopefully, the reduced scope also makes it more palatable for
maintainers to accept this functionality back in.

With this change, I can build darwin.linux-builder and run NixOS tests again.

This should not affect linux rebuilds, hence posting to master.
Meh, there's a single newline change. Targeting to staging-nixos.

Things done

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-darwin: 1 This PR causes 1 package 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 Sep 12, 2026
@booxter booxter mentioned this pull request Sep 12, 2026
4 of 13 tasks
Keep virtiofs for linux, but use 9p otherwise. This restores darwin
support - which is used both for `darwin.linux-builder` and `build-vm`
nixpkgs VMs.

This patch does not restore removed options: their utility is not
immediately clear to me, and restoring the options would complicate the
code for unclear gains. Hopefully, the reduced scope also makes it more
palatable for maintainers to accept this functionality back in.
This reverts commit 342b435.

Darwin support in qemu-vm.nix is restored and the qemu builder can,
again, be evaluated.
@booxter
booxter changed the base branch from master to staging-nixos September 12, 2026 01:55
@nixpkgs-ci nixpkgs-ci Bot closed this Sep 12, 2026
@nixpkgs-ci nixpkgs-ci Bot reopened this Sep 12, 2026
@nixpkgs-branch-check
nixpkgs-branch-check Bot dismissed their stale review September 12, 2026 02:01

Review dismissed automatically

@vcunat vcunat added the 6.topic: darwin Running or building packages on Darwin label Sep 12, 2026
@arianvp

arianvp commented Sep 12, 2026

Copy link
Copy Markdown
Member

Have you tried linux-builder-vz ?

@emilazy

emilazy commented Sep 12, 2026

Copy link
Copy Markdown
Member

That requires nested virtualization to run NixOS tests, which is slow (at least on x86 - I confess I haven't tested it on Apple Silicon) and only available on recent hardware.

FWIW I have used this functionality frequently with upstream NixOS tests while working on Nixpkgs contributions.

@nikstur

nikstur commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

IMO this doesn't belong in the qemu-vm module but in the Linux builder module. The only thing you seem to need is a shared directory for the keys. You can just add these via qemu.options there. I can look into it and prepare a patch but I cannot test it (which is one of the core issues here).

This would also mean that it's easier to evolve the qemu-vm module without affecting the Linux builder in the future.

@tfc

tfc commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

@booxter thank you for this work and especially restoring nixos tests on the mac again. Would have hoped for this to happen in the PR that removed it, so extra-thanks for the effort!

@emilazy

emilazy commented Sep 12, 2026

Copy link
Copy Markdown
Member

A change specific to the Linux builder wouldn't fix running NixOS tests or NixOS configuration VMs. It does seem better to keep the guest environment uniform across host platforms where possible - there's at least an attempt to port virtiofsd to macOS that could work - but the diff here doesn't seem like a major burden to fix a regression in an explicitly-documented feature that impacts people working with and on NixOS. Maybe @booxter would be willing to become a maintainer of the QEMU VM module to keep it working?

@booxter

booxter commented Sep 12, 2026

Copy link
Copy Markdown
Contributor Author

@arianvp

yes I tried -vz. It's currently broken after gc: #557239

There are also kernel lockups that I hit with it (I reported a bug). It will probably take some time for it to mature.

But also: I feel like folks don't know that nixos tests work on MacOS natively, and that's where 9p comes in. It's actually magic and a killer Nix* feature for developers on Darwin (which we have a lot in the industry overall).

@emilazy I appreciate an attempt to nerd snipe me to implement virtiofsd (who knows, maybe it will work😄?) but we need the regression fixed today, not in a distant future. That's what this PR is doing, and for a very cheap price honestly.

I'm happy to add myself to maintainers of the module if folks are fine with it: it's clear that the current team has its priorities elsewhere, so maybe having a Darwin voice on the list could help to catch such changes earlier. Personally I'm very much committed to maintain and improve both builder and nixos tests on Darwin and in general.

@nikstur

nikstur commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

an explicitly-documented feature that impacts people working with and on NixOS

That's true and fair but it also states that it needs some kind of remote builder:

If you run the tests on a macOS machine, you also need a “remote” builder for Linux; possibly a VM. nix-darwin users may enable nix.linux-builder.enable to launch such a VM.

And it's worth noting that make-disk-image (which is used in a large share of our tests) has been using virtiofs since December 2024 and thus has only been able to be used with nested virt on darwin.

However, I think it's fine to go with this for now as a sort of stopgap solution. I do, however, also think that we have a too tight coupling here where the qemu-vm module tries to do too much and is thus very hard to evolve. Ideally we end up in a state where we have different backends that can be managed in a different lifecycle (e.g. one for Darwin & one for Linux).

It's good to know that @booxter is comitted to help maintain this.

Let me run the systemd tests really quick and then we can get this merged.

@nixpkgs-ci nixpkgs-ci Bot added the 12.approvals: 1 This PR was reviewed and approved by one person. label Sep 12, 2026
holidayworking added a commit to holidayworking/core that referenced this pull request Sep 13, 2026
nixpkgs 02f5696b breaks nix.linux-builder on aarch64-darwin: NixOS/nixpkgs#552774
switched qemu-vm from 9p to virtiofs, but virtiofsd doesn't support darwin.
Fix (NixOS/nixpkgs#562444) isn't merged yet, so pin nixpkgs to aff8a0b (2026-09-10)
until it lands.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@arianvp
arianvp added this pull request to the merge queue Sep 14, 2026
Merged via the queue into NixOS:staging-nixos with commit c96d269 Sep 14, 2026
43 of 46 checks passed
@booxter

booxter commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

If you run the tests on a macOS machine, you also need a “remote” builder for Linux; possibly a VM. nix-darwin users may enable nix.linux-builder.enable to launch such a VM.

FWIW this is true and not contradictory: you need a builder to build test VMs, but then you run the result natively on a local Darwin machine. That said, the wording can probably be more tight. I'll look into it.

myme added a commit to myme/dotfiles that referenced this pull request Sep 21, 2026
nixpkgs switched qemu-vm's sharedDirectories from 9p to virtiofs
(NixOS/nixpkgs#552774), calling `hostPkgs.virtiofsd` unconditionally.
virtiofsd is linux-only, so `nix.linux-builder.enable` stopped
evaluating on aarch64-darwin:

  error: Refusing to evaluate package 'virtiofsd-1.14.0' ... because it
  is not available on the requested hostPlatform

NixOS/nixpkgs#562444 keeps virtiofs for linux and falls back to 9p
otherwise, restoring darwin.linux-builder. It landed in nixos-unstable
after the rev this lock pinned.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: darwin Running or building packages on Darwin 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-darwin: 1 This PR causes 1 package 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants