nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at 22.05 133 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, pythonSupport ? enableShared && stdenv.buildPlatform == stdenv.hostPlatform 15, icuSupport ? false 16, icu 17, enableShared ? stdenv.hostPlatform.libc != "msvcrt" && !stdenv.hostPlatform.isStatic 18, enableStatic ? !enableShared 19, gnome 20}: 21 22stdenv.mkDerivation rec { 23 pname = "libxml2"; 24 version = "2.9.14"; 25 26 outputs = [ "bin" "dev" "out" "man" "doc" ] 27 ++ lib.optional pythonSupport "py" 28 ++ lib.optional (enableStatic && enableShared) "static"; 29 30 src = fetchurl { 31 url = "mirror://gnome/sources/${pname}/${lib.versions.majorMinor version}/${pname}-${version}.tar.xz"; 32 sha256 = "1vnzk33wfms348lgz9pvkq9li7jm44pvm73lbr3w1khwgljlmmv0"; 33 }; 34 35 patches = [ 36 # Upstream bugs: 37 # https://bugzilla.gnome.org/show_bug.cgi?id=789714 38 # https://gitlab.gnome.org/GNOME/libxml2/issues/64 39 # Patch from https://bugzilla.opensuse.org/show_bug.cgi?id=1065270 , 40 # but only the UTF-8 part. 41 # Can also be mitigated by fixing malformed XML inputs, such as in 42 # https://gitlab.gnome.org/GNOME/gnumeric/merge_requests/3 . 43 # Other discussion: 44 # https://github.com/itstool/itstool/issues/22 45 # https://github.com/NixOS/nixpkgs/pull/63174 46 # https://github.com/NixOS/nixpkgs/pull/72342 47 ./utf8-xmlErrorFuncHandler.patch 48 ]; 49 50 strictDeps = true; 51 52 nativeBuildInputs = [ 53 pkg-config 54 autoreconfHook 55 ]; 56 57 buildInputs = lib.optionals pythonSupport [ 58 python 59 ] ++ lib.optionals (pythonSupport && python?isPy2 && python.isPy2) [ 60 gettext 61 ] ++ lib.optionals (pythonSupport && python?isPy3 && python.isPy3) [ 62 ncurses 63 ] ++ lib.optionals (stdenv.isDarwin && pythonSupport && python?isPy2 && python.isPy2) [ 64 libintl 65 ] ++ lib.optionals stdenv.isFreeBSD [ 66 # Libxml2 has an optional dependency on liblzma. However, on impure 67 # platforms, it may end up using that from /usr/lib, and thus lack a 68 # RUNPATH for that, leading to undefined references for its users. 69 xz 70 ]; 71 72 propagatedBuildInputs = [ 73 zlib 74 findXMLCatalogs 75 ] ++ lib.optionals stdenv.isDarwin [ 76 libiconv 77 ] ++ lib.optionals icuSupport [ 78 icu 79 ]; 80 81 configureFlags = [ 82 "--exec-prefix=${placeholder "dev"}" 83 (lib.enableFeature enableStatic "static") 84 (lib.enableFeature enableShared "shared") 85 (lib.withFeature icuSupport "icu") 86 (lib.withFeatureAs pythonSupport "python" python) 87 ]; 88 89 installFlags = lib.optionals pythonSupport [ 90 "pythondir=\"${placeholder "py"}/${python.sitePackages}\"" 91 ]; 92 93 enableParallelBuilding = true; 94 95 doCheck = 96 (stdenv.hostPlatform == stdenv.buildPlatform) && 97 !stdenv.isDarwin && 98 stdenv.hostPlatform.libc != "musl"; 99 100 preConfigure = lib.optionalString (lib.versionAtLeast stdenv.hostPlatform.darwinMinVersion "11") '' 101 MACOSX_DEPLOYMENT_TARGET=10.16 102 ''; 103 104 preInstall = lib.optionalString pythonSupport '' 105 substituteInPlace python/libxml2mod.la --replace "$dev/${python.sitePackages}" "$py/${python.sitePackages}" 106 ''; 107 108 postFixup = '' 109 moveToOutput bin/xml2-config "$dev" 110 moveToOutput lib/xml2Conf.sh "$dev" 111 moveToOutput share/man/man1 "$bin" 112 '' + lib.optionalString (enableStatic && enableShared) '' 113 moveToOutput lib/libxml2.a "$static" 114 ''; 115 116 passthru = { 117 inherit version; 118 pythonSupport = pythonSupport; 119 120 updateScript = gnome.updateScript { 121 packageName = pname; 122 versionPolicy = "none"; 123 }; 124 }; 125 126 meta = with lib; { 127 homepage = "https://gitlab.gnome.org/GNOME/libxml2"; 128 description = "XML parsing library for C"; 129 license = licenses.mit; 130 platforms = platforms.all; 131 maintainers = with maintainers; [ eelco ]; 132 }; 133}