Repository navigation
Darwin linux-builder drop-in solution with Rosetta support - #544193
Conversation
60c18de to
56e7343
Compare
56e7343 to
7e94757
Compare
| { | ||
| options = { | ||
|
|
||
| virtualisation.memorySize = lib.mkOption { |
There was a problem hiding this comment.
cc @nikstur as you were working on a similar split-up of the vm module at BornHack
There was a problem hiding this comment.
if we get feedback from @nikstur i would incorporate that. otherwise this could be a followup PR?
There was a problem hiding this comment.
This unfortunately perpetuates the bad original design choices of the qemu-vm module. However, since the qemu-vm module is mostly untouched (and thus can be changed independently), this is fine for me. On the other hand, it makes it easier to remove the macos specific workarounds (hostPkgs. host certs, etc.) from the qemu abstraction. So it's fine for me.
There was a problem hiding this comment.
Thank you for the quick feedback.
Do you have some material on your thoughts about the design choices and how you intend/plan to fix them?
arianvp
left a comment
There was a problem hiding this comment.
Haven't been able to test this end-to-end yet as I'm on vacation without access to a Mac. Overall approach looks fine. But have a few comments / questions.
f579dd4 to
325e6b2
Compare
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
| virtualisation.vz.diskImage = "./${config.networking.hostName}.qcow2"; | ||
|
|
||
| # authorized keys come via virtiofs. fix uid and mode for sshd's ownership checks. | ||
| systemd.services.copy-builder-keys = { |
There was a problem hiding this comment.
Note to self: This can be done way cleaner with a systemd credential passed by the hypervisor
e.g. #543333 adds support to configure the root's ssh key.
We can do something similar here. But I'll file that as a follow-up PR once linked PR lands.
There was a problem hiding this comment.
That sounds super interesting. I am happy to implement this or collab.
arianvp
left a comment
There was a problem hiding this comment.
Was able to build both an aarch64 and x86_64 binary with this. Didn't test nested virtualization as I don't have an M3+ device.
I have some ideas how this can be further improved. e.g. I think we can avoid SSH altogether by making nix-daemon.socket listen on vsock directly. I'll have a look contributing those changes to the vz package
I have implemented this once but it's difficult for multiple reasons and did not bring the improvements that i hoped for. Let's chat about this if you're interested. |
|
Thank you so much for your input, testing, and merging in such a short time @arianvp. I really appreciate it!!! |
This PR introduces a Linux builder for macOS that makes
x86_64-linuxbuilds ~2.5× faster by running the NixOS guest on Apple's native Virtualization.framework with Rosetta. It also has a smaller closure than the qemu build by offloading a lot to the apple framework.This is designed as a ~one-line drop-in swap for
darwin.linux-builder.The PR consists of:
pkgs.vzvm, an Apple Virtualization.framework based VMM. It is minimized for the projected use case as a linux-builder drop-in replacement with Rosetta support. Forwards ssh TCP connects via vsock to get around the NAT setup from outside.The following nix-darwin configuration snippet can be used to run it:
Regarding the AI policy: The upstream project has been developed with some LLM help but human-maintained and 110% human-reviewed and tested. All code in this PR is hand-written, but i let an LLM correct my sometimes bad english (not a native speaker).
Things done
passthru.tests.nixpkgs-reviewon this PR. See nixpkgs-review usage../result/bin/.