From bfd1c45e54bd9823b083c10537cf677462fc2c28 Mon Sep 17 00:00:00 2001 From: Ivan Petkov Date: Sat, 10 Dec 2022 20:13:08 -0800 Subject: 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. --- pkgs/os-specific/linux/device-tree/default.nix | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/pkgs/os-specific/linux/device-tree/default.nix b/pkgs/os-specific/linux/device-tree/default.nix index 8b8cca911a9..fb8e92f2330 100644 --- a/pkgs/os-specific/linux/device-tree/default.nix +++ b/pkgs/os-specific/linux/device-tree/default.nix @@ -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 -- cgit 1.4.1