at 23.05-pre 62 lines 1.7 kB view raw
1{ stdenv 2, lib 3, fetchgit 4, fetchpatch 5, flex 6, bison 7, pkg-config 8, which 9, pythonSupport ? false 10, python ? null 11, swig 12, libyaml 13}: 14 15stdenv.mkDerivation rec { 16 pname = "dtc"; 17 version = "1.6.1"; 18 19 src = fetchgit { 20 url = "https://git.kernel.org/pub/scm/utils/dtc/dtc.git"; 21 rev = "refs/tags/v${version}"; 22 sha256 = "sha256-gx9LG3U9etWhPxm7Ox7rOu9X5272qGeHqZtOe68zFs4="; 23 }; 24 25 patches = [ 26 # fix python 3.10 compatibility 27 # based on without requiring the setup.py rework 28 # https://git.kernel.org/pub/scm/utils/dtc/dtc.git/commit/?id=383e148b70a47ab15f97a19bb999d54f9c3e810f 29 ./python-3.10.patch 30 31 # fix dtc static building 32 ./0001-Depend-on-.a-instead-of-.so-when-building-static.patch 33 ]; 34 35 nativeBuildInputs = [ flex bison pkg-config which ] 36 ++ lib.optionals pythonSupport [ python swig ]; 37 38 buildInputs = [ libyaml ]; 39 40 postPatch = '' 41 patchShebangs pylibfdt/ 42 ''; 43 44 makeFlags = [ "PYTHON=python" "STATIC_BUILD=${toString stdenv.hostPlatform.isStatic}" ]; 45 installFlags = [ "INSTALL=install" "PREFIX=$(out)" "SETUP_PREFIX=$(out)" ]; 46 47 postFixup = lib.optionalString stdenv.isDarwin '' 48 install_name_tool -id $out/lib/libfdt.dylib $out/lib/libfdt-${version}.dylib 49 ''; 50 51 # Checks are broken on aarch64 darwin 52 # https://github.com/NixOS/nixpkgs/pull/118700#issuecomment-885892436 53 doCheck = !stdenv.isDarwin; 54 55 meta = with lib; { 56 description = "Device Tree Compiler"; 57 homepage = "https://git.kernel.org/pub/scm/utils/dtc/dtc.git"; 58 license = licenses.gpl2Plus; # dtc itself is GPLv2, libfdt is dual GPL/BSD 59 maintainers = [ maintainers.dezgeg ]; 60 platforms = platforms.unix; 61 }; 62}