nixos/hardware/device-tree: fix application of overlays

Previously whenever an overlay was found to be incompatible with a base
device tree blob, the entire base dtb would be skipped in favor of
processing the next one. This had the unfortunate effect where overlays
would not fully be applied if any incompatibility was found. For
example, this is an issue with build device trees specific for one
flavor of raspberry pi if the overlay was not compatible _everywhere_.

The solution is to forego the `continue` keyword if an overlay is in
compatible and instead use a compound conditional statement to skip
incompatible overlays but continue trying to apply it to any remaining
dtbs.
This commit is contained in:
Ivan Petkov 2022-12-10 20:13:08 -08:00
parent 2dea0f4c2d
commit bfd1c45e54
No known key found for this signature in database
GPG key ID: BB6F9EFC065832B6

View file

@ -22,21 +22,19 @@ with lib; {
# skip incompatible and non-matching overlays
if [[ ! "$dtbCompat" =~ "$overlayCompat" ]]; then
echo -n "Skipping overlay ${o.name}: incompatible with $(basename "$dtb")"
continue
fi
${optionalString (o.filter != null) ''
if [[ "''${dtb//${o.filter}/}" == "$dtb" ]]; then
echo -n "Skipping overlay ${o.name}: filter does not match $(basename "$dtb")"
continue
fi
echo "Skipping overlay ${o.name}: incompatible with $(basename "$dtb")"
elif ${if (o.filter == null) then "false" else ''
[[ "''${dtb//${o.filter}/}" == "$dtb" ]]
''}
echo -n "Applying overlay ${o.name} to $(basename "$dtb")... "
mv "$dtb"{,.in}
fdtoverlay -o "$dtb" -i "$dtb.in" "${o.dtboFile}"
echo "ok"
rm "$dtb.in"
then
echo "Skipping overlay ${o.name}: filter does not match $(basename "$dtb")"
else
echo -n "Applying overlay ${o.name} to $(basename "$dtb")... "
mv "$dtb"{,.in}
fdtoverlay -o "$dtb" -i "$dtb.in" "${o.dtboFile}"
echo "ok"
rm "$dtb.in"
fi
'')}
done