diff options
author | ktrinh <ktrinh@anduril.com> | 2023-09-24 11:58:13 -0700 |
---|---|---|
committer | ktrinh <ktrinh@anduril.com> | 2023-09-24 11:58:13 -0700 |
commit | 8da771560c5d664f4de452fb901a1eb2c7507382 (patch) | |
tree | 22e44639adc196c6647a8123eeea365e4f77461d /pkgs/os-specific/linux/device-tree/default.nix | |
parent | 48516a891d020801bc5304375739d2604400c741 (diff) | |
download | nixpkgs-8da771560c5d664f4de452fb901a1eb2c7507382.tar nixpkgs-8da771560c5d664f4de452fb901a1eb2c7507382.tar.gz nixpkgs-8da771560c5d664f4de452fb901a1eb2c7507382.tar.bz2 nixpkgs-8da771560c5d664f4de452fb901a1eb2c7507382.tar.lz nixpkgs-8da771560c5d664f4de452fb901a1eb2c7507382.tar.xz nixpkgs-8da771560c5d664f4de452fb901a1eb2c7507382.tar.zst nixpkgs-8da771560c5d664f4de452fb901a1eb2c7507382.zip |
nixos/device-tree: Allow custom dtbSource and expose compileDts
Diffstat (limited to 'pkgs/os-specific/linux/device-tree/default.nix')
-rw-r--r-- | pkgs/os-specific/linux/device-tree/default.nix | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/pkgs/os-specific/linux/device-tree/default.nix b/pkgs/os-specific/linux/device-tree/default.nix index fb8e92f2330..1a50d799b4b 100644 --- a/pkgs/os-specific/linux/device-tree/default.nix +++ b/pkgs/os-specific/linux/device-tree/default.nix @@ -1,6 +1,29 @@ -{ lib, stdenvNoCC, dtc }: +{ lib, stdenv, stdenvNoCC, dtc }: with lib; { + # Compile single Device Tree overlay source + # file (.dts) into its compiled variant (.dtb) + compileDTS = ({ + name, + dtsFile, + includePaths ? [], + extraPreprocessorFlags ? [] + }: stdenv.mkDerivation { + inherit name; + + nativeBuildInputs = [ dtc ]; + + buildCommand = + let + includeFlagsStr = lib.concatMapStringsSep " " (includePath: "-I${includePath}") includePaths; + extraPreprocessorFlagsStr = lib.concatStringsSep " " extraPreprocessorFlags; + in + '' + $CC -E -nostdinc ${includeFlagsStr} -undef -D__DTS__ -x assembler-with-cpp ${extraPreprocessorFlagsStr} ${dtsFile} | \ + dtc -I dts -O dtb -@ -o $out + ''; + }); + applyOverlays = (base: overlays': stdenvNoCC.mkDerivation { name = "device-tree-overlays"; nativeBuildInputs = [ dtc ]; |