1{ stdenv, fetchurl, openssl, cyrus_sasl, db, groff, libtool }:
2
3stdenv.mkDerivation rec {
4 name = "openldap-2.4.45";
5
6 src = fetchurl {
7 url = "http://www.openldap.org/software/download/OpenLDAP/openldap-release/${name}.tgz";
8 sha256 = "091qvwk5dkcpp17ziabcnh3rg3m7qwzw2pihfcd1d5fdxgywzmnd";
9 };
10
11 patches = [
12 (fetchurl {
13 url = "https://bz-attachments.freebsd.org/attachment.cgi?id=183223";
14 sha256 = "1fiy457hrxmydybjlvn8ypzlavz22cz31q2rga07n32dh4x759r3";
15 })
16 ];
17 patchFlags = [ "-p0" ];
18
19 # TODO: separate "out" and "bin"
20 outputs = [ "out" "dev" "man" "devdoc" ];
21
22 enableParallelBuilding = true;
23
24 buildInputs = [ openssl cyrus_sasl db groff libtool ];
25
26 configureFlags =
27 [ "--enable-overlays"
28 "--disable-dependency-tracking" # speeds up one-time build
29 "--enable-modules"
30 "--sysconfdir=/etc"
31 "--localstatedir=/var"
32 "--enable-crypt"
33 ] ++ stdenv.lib.optional (openssl == null) "--without-tls"
34 ++ stdenv.lib.optional (cyrus_sasl == null) "--without-cyrus-sasl"
35 ++ stdenv.lib.optional stdenv.isFreeBSD "--with-pic";
36
37 installFlags = [ "sysconfdir=$(out)/etc" "localstatedir=$(out)/var" ];
38
39 # 1. Fixup broken libtool
40 # 2. Libraries left in the build location confuse `patchelf --shrink-rpath`
41 # Delete these to let patchelf discover the right path instead.
42 # FIXME: that one can be removed when https://github.com/NixOS/patchelf/pull/98
43 # is in Nixpkgs patchelf.
44 preFixup = ''
45 sed -e 's,-lsasl2,-L${cyrus_sasl.out}/lib -lsasl2,' \
46 -e 's,-lssl,-L${openssl.out}/lib -lssl,' \
47 -i $out/lib/libldap.la -i $out/lib/libldap_r.la
48
49 rm -rf $out/var
50 rm -r libraries/*/.libs
51 '';
52
53 postInstall = ''
54 chmod +x "$out"/lib/*.{so,dylib}
55 '';
56
57 meta = with stdenv.lib; {
58 homepage = http://www.openldap.org/;
59 description = "An open source implementation of the Lightweight Directory Access Protocol";
60 maintainers = with maintainers; [ lovek323 ];
61 platforms = platforms.unix;
62 };
63}