@@ -125,10 +125,13 @@ in
125125 echo "${pkgs.stdenv.buildPlatform.system}" > $out/nix-support/system
126126 echo "file sd-image $img" >> $out/nix-support/hydra-build-products
127127
128− # Create the image file sized to fit /boot/firmware and /, plus 20M of slack
128+ # Gap in front of the first partition, in MiB
129+ gap=8
130+
131+ # Create the image file sized to fit /boot/firmware and /, plus slack for the gap.
129132 rootSizeBlocks=$(du -B 512 --apparent-size ${rootfsImage} | awk '{ print $1 }')
130133 firmwareSizeBlocks=$((${toString config.sdImage.firmwareSize} * 1024 * 1024 / 512))
131− imageSize=$((rootSizeBlocks * 512 + firmwareSizeBlocks * 512 + 20 * 1024 * 1024))
134+ imageSize=$((rootSizeBlocks * 512 + firmwareSizeBlocks * 512 + gap * 1024 * 1024))
132135 truncate -s $imageSize $img
133136
134137 # type=b is 'W95 FAT32', type=83 is 'Linux'.
@@ -138,8 +141,8 @@ in
138141 label: dos
139142 label-id: ${config.sdImage.firmwarePartitionID}
140143
141− start=8M, size=$firmwareSizeBlocks, type=b
142− start=${toString (8 + config.sdImage.firmwareSize)}M, type=83, bootable
144+ start=''${gap}M, size=$firmwareSizeBlocks, type=b
145+ start=$((gap + ${toString config.sdImage.firmwareSize}))M, type=83, bootable
143146 EOF
144147
145148 # Copy the rootfs into the SD image