2022-10-07 01:19:29 +02:00
|
|
|
{
|
|
|
|
stdenv
|
|
|
|
, dtc
|
2023-03-03 00:01:26 +01:00
|
|
|
, lib
|
2022-10-07 01:19:29 +02:00
|
|
|
}:
|
|
|
|
{ dts
|
2022-10-19 18:34:22 +02:00
|
|
|
, includes
|
2023-03-03 00:01:26 +01:00
|
|
|
, commandLine
|
2022-10-07 01:19:29 +02:00
|
|
|
}:let
|
|
|
|
cppDtSearchFlags = builtins.concatStringsSep " " (map (f: "-I${f}") includes);
|
|
|
|
dtcSearchFlags = builtins.concatStringsSep " " (map (f: "-i${f}") includes);
|
2023-03-03 00:01:26 +01:00
|
|
|
cmdline = lib.concatStringsSep " " commandLine;
|
2022-10-07 01:19:29 +02:00
|
|
|
in stdenv.mkDerivation {
|
|
|
|
name = "dtb";
|
|
|
|
phases = [ "buildPhase" ];
|
|
|
|
nativeBuildInputs = [ dtc ];
|
|
|
|
buildPhase = ''
|
2022-10-19 18:34:22 +02:00
|
|
|
${stdenv.cc.targetPrefix}cpp -nostdinc -x assembler-with-cpp ${cppDtSearchFlags} -undef -D__DTS__ -o dtb.tmp ${dts}
|
2023-03-03 00:01:26 +01:00
|
|
|
echo '/{ chosen { bootargs = ${builtins.toJSON cmdline}; }; };' >> dtb.tmp
|
2022-10-07 01:19:29 +02:00
|
|
|
dtc ${dtcSearchFlags} -I dts -O dtb -o $out dtb.tmp
|
|
|
|
test -e $out
|
|
|
|
'';
|
|
|
|
}
|