2021-06-15 10:12:01 +08:00
|
|
|
{ lib, stdenvNoCC, dtc, findutils }:
|
2021-06-03 07:17:23 +08:00
|
|
|
|
2021-06-15 10:12:01 +08:00
|
|
|
with lib; {
|
2021-06-03 07:17:23 +08:00
|
|
|
applyOverlays = (base: overlays: stdenvNoCC.mkDerivation {
|
|
|
|
name = "device-tree-overlays";
|
|
|
|
nativeBuildInputs = [ dtc findutils ];
|
|
|
|
buildCommand = let
|
|
|
|
quotedDtbos = concatMapStringsSep " " (o: "\"${toString o}\"") (toList overlays);
|
|
|
|
in ''
|
|
|
|
for dtb in $(find ${base} -name "*.dtb" ); do
|
|
|
|
outDtb=$out/$(realpath --relative-to "${base}" "$dtb")
|
|
|
|
mkdir -p "$(dirname "$outDtb")"
|
|
|
|
fdtoverlay -o "$outDtb" -i "$dtb" ${quotedDtbos};
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
});
|
|
|
|
}
|