1 { lib, stdenv, fetchurl, makeWrapper, apr, expat, gnused
2 , sslSupport ? true, openssl
3 , bdbSupport ? true, db
4 , ldapSupport ? !stdenv.isCygwin, openldap
6 , cyrus_sasl, autoreconfHook
9 assert sslSupport -> openssl != null;
10 assert bdbSupport -> db != null;
11 assert ldapSupport -> openldap != null;
15 stdenv.mkDerivation rec {
20 url = "mirror://apache/apr/${pname}-${version}.tar.bz2";
21 sha256 = "0nq3s1yn13vplgl6qfm09f7n0wm08malff9s59bqf9nid9xjzqfk";
24 patches = [ ./fix-libxcrypt-build.patch ]
25 ++ optional stdenv.isFreeBSD ./include-static-dependencies.patch;
27 NIX_CFLAGS_LINK = [ "-lcrypt" ];
29 outputs = [ "out" "dev" ];
32 nativeBuildInputs = [ makeWrapper ] ++ optional stdenv.isFreeBSD autoreconfHook;
34 configureFlags = [ "--with-apr=${apr.dev}" "--with-expat=${expat.dev}" ]
35 ++ optional (!stdenv.isCygwin) "--with-crypto"
36 ++ optional sslSupport "--with-openssl=${openssl.dev}"
37 ++ optional bdbSupport "--with-berkeley-db=${db.dev}"
38 ++ optional ldapSupport "--with-ldap=ldap"
39 ++ optionals stdenv.isCygwin
40 [ "--without-pgsql" "--without-sqlite2" "--without-sqlite3"
41 "--without-freetds" "--without-berkeley-db" "--without-crypto" ]
45 echo '#define APR_HAVE_CRYPT_H 1' >> confdefs.h
47 # For some reason, db version 6.9 is selected when cross-compiling.
48 # It's unclear as to why, it requires someone with more autotools / configure knowledge to go deeper into that.
49 # Always replacing the link flag with a generic link flag seems to help though, so let's do that for now.
50 lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform) ''
51 substituteInPlace Makefile \
52 --replace "-ldb-6.9" "-ldb"
55 propagatedBuildInputs = [ apr expat libiconv libxcrypt ]
56 ++ optional sslSupport openssl
57 ++ optional bdbSupport db
58 ++ optional ldapSupport openldap
59 ++ optional stdenv.isFreeBSD cyrus_sasl;
62 for f in $out/lib/*.la $out/lib/apr-util-1/*.la $dev/bin/apu-1-config; do
63 substituteInPlace $f \
64 --replace "${expat.dev}/lib" "${expat.out}/lib" \
65 --replace "${db.dev}/lib" "${db.out}/lib" \
66 --replace "${openssl.dev}/lib" "${lib.getLib openssl}/lib"
69 # Give apr1 access to sed for runtime invocations.
70 wrapProgram $dev/bin/apu-1-config --prefix PATH : "${gnused}/bin"
73 enableParallelBuilding = true;
76 inherit sslSupport bdbSupport ldapSupport;
80 homepage = "https://apr.apache.org/";
81 description = "A companion library to APR, the Apache Portable Runtime";
82 maintainers = [ maintainers.eelco ];
83 platforms = platforms.unix;
84 license = licenses.asl20;