2.7 KiB
Ownerboot Architecture
Nixpkgs
Nixpkgs is organized as a mutually-recursive package collection; the machinery for this involves lib.makeScope
and callPackage
.
Ownerboot
Ownerboot creates a second mutually-recursive package set containing all of the build products which go into the final flash image; this package set is what you see in src/default.nix
:
coreboot
-- a Nix package for coreboot, since it is not in nixpkgskernel
-- the Linux kernel, using a custom (non-nixpkgs) expressionuserspace
-- the userspace for the linux initramfsinitramfs
-- mergesuserspace
with the boot-critical modules fromkernel
and wraps it in a properly-formattedcpio
archivearm-trusted-firmware
-- the ARM EL3 privileged routinesfit
-- generates a FIT payloadiasl
-- the Intel ACPI compiler
Many of these packages are simply customizations of the corresponding packages in nixpkgs. In spite of this, the ownerboot package set is not a scope-extension of any nixpkgs package set, in order to avoid future package name collisions as nixpkgs adds more packages (and present name collisions due to mistakes!).
Cross Compilation
Ownerboot is designed for cross-compilation as a first-class citizen. My arm64 laptop is fanless and lightweight but slow; I don't want to use it to build its own bootloader.
Terminology
Recall the GCC cross-compilation terminology:
build
: the platfrom doing the compilinghost
: the platform which runs the result of the compilationtarget
: if running the result of the compilation emits code, the platform on which that code runs
Package Sets
When cross-compiling nixpkgs there will be (at least) two of these mutually-recursive package sets. Ownerboot instantiates them as:
nixpkgsOnBuildForBuild
: a copy of nixpkgs which executes on the build machine and emits code for the build machinenixpkgsOnBuildForHost
: a copy of nixpkgs which executes on the build machine and emits code for the host machine
The ownerboot package set is host-independent; it contains only the code which is common across all hosts. Several essential inputs (for example, choice of coreboot version) are host-specific. The host-independent package set has throw "you must provide..."
placeholders for these. If you attempt to build the host-independent package set, you will encounter these thrown exceptions.
Each host platform supported by ownerboot applies an overlay (i.e. overrideScope'
) to the host-independent package set. These overlays must replace all of the throw
placeholders in order to produce a useful build artifact. There is one entry for each supported host platform near the bottom of src/default.nix
.