Nix 101 Course / Section 7: Advanced packaging topics
Premium

7.5 Nix cross-compilation with pkgsCross

Lesson 51 of 68 · 23:52

placeholder thumbnail

Sign in, then buy this course to watch

Free account · no credit card needed

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 ripgrep for ARM and Windows live in the REPL, verified with the file utility
  • Splicing explained: how two callPackage invocations combine into one derivation that runs on your host but compiles for the target
  • The one mixup that breaks cross-compilation, and how strictDeps = true turns it into an immediate error instead of a mystery
  • pkgsStatic for 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: