nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ stdenv, lib, fetchurl, fetchpatch
2, zlib, xz, python2, ncurses, findXMLCatalogs
3, pythonSupport ? stdenv.buildPlatform == stdenv.hostPlatform
4, icuSupport ? false, icu ? null
5, enableShared ? stdenv.hostPlatform.libc != "msvcrt"
6, enableStatic ? !enableShared,
7}:
8
9let
10 python = python2;
11
12in stdenv.mkDerivation rec {
13 name = "libxml2-${version}";
14 version = "2.9.9";
15
16 src = fetchurl {
17 url = "http://xmlsoft.org/sources/${name}.tar.gz";
18 sha256 = "0wd881jzvqayx0ihzba29jl80k06xj9ywp16kxacdqs3064p1ywl";
19 };
20
21 outputs = [ "bin" "dev" "out" "man" "doc" ]
22 ++ lib.optional pythonSupport "py"
23 ++ lib.optional (enableStatic && enableShared) "static";
24 propagatedBuildOutputs = "out bin" + lib.optionalString pythonSupport " py";
25
26 buildInputs = lib.optional pythonSupport python
27 ++ lib.optional (pythonSupport && python?isPy3 && python.isPy3) ncurses
28 # Libxml2 has an optional dependency on liblzma. However, on impure
29 # platforms, it may end up using that from /usr/lib, and thus lack a
30 # RUNPATH for that, leading to undefined references for its users.
31 ++ lib.optional stdenv.isFreeBSD xz;
32
33 propagatedBuildInputs = [ zlib findXMLCatalogs ] ++ lib.optional icuSupport icu;
34
35 configureFlags = [
36 "--exec_prefix=$dev"
37 (lib.enableFeature enableStatic "static")
38 (lib.enableFeature enableShared "shared")
39 (lib.withFeature icuSupport "icu")
40 (lib.withFeatureAs pythonSupport "python" python)
41 ];
42
43 enableParallelBuilding = true;
44
45 doCheck = (stdenv.hostPlatform == stdenv.buildPlatform) && !stdenv.isDarwin &&
46 stdenv.hostPlatform.libc != "musl";
47
48 preInstall = lib.optionalString pythonSupport
49 ''substituteInPlace python/libxml2mod.la --replace "${python}" "$py"'';
50 installFlags = lib.optionalString pythonSupport
51 ''pythondir="$(py)/lib/${python.libPrefix}/site-packages"'';
52
53 postFixup = ''
54 moveToOutput bin/xml2-config "$dev"
55 moveToOutput lib/xml2Conf.sh "$dev"
56 moveToOutput share/man/man1 "$bin"
57 '' + lib.optionalString (enableStatic && enableShared) ''
58 moveToOutput lib/libxml2.a "$static"
59 '';
60
61 passthru = { inherit version; pythonSupport = pythonSupport; };
62
63 meta = {
64 homepage = http://xmlsoft.org/;
65 description = "An XML parsing library for C";
66 license = lib.licenses.mit;
67 platforms = lib.platforms.all;
68 maintainers = [ lib.maintainers.eelco ];
69 };
70}