Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 49 lines 1.2 kB view raw
1{ 2 lib, 3 stdenv, 4 stdenvNoCC, 5 dtc, 6 writers, 7 python3, 8}: 9 10{ 11 # Compile single Device Tree overlay source 12 # file (.dts) into its compiled variant (.dtb) 13 compileDTS = ( 14 { 15 name, 16 dtsFile, 17 includePaths ? [ ], 18 extraPreprocessorFlags ? [ ], 19 }: 20 stdenv.mkDerivation { 21 inherit name; 22 23 nativeBuildInputs = [ dtc ]; 24 25 buildCommand = 26 let 27 includeFlagsStr = lib.concatMapStringsSep " " (includePath: "-I${includePath}") includePaths; 28 extraPreprocessorFlagsStr = lib.concatStringsSep " " extraPreprocessorFlags; 29 in 30 '' 31 $CC -E -nostdinc ${includeFlagsStr} -undef -D__DTS__ -x assembler-with-cpp ${extraPreprocessorFlagsStr} ${dtsFile} | \ 32 dtc -I dts -O dtb -@ -o $out 33 ''; 34 } 35 ); 36 37 applyOverlays = ( 38 base: overlays': 39 stdenvNoCC.mkDerivation { 40 name = "device-tree-overlays"; 41 nativeBuildInputs = [ 42 (python3.pythonOnBuildForHost.withPackages (ps: [ ps.libfdt ])) 43 ]; 44 buildCommand = '' 45 python ${./apply_overlays.py} --source ${base} --destination $out --overlays ${writers.writeJSON "overlays.json" overlays'} 46 ''; 47 } 48 ); 49}