@@ -1,8 +1,12 @@
11# This module creates a bootable SD card image containing the given NixOS
2−# configuration. The generated image is MBR partitioned, with a FAT /boot
3−# partition, and ext4 root partition. The generated image is sized to fit
4−# its contents, and a boot script automatically resizes the root partition
5−# to fit the device on the first boot.
2+# configuration. The generated image is MBR partitioned, with a FAT
3+# /boot/firmware partition, and ext4 root partition. The generated image
4+# is sized to fit its contents, and a boot script automatically resizes
5+# the root partition to fit the device on the first boot.
6+#
7+# The firmware partition is built with expectation to hold the Raspberry
8+# Pi firmware and bootloader, and be removed and replaced with a firmware
9+# build for the target SoC for other board families.
610#
711# The derivation for the SD image will be placed in
812# config.system.build.sdImage
@@ -96,6 +100,9 @@ in
96100 "/boot/firmware" = {
97101 device = "/dev/disk/by-label/FIRMWARE";
98102 fsType = "vfat";
103+ # Alternatively, this could be removed from the configuration.
104+ # The filesystem is not needed at runtime, it could be treated
105+ # as an opaque blob instead of a discrete FAT32 filesystem.
99106 options = [ "nofail" "noauto" ];
100107 };
101108 "/" = {
@@ -125,6 +132,8 @@ in
125132 truncate -s $imageSize $img
126133
127134 # type=b is 'W95 FAT32', type=83 is 'Linux'.
135+ # The "bootable" partition is where u-boot will look file for the bootloader
136+ # information (dtbs, extlinux.conf file).
128137 sfdisk $img <<EOF
129138 label: dos
130139 label-id: ${config.sdImage.firmwarePartitionID}