summary refs log tree commit diff
diff options
context:
space:
mode:
authorIvan Petkov <ivanppetkov@gmail.com>2022-12-10 20:13:08 -0800
committerIvan Petkov <ivanppetkov@gmail.com>2022-12-10 20:13:08 -0800
commitbfd1c45e54bd9823b083c10537cf677462fc2c28 (patch)
tree5e7c5806507e639fce60998fa42e56a4514b3c87
parent2dea0f4c2d6e4603f54b2c56c22367e77869490c (diff)
downloadnixpkgs-bfd1c45e54bd9823b083c10537cf677462fc2c28.tar
nixpkgs-bfd1c45e54bd9823b083c10537cf677462fc2c28.tar.gz
nixpkgs-bfd1c45e54bd9823b083c10537cf677462fc2c28.tar.bz2
nixpkgs-bfd1c45e54bd9823b083c10537cf677462fc2c28.tar.lz
nixpkgs-bfd1c45e54bd9823b083c10537cf677462fc2c28.tar.xz
nixpkgs-bfd1c45e54bd9823b083c10537cf677462fc2c28.tar.zst
nixpkgs-bfd1c45e54bd9823b083c10537cf677462fc2c28.zip
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.
-rw-r--r--pkgs/os-specific/linux/device-tree/default.nix26
1 files 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