nixpkgs/pkgs/development/libraries/libxml2/default.nix

82 lines
2.9 KiB
Nix
Raw Normal View History

{ stdenv, lib, fetchurl
, zlib, xz, python, ncurses, findXMLCatalogs
, pythonSupport ? stdenv.buildPlatform == stdenv.hostPlatform
2017-02-11 04:48:28 +00:00
, icuSupport ? false, icu ? null
, enableShared ? stdenv.hostPlatform.libc != "msvcrt"
2018-07-23 19:37:08 +00:00
, enableStatic ? !enableShared,
2017-02-11 04:48:28 +00:00
}:
stdenv.mkDerivation rec {
pname = "libxml2";
2019-01-03 20:34:10 +00:00
version = "2.9.9";
src = fetchurl {
url = "http://xmlsoft.org/sources/${pname}-${version}.tar.gz";
2019-01-03 20:34:10 +00:00
sha256 = "0wd881jzvqayx0ihzba29jl80k06xj9ywp16kxacdqs3064p1ywl";
};
patches = [
# Upstream bugs:
# https://bugzilla.gnome.org/show_bug.cgi?id=789714
# https://gitlab.gnome.org/GNOME/libxml2/issues/64
# Patch from https://bugzilla.opensuse.org/show_bug.cgi?id=1065270 ,
# but only the UTF-8 part.
# Can also be mitigated by fixing malformed XML inputs, such as in
# https://gitlab.gnome.org/GNOME/gnumeric/merge_requests/3 .
# Other discussion:
# https://github.com/itstool/itstool/issues/22
# https://github.com/NixOS/nixpkgs/pull/63174
# https://github.com/NixOS/nixpkgs/pull/72342
./utf8-xmlErrorFuncHandler.patch
];
outputs = [ "bin" "dev" "out" "man" "doc" ]
++ lib.optional pythonSupport "py"
++ lib.optional (enableStatic && enableShared) "static";
propagatedBuildOutputs = "out bin" + lib.optionalString pythonSupport " py";
buildInputs = lib.optional pythonSupport python
2018-10-17 07:35:45 +00:00
++ lib.optional (pythonSupport && python?isPy3 && python.isPy3) ncurses
# Libxml2 has an optional dependency on liblzma. However, on impure
# platforms, it may end up using that from /usr/lib, and thus lack a
# RUNPATH for that, leading to undefined references for its users.
++ lib.optional stdenv.isFreeBSD xz;
2017-02-11 03:15:41 +00:00
propagatedBuildInputs = [ zlib findXMLCatalogs ] ++ lib.optional icuSupport icu;
2018-07-25 00:13:43 +00:00
configureFlags = [
"--exec_prefix=$dev"
(lib.enableFeature enableStatic "static")
(lib.enableFeature enableShared "shared")
(lib.withFeature icuSupport "icu")
(lib.withFeatureAs pythonSupport "python" python)
];
enableParallelBuilding = true;
2018-01-12 08:27:33 +00:00
doCheck = (stdenv.hostPlatform == stdenv.buildPlatform) && !stdenv.isDarwin &&
stdenv.hostPlatform.libc != "musl";
preInstall = lib.optionalString pythonSupport
''substituteInPlace python/libxml2mod.la --replace "${python}" "$py"'';
installFlags = lib.optionalString pythonSupport
''pythondir="$(py)/lib/${python.libPrefix}/site-packages"'';
postFixup = ''
moveToOutput bin/xml2-config "$dev"
moveToOutput lib/xml2Conf.sh "$dev"
moveToOutput share/man/man1 "$bin"
'' + lib.optionalString (enableStatic && enableShared) ''
moveToOutput lib/libxml2.a "$static"
'';
passthru = { inherit version; pythonSupport = pythonSupport; };
meta = {
homepage = http://xmlsoft.org/;
description = "An XML parsing library for C";
license = lib.licenses.mit;
platforms = lib.platforms.all;
maintainers = [ lib.maintainers.eelco ];
};
}