Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 23.11-beta 146 lines 4.4 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}: 24 25let 26 # Newer versions fail with minimal python, probably because 27 # https://gitlab.gnome.org/GNOME/libxml2/-/commit/b706824b612adb2c8255819c9a55e78b52774a3c 28 # This case is encountered "temporarily" during stdenv bootstrapping on darwin. 29 # Beware that the old version has known security issues, so the final set shouldn't use it. 30 oldVer = python.pname == "python3-minimal"; 31in 32 assert oldVer -> stdenv.isDarwin; # reduce likelihood of using old libxml2 unintentionally 33 34let 35libxml = stdenv.mkDerivation rec { 36 pname = "libxml2"; 37 version = "2.11.5"; 38 39 outputs = [ "bin" "dev" "out" "doc" ] 40 ++ lib.optional pythonSupport "py" 41 ++ lib.optional (enableStatic && enableShared) "static"; 42 outputMan = "bin"; 43 44 src = fetchurl { 45 url = "mirror://gnome/sources/libxml2/${lib.versions.majorMinor version}/libxml2-${version}.tar.xz"; 46 sha256 = "NyeweMNg7Gn6hp3hS9b3XX7o02mHsHHmko1HIKKN86Y="; 47 }; 48 49 strictDeps = true; 50 51 nativeBuildInputs = [ 52 pkg-config 53 autoreconfHook 54 ]; 55 56 buildInputs = lib.optionals pythonSupport [ 57 python 58 ] ++ lib.optionals (pythonSupport && python?isPy2 && python.isPy2) [ 59 gettext 60 ] ++ lib.optionals (pythonSupport && python?isPy3 && python.isPy3) [ 61 ncurses 62 ] ++ lib.optionals (stdenv.isDarwin && pythonSupport && python?isPy2 && python.isPy2) [ 63 libintl 64 ] ++ lib.optionals stdenv.isFreeBSD [ 65 # Libxml2 has an optional dependency on liblzma. However, on impure 66 # platforms, it may end up using that from /usr/lib, and thus lack a 67 # RUNPATH for that, leading to undefined references for its users. 68 xz 69 ]; 70 71 propagatedBuildInputs = [ 72 zlib 73 findXMLCatalogs 74 ] ++ lib.optionals stdenv.isDarwin [ 75 libiconv 76 ] ++ lib.optionals icuSupport [ 77 icu 78 ]; 79 80 configureFlags = [ 81 "--exec-prefix=${placeholder "dev"}" 82 (lib.enableFeature enableStatic "static") 83 (lib.enableFeature enableShared "shared") 84 (lib.withFeature icuSupport "icu") 85 (lib.withFeature pythonSupport "python") 86 (lib.optionalString pythonSupport "PYTHON=${python.pythonOnBuildForHost.interpreter}") 87 ]; 88 89 installFlags = lib.optionals pythonSupport [ 90 "pythondir=\"${placeholder "py"}/${python.sitePackages}\"" 91 "pyexecdir=\"${placeholder "py"}/${python.sitePackages}\"" 92 ]; 93 94 enableParallelBuilding = true; 95 96 doCheck = 97 (stdenv.hostPlatform == stdenv.buildPlatform) && 98 stdenv.hostPlatform.libc != "musl"; 99 preCheck = lib.optional stdenv.isDarwin '' 100 export DYLD_LIBRARY_PATH="$PWD/.libs:$DYLD_LIBRARY_PATH" 101 ''; 102 103 preConfigure = lib.optionalString (lib.versionAtLeast stdenv.hostPlatform.darwinMinVersion "11") '' 104 MACOSX_DEPLOYMENT_TARGET=10.16 105 ''; 106 107 preInstall = lib.optionalString pythonSupport '' 108 substituteInPlace python/libxml2mod.la --replace "$dev/${python.sitePackages}" "$py/${python.sitePackages}" 109 ''; 110 111 postFixup = '' 112 moveToOutput bin/xml2-config "$dev" 113 moveToOutput lib/xml2Conf.sh "$dev" 114 '' + lib.optionalString (enableStatic && enableShared) '' 115 moveToOutput lib/libxml2.a "$static" 116 ''; 117 118 passthru = { 119 inherit version; 120 pythonSupport = pythonSupport; 121 122 updateScript = gnome.updateScript { 123 packageName = pname; 124 versionPolicy = "none"; 125 }; 126 }; 127 128 meta = with lib; { 129 homepage = "https://gitlab.gnome.org/GNOME/libxml2"; 130 description = "XML parsing library for C"; 131 license = licenses.mit; 132 platforms = platforms.all; 133 maintainers = with maintainers; [ eelco jtojnar ]; 134 }; 135}; 136in 137if oldVer then 138 libxml.overrideAttrs (attrs: rec { 139 version = "2.10.1"; 140 src = fetchurl { 141 url = "mirror://gnome/sources/libxml2/${lib.versions.majorMinor version}/libxml2-${version}.tar.xz"; 142 sha256 = "21a9e13cc7c4717a6c36268d0924f92c3f67a1ece6b7ff9d588958a6db9fb9d8"; 143 }; 144 }) 145else 146 libxml