detect arch in kernel and uimage

also move kernel builder to pkgs/

FIXME we need to straighten out the mess in calling
dtb.nix/uimage.nix
This commit is contained in:
Daniel Barlow 2023-09-20 17:57:17 +01:00
parent f1c04c7979
commit 4f29bdd3ed
6 changed files with 28 additions and 9 deletions

23
pkgs/kernel/dtb.nix Normal file
View file

@ -0,0 +1,23 @@
{
stdenv
, dtc
, lib
}:
{ dts
, includes
, commandLine
}:let
cppDtSearchFlags = builtins.concatStringsSep " " (map (f: "-I${f}") includes);
dtcSearchFlags = builtins.concatStringsSep " " (map (f: "-i${f}") includes);
cmdline = lib.concatStringsSep " " commandLine;
in stdenv.mkDerivation {
name = "dtb";
phases = [ "buildPhase" ];
nativeBuildInputs = [ dtc ];
buildPhase = ''
${stdenv.cc.targetPrefix}cpp -nostdinc -x assembler-with-cpp ${cppDtSearchFlags} -undef -D__DTS__ -o dtb.tmp ${dts}
echo '/{ chosen { bootargs = ${builtins.toJSON cmdline}; }; };' >> dtb.tmp
dtc ${dtcSearchFlags} -I dts -O dtb -o $out dtb.tmp
test -e $out
'';
}