I’m currently tinkering with cross-compiling NixOS from an AMD machine (“x86_64-linux”) to Raspberry Pi 5 (“aarch64-linux”) and Starfive VisionFive 2 (“riscv-linux”), and would like to know about the latest best practice to recommend in guides. I found several similar styles, but i’m not sure which one is the latest and best:
mySystem = nixpkgs.lib.nixosSystem {
modules = [
{
nixpkgs.buildPlatform = "x86_64-linux";
nixpkgs.hostPlatform = "riscv64-linux";
}
];
};
like it seems to be recommended in the official NixOS manual cross-compile section (but unclear as it mentions other styles as well) and in Jörg Thalheims blog post.
mySystem = nixpkgs.lib.nixosSystem {
modules = [
{
nixpkgs.localSystem.config = "x86_64-unknown-linux-gnu";
nixpkgs.crossSystem.config = "riscv64-unknown-linux-gnu";
}
];
};
that seems to be recommended in the official nix.dev cross-compile guide (although that style is shown only for pkgsCross
usage)
mySystem = nixpkgs.lib.nixosSystem {
modules = [
{
nixpkgs.localSystem.system = "x86_64-linux";
nixpkgs.crossSystem.system = "riscv64-linux";
}
];
};
that seems to be used in multiple blogs like the fantastic recently published handbook guide by Ryan Yin.
mySystem = nixpkgs.lib.nixosSystem {
system = "x86_64-linux"
modules = [
{
nixpkgs.crossSystem.system = "riscv64-linux";
}
];
};
I have seen this style many times in blog posts.
mySystem = nixpkgs.lib.nixosSystem {
system = "x86_64-linux"
modules = [
{
nixpkgs.crossSystem.config = "riscv64-unknown-linux-gnu";
nixpkgs.crossSystem.system = "riscv64-linux";
}
];
};
I have sometimes also have seem both system
and config
having been defined.
So which one is the latest, recommended way? (Or what are the trade-offs?). I could create a PR against the official documentation as well if you can point me to the right place.