Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 24.05-beta 132 lines 3.8 kB view raw
1{ stdenv 2, lib 3, fetchurl 4, zlib 5, pkg-config 6, autoreconfHook 7, xz 8, libintl 9, python 10, gettext 11, ncurses 12, findXMLCatalogs 13, libiconv 14# Python limits cross-compilation to an allowlist of host OSes. 15# https://github.com/python/cpython/blob/dfad678d7024ab86d265d84ed45999e031a03691/configure.ac#L534-L562 16, pythonSupport ? enableShared && 17 (stdenv.hostPlatform == stdenv.buildPlatform || stdenv.hostPlatform.isCygwin || stdenv.hostPlatform.isLinux || stdenv.hostPlatform.isWasi) 18, icuSupport ? false 19, icu 20, enableShared ? !stdenv.hostPlatform.isMinGW && !stdenv.hostPlatform.isStatic 21, enableStatic ? !enableShared 22, gnome 23, testers 24}: 25 26stdenv.mkDerivation (finalAttrs: rec { 27 pname = "libxml2"; 28 version = "2.12.7"; 29 30 outputs = [ "bin" "dev" "out" "doc" ] 31 ++ lib.optional pythonSupport "py" 32 ++ lib.optional (enableStatic && enableShared) "static"; 33 outputMan = "bin"; 34 35 src = fetchurl { 36 url = "mirror://gnome/sources/libxml2/${lib.versions.majorMinor version}/libxml2-${version}.tar.xz"; 37 hash = "sha256-JK54/xNjqXPm2L66lBp5RdoqwFbhm1OVautpJ/1s+1Y="; 38 }; 39 40 strictDeps = true; 41 42 nativeBuildInputs = [ 43 pkg-config 44 autoreconfHook 45 ]; 46 47 buildInputs = lib.optionals pythonSupport [ 48 python 49 ] ++ lib.optionals (pythonSupport && python?isPy2 && python.isPy2) [ 50 gettext 51 ] ++ lib.optionals (pythonSupport && python?isPy3 && python.isPy3) [ 52 ncurses 53 ] ++ lib.optionals (stdenv.isDarwin && pythonSupport && python?isPy2 && python.isPy2) [ 54 libintl 55 ] ++ lib.optionals stdenv.isFreeBSD [ 56 # Libxml2 has an optional dependency on liblzma. However, on impure 57 # platforms, it may end up using that from /usr/lib, and thus lack a 58 # RUNPATH for that, leading to undefined references for its users. 59 xz 60 ]; 61 62 propagatedBuildInputs = [ 63 zlib 64 findXMLCatalogs 65 ] ++ lib.optionals stdenv.isDarwin [ 66 libiconv 67 ] ++ lib.optionals icuSupport [ 68 icu 69 ]; 70 71 configureFlags = [ 72 "--exec-prefix=${placeholder "dev"}" 73 (lib.enableFeature enableStatic "static") 74 (lib.enableFeature enableShared "shared") 75 (lib.withFeature icuSupport "icu") 76 (lib.withFeature pythonSupport "python") 77 (lib.optionalString pythonSupport "PYTHON=${python.pythonOnBuildForHost.interpreter}") 78 ]; 79 80 installFlags = lib.optionals pythonSupport [ 81 "pythondir=\"${placeholder "py"}/${python.sitePackages}\"" 82 "pyexecdir=\"${placeholder "py"}/${python.sitePackages}\"" 83 ]; 84 85 enableParallelBuilding = true; 86 87 doCheck = 88 (stdenv.hostPlatform == stdenv.buildPlatform) && 89 stdenv.hostPlatform.libc != "musl"; 90 preCheck = lib.optional stdenv.isDarwin '' 91 export DYLD_LIBRARY_PATH="$PWD/.libs:$DYLD_LIBRARY_PATH" 92 ''; 93 94 preConfigure = lib.optionalString (lib.versionAtLeast stdenv.hostPlatform.darwinMinVersion "11") '' 95 MACOSX_DEPLOYMENT_TARGET=10.16 96 ''; 97 98 preInstall = lib.optionalString pythonSupport '' 99 substituteInPlace python/libxml2mod.la --replace "$dev/${python.sitePackages}" "$py/${python.sitePackages}" 100 ''; 101 102 postFixup = '' 103 moveToOutput bin/xml2-config "$dev" 104 moveToOutput lib/xml2Conf.sh "$dev" 105 '' + lib.optionalString (enableStatic && enableShared) '' 106 moveToOutput lib/libxml2.a "$static" 107 ''; 108 109 passthru = { 110 inherit version; 111 pythonSupport = pythonSupport; 112 113 updateScript = gnome.updateScript { 114 packageName = pname; 115 versionPolicy = "none"; 116 }; 117 tests = { 118 pkg-config = testers.hasPkgConfigModules { 119 package = finalAttrs.finalPackage; 120 }; 121 }; 122 }; 123 124 meta = with lib; { 125 homepage = "https://gitlab.gnome.org/GNOME/libxml2"; 126 description = "XML parsing library for C"; 127 license = licenses.mit; 128 platforms = platforms.all; 129 maintainers = with maintainers; [ eelco jtojnar ]; 130 pkgConfigModules = [ "libxml-2.0" ]; 131 }; 132})