Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

The Nix Flake

flake.nix is the entry point for everything. It is large and written by hand, so this page is a map. The file itself is the reference.

Inputs

InputWhat it provides
nixpkgs (nixos-26.05)The host side: build tools, unmodified upstream sources that ports reuse
iig-toolsiig, Apple’s IOKit interface generator, needed to build modern kexts
kc-toolskc-builder and prelink-builder, which link kernel collections
xnu-loaderThe bootloader that loads the kernel collection
pd-sb-keyThe key pair that signs Secure Boot images. It defaults to a keyless placeholder, and builds that sign override it

iig-tools, kc-tools and xnu-loader are PureDarwin repositories. When you are changing one of them alongside the main tree, use --override-input, and remember that a build may need the override on more than one input at once.

How the Outputs Are Put Together

mkSystem is evaluated per system and composes four package sets:

packages = commonPackages // arm64Packages // probePackages
           // (linuxPackages, only when the host is Linux)

linuxPackages is where images, kernel collections and runner apps live, which is why a macOS host builds components, the kernel and libSystem included, but no bootable output.

The supporting files:

FileRole
build.nixThe single generic derivation that builds the in-tree CMake sources
image.nixAssembles a partitioned, bootable disk image
nix/sources.nixPins the component source trees
nix/image-contents.nixDecides what goes into each image flavour, and defines the runners
nix/arm64.nixThe arm64 and armv6 kernels, kexts and userland
nix/lib/kc-kexts.nixThe shared x86_64 kernel collection kext list
nix/lib/target-info.nixMaps a target triple to meson and clang settings
nix/pkgs/**Every ported third-party package

Package Naming

  • A bare name is the x86_64 build: kernel, kexts, userland, zsh, mesa.
  • -arm64 is the arm64 build of the same thing: kernel-arm64, zsh-arm64.
  • -arm32 or -armv6 is the 32-bit ARM build: kernel-arm32-bcm2835.
  • A board suffix pins a machine: -virt, -t8010, -bcm2837, -bcm2835.
  • -debug is the DEVELOPMENT kernel configuration, or a debug image built on it.

So kc-arm64-t8010-debug is the debug kernel collection for the iPad 6 target, and image-minimal-debug is the small x86_64 image built against the debug kernel.

nix flake show prints the full list. It is long, with several hundred outputs.

Apps

Apps are the QEMU runners. nix run .#vm, .#kvm, .#arm64-virt, .#arm64-uefi, .#arm64-uboot. They are documented in Running in QEMU.

The Dev Shell

nix develop gives you the toolchain, the cached native ld, migcom and unifdef, and sets CMAKE_TOOLCHAIN_FILE to cmake/nix-toolchain.cmake. devShells.kernel and devShells.default are the same shell.

The shell is for working on one component at a time. It does not produce a system. See The CMake Tree.