dtb.nix (675B)
1 { 2 stdenv 3 , dtc 4 , lib 5 }: 6 { dts 7 , includes 8 , commandLine 9 }:let 10 cppDtSearchFlags = builtins.concatStringsSep " " (map (f: "-I${f}") includes); 11 dtcSearchFlags = builtins.concatStringsSep " " (map (f: "-i${f}") includes); 12 cmdline = lib.concatStringsSep " " commandLine; 13 in stdenv.mkDerivation { 14 name = "dtb"; 15 phases = [ "buildPhase" ]; 16 nativeBuildInputs = [ dtc ]; 17 buildPhase = '' 18 ${stdenv.cc.targetPrefix}cpp -nostdinc -x assembler-with-cpp ${cppDtSearchFlags} -undef -D__DTS__ -o dtb.tmp ${dts} 19 echo '/{ chosen { bootargs = ${builtins.toJSON cmdline}; }; };' >> dtb.tmp 20 dtc ${dtcSearchFlags} -I dts -O dtb -o $out dtb.tmp 21 test -e $out 22 ''; 23 }