Merge pull request #7867 from NixOS/hacking-cross

doc/hacking.md: Corrections and additions for cross
This commit is contained in:
Robert Hensing 2023-02-20 22:25:55 +01:00 committed by GitHub
commit df6829e0d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -110,7 +110,7 @@ $ nix-build
You can also build Nix for one of the [supported target platforms](#target-platforms). You can also build Nix for one of the [supported target platforms](#target-platforms).
## Target platforms ## Platforms
As specified in [`flake.nix`], Nix can be built for various platforms: As specified in [`flake.nix`], Nix can be built for various platforms:
@ -122,14 +122,15 @@ As specified in [`flake.nix`], Nix can be built for various platforms:
[`flake.nix`]: https://github.com/nixos/nix/blob/master/flake.nix [`flake.nix`]: https://github.com/nixos/nix/blob/master/flake.nix
In order to build Nix for a different platform than the one you're currently In order to build Nix for a different platform than the one you're currently
one, you need to have some way for your system Nix to build code for that on, you need to have some way for your system Nix to build code for that
platform. Common solutions include [remote builders] and [binfmt emulation] platform. Common solutions include [remote builders] and [binfmt emulation]
(only supported on NixOS). (only supported on NixOS).
[remote builders]: ../advanced-topics/distributed-builds.md [remote builders]: ../advanced-topics/distributed-builds.md
[binfmt emulation]: https://nixos.org/manual/nixos/stable/options.html#opt-boot.binfmt.emulatedSystems [binfmt emulation]: https://nixos.org/manual/nixos/stable/options.html#opt-boot.binfmt.emulatedSystems
Once you are able to build for different platforms, executing the build is as simple as These solutions let Nix perform builds as if you're on the native platform, so
executing the build is as simple as
```console ```console
$ nix build .#packages.aarch64-linux.default $ nix build .#packages.aarch64-linux.default
@ -145,6 +146,8 @@ for classic Nix.
You can use any of the other supported platforms in place of `aarch64-linux`. You can use any of the other supported platforms in place of `aarch64-linux`.
Cross-compiled builds are available for ARMv6 and ARMv7, and Nix on unsupported platforms can be bootstrapped by adding more `crossSystems` in `flake.nix`.
## Compilation environments ## Compilation environments
Nix can be compiled using multiple environments: Nix can be compiled using multiple environments: