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 it is generated by hand rather than by a framework, so this page is a map rather than a 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 UEFI bootloader that loads the kernel collection

The last three 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; 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; there are 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 iterating on a component while you work on it. It is not a supported way to produce a system; see The CMake tree.