Skip to content

blitz/polyglot-image

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The Polyglot NixOS Image

This is a demo of building bootable NixOS disk images that work on multiple architectures. In principle, this works on all UEFI platforms. For now, we use the following well supported platforms in NixOS:

  • Intel/AMD x86_64
  • ARM aarch64
  • RISC-V riscv64

We will build one disk image that boots on all these platforms.

How to build the image?

Just build the default package via:

$ nix build

As this cross-compiles code for aarch64 and riscv64, which is usually not found in cache.nixos.org, this will take a while. You can use nom to see what's going on:

$ nom build

When this process is done, you will have a disk image in /result/boot-volume.raw.

How to run the image?

You can use any VMM that supports UEFI to run these. They should also run on real hardware (not tested!). For convenience, I've included the necessary Qemu magic in the shell environment:

$ nix develop
$ qemu-efi riscv64 result/boot-volume.raw # or x86_64 or aarch64

How does this work?

We build UKIs for each architecture and put them into their default locations on the UEFI System Partition. These default locations are architecture-dependent.

Each UKI refers to a different NixOS top-level store path. We take all of those and their transitive closure and pack them into one big compressed read-only partition that eventually is mounted at /nix/store. So each architecture uses the same store and we save some bits compared to packing them all individually.

Limitations

Of course, there are limitations. For now, all architectures share the same /var. This is probably a bad idea for any serious use, because programs might not share a compatible data format between architectures.

About

A disk image that boots on multiple architectures

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages