1 { lib, stdenv, stdenvNoCC, dtc, writers, python3 }:
4 # Compile single Device Tree overlay source
5 # file (.dts) into its compiled variant (.dtb)
10 extraPreprocessorFlags ? []
11 }: stdenv.mkDerivation {
14 nativeBuildInputs = [ dtc ];
18 includeFlagsStr = lib.concatMapStringsSep " " (includePath: "-I${includePath}") includePaths;
19 extraPreprocessorFlagsStr = lib.concatStringsSep " " extraPreprocessorFlags;
22 $CC -E -nostdinc ${includeFlagsStr} -undef -D__DTS__ -x assembler-with-cpp ${extraPreprocessorFlagsStr} ${dtsFile} | \
23 dtc -I dts -O dtb -@ -o $out
27 applyOverlays = (base: overlays': stdenvNoCC.mkDerivation {
28 name = "device-tree-overlays";
30 (python3.pythonOnBuildForHost.withPackages(ps: [ps.libfdt]))
33 python ${./apply_overlays.py} --source ${base} --destination $out --overlays ${writers.writeJSON "overlays.json" overlays'}