Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make-disk-image: add binfmt emulation #943

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

saviosg
Copy link
Contributor

@saviosg saviosg commented Jan 16, 2025

Now it's possible to build images for other architectures with native speed using KVM.
Binfmt emulation is only needed for the bootloader installation step, other steps use native binaries.

To use it, set imageBuilder.enableBinfmt to true, and pass a new nixpkgs instance to the image builder, with the system set to the running machine.

Example, building an aarch64 image on an x86_64 host:

nixpkgs.lib.nixosSystem {
  system = null;
  modules = [
    {
      nixpkgs.buildPlatform = "aarch64-linux";
      nixpkgs.hostPlatform = "aarch64-linux";
    }
  ];
}

...

imageBuilder.enableBinfmt = true;
imageBuilder.pkgs = nixpkgs { system = "x86_64-linux"; };

@iFreilicht
Copy link
Contributor

Very cool! Could you try to add a test for this as well? No need to test all permutations, aarch64 on x86_64 would be sufficient.

@phaer
Copy link
Member

phaer commented Jan 17, 2025

Very nice feature, thank you!

Don't want to block, but I think copying the magic numbers and such from nixpkgs and duplicating them in diskos source might not be the best course of action long-term.

Maybe nixpkgs could expose them via a non-visible readOnly option or so instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants