maintainers: remove email for amuckstot30 (#360059)
[NixPkgs.git] / pkgs / os-specific / linux / device-tree / default.nix
blobb8c71cc5a8ae33d79a3baad2302e3d74d35eec48
1 { lib, stdenv, stdenvNoCC, dtc, writers, python3 }:
4   # Compile single Device Tree overlay source
5   # file (.dts) into its compiled variant (.dtb)
6   compileDTS = ({
7     name,
8     dtsFile,
9     includePaths ? [],
10     extraPreprocessorFlags ? []
11   }: stdenv.mkDerivation {
12     inherit name;
14     nativeBuildInputs = [ dtc ];
16     buildCommand =
17       let
18         includeFlagsStr = lib.concatMapStringsSep " " (includePath: "-I${includePath}") includePaths;
19         extraPreprocessorFlagsStr = lib.concatStringsSep " " extraPreprocessorFlags;
20       in
21       ''
22         $CC -E -nostdinc ${includeFlagsStr} -undef -D__DTS__ -x assembler-with-cpp ${extraPreprocessorFlagsStr} ${dtsFile} | \
23         dtc -I dts -O dtb -@ -o $out
24       '';
25   });
27   applyOverlays = (base: overlays': stdenvNoCC.mkDerivation {
28     name = "device-tree-overlays";
29     nativeBuildInputs = [
30       (python3.pythonOnBuildForHost.withPackages(ps: [ps.libfdt]))
31     ];
32     buildCommand = ''
33       python ${./apply_overlays.py} --source ${base} --destination $out --overlays ${writers.writeJSON "overlays.json" overlays'}
34     '';
35   });