1{ stdenv, lib, fetchgit, flex, bison, pkgconfig, which
2, pythonSupport ? false, python, swig
3}:
4
5stdenv.mkDerivation rec {
6 pname = "dtc";
7 version = "1.6.0";
8
9 src = fetchgit {
10 url = "https://git.kernel.org/pub/scm/utils/dtc/dtc.git";
11 rev = "refs/tags/v${version}";
12 sha256 = "0li992wwd7kgy71bikanqky49y4hq3p3vx35p2hvyxy1k0wfy7i8";
13 };
14
15 nativeBuildInputs = [ flex bison pkgconfig which ] ++ lib.optionals pythonSupport [ python swig ];
16 buildInputs = lib.optionals pythonSupport [ python ];
17
18 postPatch = ''
19 patchShebangs pylibfdt/
20 '';
21
22 makeFlags = [ "PYTHON=python" ];
23 installFlags = [ "INSTALL=install" "PREFIX=$(out)" "SETUP_PREFIX=$(out)" ];
24
25 meta = with lib; {
26 description = "Device Tree Compiler";
27 homepage = "https://git.kernel.org/cgit/utils/dtc/dtc.git";
28 license = licenses.gpl2; # dtc itself is GPLv2, libfdt is dual GPL/BSD
29 maintainers = [ maintainers.dezgeg ];
30 platforms = platforms.unix;
31 };
32}