Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at fix-function-merge 126 lines 3.5 kB view raw
1{ stdenv 2, lib 3, fetchzip 4, fetchpatch 5, meson 6, ninja 7, flex 8, bison 9, pkg-config 10, which 11, pythonSupport ? false 12, python ? null 13, swig 14, libyaml 15}: 16 17stdenv.mkDerivation (finalAttrs: { 18 pname = "dtc"; 19 version = "1.7.0"; 20 21 src = fetchzip { 22 url = "https://git.kernel.org/pub/scm/utils/dtc/dtc.git/snapshot/dtc-v${finalAttrs.version}.tar.gz"; 23 sha256 = "sha256-FMh3VvlY3fUK8fbd0M+aCmlUrmG9YegiOOQ7MOByffc="; 24 }; 25 26 # Big pile of backports. 27 # FIXME: remove all of these after next upstream release. 28 patches = let 29 fetchUpstreamPatch = { rev, hash }: fetchpatch { 30 name = "dtc-${rev}.patch"; 31 url = "https://git.kernel.org/pub/scm/utils/dtc/dtc.git/patch/?id=${rev}"; 32 inherit hash; 33 }; 34 in [ 35 # meson: Fix cell overflow tests when running from meson 36 (fetchUpstreamPatch { 37 rev = "32174a66efa4ad19fc6a2a6422e4af2ae4f055cb"; 38 hash = "sha256-C7OzwY0zq+2CV3SB5unI7Ill2M3deF7FXeQE3B/Kx2s="; 39 }) 40 41 # Use #ifdef NO_VALGRIND 42 (fetchUpstreamPatch { 43 rev = "41821821101ad8a9f83746b96b163e5bcbdbe804"; 44 hash = "sha256-7QEFDtap2DWbUGqtyT/RgJZJFldKB8oSubKiCtLZ0w4="; 45 }) 46 47 # dtc: Fix linker options so it also works in Darwin 48 (fetchUpstreamPatch { 49 rev = "71a8b8ef0adf01af4c78c739e04533a35c1dc89c"; 50 hash = "sha256-uLXL0Sjcn+bnMuF+A6PjUW1Rq6uNg1dQl58zbeYpP/U="; 51 }) 52 53 # meson: allow disabling tests 54 (fetchUpstreamPatch { 55 rev = "bdc5c8793a13abb8846d115b7923df87605d05bd"; 56 hash = "sha256-cO4f/jJX/pQL7kk4jpKUhsCVESW2ZuWaTr7z3BuvVkw="; 57 }) 58 59 # meson: fix installation with meson-python 60 (fetchUpstreamPatch { 61 rev = "3fbfdd08afd2a7a25b27433f6f5678c0fe694721"; 62 hash = "sha256-skK8m1s4xkK6x9AqzxiEK+1uMEmS27dBI1CdEXNFTfU="; 63 }) 64 65 # pylibfdt: fix get_mem_rsv for newer Python versions 66 (fetchUpstreamPatch { 67 rev = "822123856980f84562406cc7bd1d4d6c2b8bc184"; 68 hash = "sha256-IJpRgP3pP8Eewx2PNKxhXZdsnomz2AR6oOsun50qAms="; 69 }) 70 ]; 71 72 env.SETUPTOOLS_SCM_PRETEND_VERSION = finalAttrs.version; 73 74 nativeBuildInputs = [ 75 meson 76 ninja 77 flex 78 bison 79 pkg-config 80 which 81 ] ++ lib.optionals pythonSupport [ 82 python 83 python.pkgs.setuptools-scm 84 swig 85 ]; 86 87 buildInputs = [ libyaml ]; 88 89 postPatch = '' 90 patchShebangs setup.py 91 92 # meson.build: bump version to 1.7.0 93 substituteInPlace libfdt/meson.build \ 94 --replace "version: '1.6.0'," "version: '${finalAttrs.version}'," 95 substituteInPlace meson.build \ 96 --replace "version: '1.6.0'," "version: '${finalAttrs.version}'," 97 ''; 98 99 # Required for installation of Python library and is innocuous otherwise. 100 env.DESTDIR = "/"; 101 102 mesonAutoFeatures = "auto"; 103 mesonFlags = [ 104 (lib.mesonBool "static-build" stdenv.hostPlatform.isStatic) 105 (lib.mesonBool "tests" finalAttrs.finalPackage.doCheck) 106 ]; 107 108 doCheck = 109 # Checks are broken on aarch64 darwin 110 # https://github.com/NixOS/nixpkgs/pull/118700#issuecomment-885892436 111 !stdenv.isDarwin && 112 113 # we must explicitly disable this here so that mesonFlags receives 114 # `-Dtests=disabled`; without it meson will attempt to run 115 # hostPlatform binaries during the configurePhase. 116 (with stdenv; buildPlatform.canExecute hostPlatform); 117 118 meta = with lib; { 119 description = "Device Tree Compiler"; 120 homepage = "https://git.kernel.org/pub/scm/utils/dtc/dtc.git"; 121 license = licenses.gpl2Plus; # dtc itself is GPLv2, libfdt is dual GPL/BSD 122 maintainers = [ maintainers.dezgeg ]; 123 platforms = platforms.unix; 124 mainProgram = "dtc"; 125 }; 126})