anchor.diff: -{ lib, stdenv, fetchurl, openssl, cyrus_sasl, db, groff, libtool }:
  +{ lib, stdenv, fetchurl, openssl, db, groff, libtool
  +, withCyrusSasl ? true
  +, cyrus_sasl
  +}:
   
   stdenv.mkDerivation rec {
     pname = "openldap";
  
positive.code:     "moduledir=$(out)/lib/modules"
    ];
  
    # 1. Fixup broken libtool
    # 2. Libraries left in the build location confuse `patchelf --shrink-rpath`
    #    Delete these to let patchelf discover the right path instead.
    #    FIXME: that one can be removed when https://github.com/NixOS/patchelf/pull/98
    #    is in Nixpkgs patchelf.
    preFixup = ''
      sed -e 's,-lsasl2,-L${cyrus_sasl.out}/lib -lsasl2,' \
          -e 's,-lssl,-L${openssl.out}/lib -lssl,' \
          -i $out/lib/libldap.la -i $out/lib/libldap_r.la
  
      rm -rf $out/var
      rm -r libraries/*/.libs
      rm -r contrib/slapd-modules/passwd/*/.libs
    '';
  
    postInstall = ''
  
negative.code:   ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
      "--with-yielding_select=yes"
      "ac_cv_func_memcmp_working=yes"
    ] ++ lib.optional (!withCyrusSasl) "--without-cyrus-sasl"
      ++ lib.optional stdenv.isFreeBSD "--with-pic";
  
    postBuild = ''
  