Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 21.05 100 lines 3.8 kB view raw
1{ stdenv, lib, fetchurl, fetchpatch 2, zlib, xz, libintl, python, gettext, ncurses, findXMLCatalogs 3, pythonSupport ? enableShared && stdenv.buildPlatform == stdenv.hostPlatform 4, icuSupport ? false, icu ? null 5, enableShared ? stdenv.hostPlatform.libc != "msvcrt" 6, enableStatic ? !enableShared 7}: 8 9stdenv.mkDerivation rec { 10 pname = "libxml2"; 11 version = "2.9.12"; 12 13 src = fetchurl { 14 url = "http://xmlsoft.org/sources/${pname}-${version}.tar.gz"; 15 sha256 = "14hxwzmf5xqppx77z7i0ni9lpzg1a84dqpf8j8l1fvy570g6imn8"; 16 }; 17 patches = [ 18 # Upstream bugs: 19 # https://bugzilla.gnome.org/show_bug.cgi?id=789714 20 # https://gitlab.gnome.org/GNOME/libxml2/issues/64 21 # Patch from https://bugzilla.opensuse.org/show_bug.cgi?id=1065270 , 22 # but only the UTF-8 part. 23 # Can also be mitigated by fixing malformed XML inputs, such as in 24 # https://gitlab.gnome.org/GNOME/gnumeric/merge_requests/3 . 25 # Other discussion: 26 # https://github.com/itstool/itstool/issues/22 27 # https://github.com/NixOS/nixpkgs/pull/63174 28 # https://github.com/NixOS/nixpkgs/pull/72342 29 ./utf8-xmlErrorFuncHandler.patch 30 31 # Work around lxml API misuse. 32 # https://gitlab.gnome.org/GNOME/libxml2/issues/255 33 (fetchpatch { 34 url = "https://gitlab.gnome.org/GNOME/libxml2/commit/85b1792e37b131e7a51af98a37f92472e8de5f3f.patch"; 35 sha256 = "epqlNs2S0Zczox3KyCB6R2aJKh87lXydlZ0x6tLHweE="; 36 }) 37 ]; 38 39 outputs = [ "bin" "dev" "out" "man" "doc" ] 40 ++ lib.optional pythonSupport "py" 41 ++ lib.optional (enableStatic && enableShared) "static"; 42 43 buildInputs = lib.optional pythonSupport python 44 ++ lib.optional (pythonSupport && python?isPy2 && python.isPy2) gettext 45 ++ lib.optional (pythonSupport && python?isPy3 && python.isPy3) ncurses 46 ++ lib.optional (stdenv.isDarwin && 47 pythonSupport && python?isPy2 && python.isPy2) libintl 48 # Libxml2 has an optional dependency on liblzma. However, on impure 49 # platforms, it may end up using that from /usr/lib, and thus lack a 50 # RUNPATH for that, leading to undefined references for its users. 51 ++ lib.optional stdenv.isFreeBSD xz; 52 53 propagatedBuildInputs = [ zlib findXMLCatalogs ] ++ lib.optional icuSupport icu; 54 55 configureFlags = [ 56 "--exec_prefix=$dev" 57 (lib.enableFeature enableStatic "static") 58 (lib.enableFeature enableShared "shared") 59 (lib.withFeature icuSupport "icu") 60 (lib.withFeatureAs pythonSupport "python" python) 61 ]; 62 63 preConfigure = lib.optionalString (lib.versionAtLeast stdenv.hostPlatform.darwinMinVersion "11") '' 64 MACOSX_DEPLOYMENT_TARGET=10.16 65 ''; 66 67 enableParallelBuilding = true; 68 69 # disable test that's problematic with newer pythons: see 70 # https://mail.gnome.org/archives/xml/2017-August/msg00014.html 71 preCheck = lib.optionalString (pythonSupport && !(python?pythonOlder && python.pythonOlder "3.5")) '' 72 echo "" > python/tests/tstLastError.py 73 ''; 74 75 doCheck = (stdenv.hostPlatform == stdenv.buildPlatform) && !stdenv.isDarwin && 76 stdenv.hostPlatform.libc != "musl"; 77 78 preInstall = lib.optionalString pythonSupport 79 ''substituteInPlace python/libxml2mod.la --replace "${python}" "$py"''; 80 installFlags = lib.optional pythonSupport 81 "pythondir=\"${placeholder "py"}/lib/${python.libPrefix}/site-packages\""; 82 83 postFixup = '' 84 moveToOutput bin/xml2-config "$dev" 85 moveToOutput lib/xml2Conf.sh "$dev" 86 moveToOutput share/man/man1 "$bin" 87 '' + lib.optionalString (enableStatic && enableShared) '' 88 moveToOutput lib/libxml2.a "$static" 89 ''; 90 91 passthru = { inherit version; pythonSupport = pythonSupport; }; 92 93 meta = { 94 homepage = "http://xmlsoft.org/"; 95 description = "An XML parsing library for C"; 96 license = lib.licenses.mit; 97 platforms = lib.platforms.all; 98 maintainers = [ lib.maintainers.eelco ]; 99 }; 100}