|
| 1 | +{ stdenv |
| 2 | +, lib |
| 3 | +, fetchurl |
| 4 | +, pkg-config |
| 5 | +, autoreconfHook |
| 6 | +, libintl |
| 7 | +, python3 |
| 8 | +, gettext |
| 9 | +, ncurses |
| 10 | +, findXMLCatalogs |
| 11 | +, libiconv |
| 12 | +, pythonSupport ? enableShared && |
| 13 | + (stdenv.hostPlatform == stdenv.buildPlatform || stdenv.hostPlatform.isCygwin || stdenv.hostPlatform.isLinux || stdenv.hostPlatform.isWasi) |
| 14 | +, icuSupport ? false |
| 15 | +, icu |
| 16 | +, enableShared ? !stdenv.hostPlatform.isMinGW && !stdenv.hostPlatform.isStatic |
| 17 | +, enableStatic ? !enableShared |
| 18 | +, gnome |
| 19 | +, testers |
| 20 | +, enableHttp ? false |
| 21 | +, python ? null # Add this line to accept 'python' as an argument |
| 22 | +}: |
| 23 | + |
| 24 | +let |
| 25 | + # If 'python' is provided, use it; otherwise use 'python3' |
| 26 | + pythonEnv = python3; |
| 27 | +in |
| 28 | + |
| 29 | +stdenv.mkDerivation (finalAttrs: { |
| 30 | + pname = "libxml2"; |
| 31 | + version = "2.13.3"; |
| 32 | + |
| 33 | + outputs = [ "bin" "dev" "out" "devdoc" ] |
| 34 | + ++ lib.optional pythonSupport "py" |
| 35 | + ++ lib.optional (enableStatic && enableShared) "static"; |
| 36 | + outputMan = "bin"; |
| 37 | + |
| 38 | + src = fetchurl { |
| 39 | + url = "mirror://gnome/sources/libxml2/${lib.versions.majorMinor finalAttrs.version}/libxml2-${finalAttrs.version}.tar.xz"; |
| 40 | + hash = "sha256-CAXXwYDPCcqtcWZsekWKdPBBVhpTKQJFTaUEfYOUgTg="; |
| 41 | + }; |
| 42 | + |
| 43 | + strictDeps = true; |
| 44 | + |
| 45 | + nativeBuildInputs = [ |
| 46 | + pkg-config |
| 47 | + autoreconfHook |
| 48 | + ]; |
| 49 | + |
| 50 | + buildInputs = lib.optionals pythonSupport [ |
| 51 | + pythonEnv |
| 52 | + ncurses |
| 53 | + ]; |
| 54 | + |
| 55 | + propagatedBuildInputs = [ |
| 56 | + findXMLCatalogs |
| 57 | + ] ++ lib.optionals stdenv.isDarwin [ |
| 58 | + libiconv |
| 59 | + ] ++ lib.optionals icuSupport [ |
| 60 | + icu |
| 61 | + ]; |
| 62 | + |
| 63 | + configureFlags = [ |
| 64 | + "--exec-prefix=${placeholder "dev"}" |
| 65 | + (lib.enableFeature enableStatic "static") |
| 66 | + (lib.enableFeature enableShared "shared") |
| 67 | + (lib.withFeature icuSupport "icu") |
| 68 | + (lib.withFeature pythonSupport "python") |
| 69 | + (lib.optionalString pythonSupport "PYTHON=${pythonEnv.pythonOnBuildForHost.interpreter}") |
| 70 | + ] ++ lib.optional enableHttp "--with-http"; |
| 71 | + |
| 72 | + installFlags = lib.optionals pythonSupport [ |
| 73 | + "pythondir=\"${placeholder "py"}/${pythonEnv.sitePackages}\"" |
| 74 | + "pyexecdir=\"${placeholder "py"}/${pythonEnv.sitePackages}\"" |
| 75 | + ]; |
| 76 | + |
| 77 | + enableParallelBuilding = true; |
| 78 | + |
| 79 | + doCheck = |
| 80 | + (stdenv.hostPlatform == stdenv.buildPlatform) && |
| 81 | + stdenv.hostPlatform.libc != "musl"; |
| 82 | + preCheck = lib.optional stdenv.isDarwin '' |
| 83 | + export DYLD_LIBRARY_PATH="$PWD/.libs:$DYLD_LIBRARY_PATH" |
| 84 | + ''; |
| 85 | + |
| 86 | + preConfigure = lib.optionalString (lib.versionAtLeast stdenv.hostPlatform.darwinMinVersion "11") '' |
| 87 | + MACOSX_DEPLOYMENT_TARGET=10.16 |
| 88 | + ''; |
| 89 | + |
| 90 | + preInstall = lib.optionalString pythonSupport '' |
| 91 | + substituteInPlace python/libxml2mod.la --replace-fail "$dev/${pythonEnv.sitePackages}" "$py/${pythonEnv.sitePackages}" |
| 92 | + ''; |
| 93 | + |
| 94 | + postFixup = '' |
| 95 | + moveToOutput bin/xml2-config "$dev" |
| 96 | + moveToOutput lib/xml2Conf.sh "$dev" |
| 97 | + '' + lib.optionalString (enableStatic && enableShared) '' |
| 98 | + moveToOutput lib/libxml2.a "$static" |
| 99 | + ''; |
| 100 | + |
| 101 | + passthru = { |
| 102 | + inherit pythonSupport; |
| 103 | + |
| 104 | + updateScript = gnome.updateScript { |
| 105 | + packageName = "libxml2"; |
| 106 | + versionPolicy = "none"; |
| 107 | + }; |
| 108 | + tests = { |
| 109 | + pkg-config = testers.hasPkgConfigModules { |
| 110 | + package = finalAttrs.finalPackage; |
| 111 | + }; |
| 112 | + }; |
| 113 | + }; |
| 114 | + |
| 115 | + meta = with lib; { |
| 116 | + homepage = "https://gitlab.gnome.org/GNOME/libxml2"; |
| 117 | + description = "XML parsing library for C"; |
| 118 | + license = licenses.mit; |
| 119 | + platforms = platforms.all; |
| 120 | + maintainers = with maintainers; [ jtojnar ]; |
| 121 | + pkgConfigModules = [ "libxml-2.0" ]; |
| 122 | + }; |
| 123 | +}) |
0 commit comments