liminix-fork/kernel/dtb.nix
Daniel Barlow f1b7780537 speed up kernel build
by having two separate derivations for patching the kernel source tree
and building it, we have to copy said source trees from one store
location to another which takes non-neglible time on spinning rust
(literally minutes on my machine). Replace with a single derivation
that can do more things on one tree in-place
2022-10-19 17:34:22 +01:00

19 lines
525 B
Nix

{
stdenv
, dtc
}:
{ dts
, includes
}:let
cppDtSearchFlags = builtins.concatStringsSep " " (map (f: "-I${f}") includes);
dtcSearchFlags = builtins.concatStringsSep " " (map (f: "-i${f}") includes);
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}
dtc ${dtcSearchFlags} -I dts -O dtb -o $out dtb.tmp
test -e $out
'';
}