7.5 Nix cross-compilation with pkgsCross
Lesson 51 of 68 · 23:52
Up next in 5s…
About this lesson
Building ARM binaries on an Intel machine, Windows executables on Linux, static binaries with musl: Nix cross-compilation turns all of this into picking a different package set. This lesson shows pkgsCross and the crossSystem parameter, explains the splicing mechanism behind them, and teaches the habits that keep your own packages cross-compilable even if you never touch embedded systems.
In this video
- A tour of
pkgs.lib.systems.examples: ARM, RISC-V, WebAssembly, Windows, Android, Raspberry Pi, even iPhone targets, ready to use - Cross-building GNU hello and
ripgrepfor ARM and Windows live in the REPL, verified with thefileutility - Splicing explained: how two
callPackageinvocations combine into one derivation that runs on your host but compiles for the target - The one mixup that breaks cross-compilation, and how
strictDeps = trueturns it into an immediate error instead of a mystery pkgsStaticfor static linking without touching your build system, plus the build system smells that quietly kill portability
After this lesson
You can cross-compile packages from nixpkgs for another architecture in one line, and you know the rules that keep your own derivations portable enough that others can do the same with your software.
Builds on: How callPackage works (6.3)
Links: