nixos/binfmt: Add support for using statically-linked QEMU#160802
nixos/binfmt: Add support for using statically-linked QEMU#160802zhaofengli wants to merge 9 commits intoNixOS:masterfrom
Conversation
|
What's the status of this? I ran into the need for For the limited testing needs I have I can probably just keep rebasing if I need to update, and just disable the EDIT: heh, didn't really need this, turns out the real issue was a much weirder "high UID/GID" thing, not specific to any architecture - but I'll keep my branch around if it helps anyone. |
There was a problem hiding this comment.
Maybe we should combine this into a minimal option or package?
e9d1fb5 to
5ea9106
Compare
|
This is great work, how can we contribute to finalize it? |
|
I guess we can first get the support for building QEMU statically as well as |
|
This looks great, I'd love to see this getting merged. |
|
Hi all, glad to see this finally getting some attention. I'm currently busy with something else at the moment but will get back to this PR in the coming days. |
5ea9106 to
147346d
Compare
|
Is there anything I can do to help getting this forward? |
147346d to
491d05c
Compare
|
This is a friendly ping. Since the allocation failure is intentional, would it be possible to merge the pull request now? I believe that this feature would be very useful for developers who work on embedded Linux products. |
Signed-off-by: Bernd Müller <github@muellerbernd.de>
|
I ran into this limitation today once again. +1 for merging this. |
|
I also ran into this problem. +1 for merging |
|
Could you please solve the merge conflicts. I will merge afterwards. |
|
Ran into this the last few days and took me a while to figure out why binfmt was working on Debian but not on NixOS, +1 for merging, would allow me to run different arch images in Kubernetes |
|
I'm not familiar with the etiquette on updating the PR of others, but I did attempt to update it to fix merge conflicts and new compilation issues on #300070 I did not find yet the right git commands to keep #160802 authorship during the merge I'd like to thank @zhaofengli for the original PR and I'll investigate how to keep the authorship intact meanwhile |
Built on top of NixOS#160802, this commit addresses necessary updates to bring it up to parity with `nixpkgs-unstable`: - Introduce `pipewireSupport: false` as a new override option - Remove 8.1.1 patch as qemu is 8.2.2 in nixpkgs-unstable - Introduce new patch to expose libaio static due to upstream meson.build changes In order to compile, the `perl` dependency must also be fixed (NixOS#299623) on the `pkgsStatic` environment. With this additional changeset, `nix-shell -p qemu-user-static` compiles. **Tested on**: - `x86_64-linux` - `aarch64-linux` **Depends on:** - [ ] NixOS#299623
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/docker-ignoring-platform-when-run-in-nixos/21120/17 |
Built on top of NixOS#160802, this commit addresses necessary updates to bring it up to parity with `nixpkgs-unstable`: - Introduce `pipewireSupport: false` as a new override option - Remove 8.1.1 patch as qemu is 8.2.2 in nixpkgs-unstable - Introduce new patch to expose libaio static due to upstream meson.build changes **Tested on**: - `x86_64-linux` - `aarch64-linux` **Depends on:** - [ ] NixOS#299623
Oops, you’re right. I fixed the link. |

Motivation for this change
This PR adds support for using a statically-linked build of QEMU without any intermediate wrapper to the binfmt-misc integration in NixOS. It also enables the "F" (fix binary) flag, allowing chroot into a foreign root filesystem without first having to make the interpreter available inside the rootfs. This fixes #160300 so foreign chroots "just work."
To use the statically-linked QEMU, set
boot.binfmt.preferStaticEmulators = true;.Currently,
qemu-user-staticis built with musl and has a couple of hard-to-debug problems. When buildingcoreutilsfor aarch64-linux on x86_64-linux with it (see #143060 for background),all tests pass except forthe tests become stuck. Other distros shiptest-freewhere it segfaultsqemu-user-staticwith static glibc. To prevent introducing new breakages, this PR keeps the dynamically-linked QEMU as the default.How To Test
nix-build -A nixosTests.systemd-binfmtchroottest is added which makes use of the newqemu-user-staticnix-build --system aarch64-linux -A hello --checkworksboot.binfmt.preferStaticEmulators = true;/etc/nix/nix.confand observe thatextra-sandbox-pathsis now emptynix-build --system aarch64-linux -A hello --checkstill worksnix-build --system aarch64-linux -A coreutils --checkdoesn't work nowThings done
sandbox = trueset innix.conf? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)nixos/doc/manual/md-to-db.shto update generated release notes