Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at flake-libs 153 lines 4.0 kB view raw
1{ 2 stdenv, 3 lib, 4 fetchurl, 5 pkg-config, 6 autoreconfHook, 7 libintl, 8 python, 9 gettext, 10 ncurses, 11 findXMLCatalogs, 12 libiconv, 13 # Python limits cross-compilation to an allowlist of host OSes. 14 # https://github.com/python/cpython/blob/dfad678d7024ab86d265d84ed45999e031a03691/configure.ac#L534-L562 15 pythonSupport ? 16 enableShared 17 && ( 18 stdenv.hostPlatform == stdenv.buildPlatform 19 || stdenv.hostPlatform.isCygwin 20 || stdenv.hostPlatform.isLinux 21 || stdenv.hostPlatform.isWasi 22 ), 23 icuSupport ? false, 24 icu, 25 zlibSupport ? false, 26 zlib, 27 enableShared ? !stdenv.hostPlatform.isMinGW && !stdenv.hostPlatform.isStatic, 28 enableStatic ? !enableShared, 29 gnome, 30 testers, 31 enableHttp ? false, 32}: 33 34stdenv.mkDerivation (finalAttrs: { 35 pname = "libxml2"; 36 version = "2.13.8"; 37 38 outputs = 39 [ 40 "bin" 41 "dev" 42 "out" 43 "devdoc" 44 ] 45 ++ lib.optional pythonSupport "py" 46 ++ lib.optional (enableStatic && enableShared) "static"; 47 outputMan = "bin"; 48 49 src = fetchurl { 50 url = "mirror://gnome/sources/libxml2/${lib.versions.majorMinor finalAttrs.version}/libxml2-${finalAttrs.version}.tar.xz"; 51 hash = "sha256-J3KUyzMRmrcbK8gfL0Rem8lDW4k60VuyzSsOhZoO6Eo="; 52 }; 53 54 strictDeps = true; 55 56 nativeBuildInputs = [ 57 pkg-config 58 autoreconfHook 59 ]; 60 61 buildInputs = 62 lib.optionals pythonSupport [ 63 python 64 ] 65 ++ lib.optionals (pythonSupport && python ? isPy2 && python.isPy2) [ 66 gettext 67 ] 68 ++ lib.optionals (pythonSupport && python ? isPy3 && python.isPy3) [ 69 ncurses 70 ] 71 ++ lib.optionals (stdenv.hostPlatform.isDarwin && pythonSupport && python ? isPy2 && python.isPy2) [ 72 libintl 73 ] 74 ++ lib.optionals zlibSupport [ 75 zlib 76 ]; 77 78 propagatedBuildInputs = 79 [ 80 findXMLCatalogs 81 ] 82 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 83 libiconv 84 ] 85 ++ lib.optionals icuSupport [ 86 icu 87 ]; 88 89 configureFlags = 90 [ 91 "--exec-prefix=${placeholder "dev"}" 92 (lib.enableFeature enableStatic "static") 93 (lib.enableFeature enableShared "shared") 94 (lib.withFeature icuSupport "icu") 95 (lib.withFeature pythonSupport "python") 96 (lib.optionalString pythonSupport "PYTHON=${python.pythonOnBuildForHost.interpreter}") 97 ] 98 # avoid rebuilds, can be merged into list in version bumps 99 ++ lib.optional enableHttp "--with-http" 100 ++ lib.optional zlibSupport "--with-zlib"; 101 102 installFlags = lib.optionals pythonSupport [ 103 "pythondir=\"${placeholder "py"}/${python.sitePackages}\"" 104 "pyexecdir=\"${placeholder "py"}/${python.sitePackages}\"" 105 ]; 106 107 enableParallelBuilding = true; 108 109 doCheck = (stdenv.hostPlatform == stdenv.buildPlatform) && stdenv.hostPlatform.libc != "musl"; 110 preCheck = lib.optional stdenv.hostPlatform.isDarwin '' 111 export DYLD_LIBRARY_PATH="$PWD/.libs:$DYLD_LIBRARY_PATH" 112 ''; 113 114 preConfigure = lib.optionalString (lib.versionAtLeast stdenv.hostPlatform.darwinMinVersion "11") '' 115 MACOSX_DEPLOYMENT_TARGET=10.16 116 ''; 117 118 preInstall = lib.optionalString pythonSupport '' 119 substituteInPlace python/libxml2mod.la --replace-fail "$dev/${python.sitePackages}" "$py/${python.sitePackages}" 120 ''; 121 122 postFixup = 123 '' 124 moveToOutput bin/xml2-config "$dev" 125 moveToOutput lib/xml2Conf.sh "$dev" 126 '' 127 + lib.optionalString (enableStatic && enableShared) '' 128 moveToOutput lib/libxml2.a "$static" 129 ''; 130 131 passthru = { 132 inherit pythonSupport; 133 134 updateScript = gnome.updateScript { 135 packageName = "libxml2"; 136 versionPolicy = "none"; 137 }; 138 tests = { 139 pkg-config = testers.hasPkgConfigModules { 140 package = finalAttrs.finalPackage; 141 }; 142 }; 143 }; 144 145 meta = with lib; { 146 homepage = "https://gitlab.gnome.org/GNOME/libxml2"; 147 description = "XML parsing library for C"; 148 license = licenses.mit; 149 platforms = platforms.all; 150 maintainers = with maintainers; [ jtojnar ]; 151 pkgConfigModules = [ "libxml-2.0" ]; 152 }; 153})