Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib 2, stdenv 3, fetchurl 4, fetchpatch 5 6# dependencies 7, cyrus_sasl 8, db 9, groff 10, libsodium 11, libtool 12, openssl 13, systemdMinimal 14, libxcrypt 15 16# passthru 17, nixosTests 18}: 19 20stdenv.mkDerivation rec { 21 pname = "openldap"; 22 version = "2.6.4"; 23 24 src = fetchurl { 25 url = "https://www.openldap.org/software/download/OpenLDAP/openldap-release/${pname}-${version}.tgz"; 26 hash = "sha256-1RcE5QF4QwwGzz2KoXTaZrrfVZdHpH2SC7VLLUqkCZE="; 27 }; 28 29 # TODO: separate "out" and "bin" 30 outputs = [ 31 "out" 32 "dev" 33 "man" 34 "devdoc" 35 ]; 36 37 enableParallelBuilding = true; 38 39 nativeBuildInputs = [ 40 groff 41 ]; 42 43 buildInputs = [ 44 (cyrus_sasl.override { 45 inherit openssl; 46 }) 47 db 48 libsodium 49 libtool 50 openssl 51 ] ++ lib.optionals (stdenv.isLinux) [ 52 libxcrypt # causes linking issues on *-darwin 53 systemdMinimal 54 ]; 55 56 preConfigure = lib.optionalString (lib.versionAtLeast stdenv.hostPlatform.darwinMinVersion "11") '' 57 MACOSX_DEPLOYMENT_TARGET=10.16 58 ''; 59 60 configureFlags = [ 61 "--enable-argon2" 62 "--enable-crypt" 63 "--enable-modules" 64 "--enable-overlays" 65 ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ 66 "--with-yielding_select=yes" 67 "ac_cv_func_memcmp_working=yes" 68 ] ++ lib.optional stdenv.isFreeBSD "--with-pic"; 69 70 env.NIX_CFLAGS_COMPILE = toString [ "-DLDAPI_SOCK=\"/run/openldap/ldapi\"" ]; 71 72 makeFlags= [ 73 "CC=${stdenv.cc.targetPrefix}cc" 74 "STRIP=" # Disable install stripping as it breaks cross-compiling. We strip binaries anyway in fixupPhase. 75 "STRIP_OPTS=" 76 "prefix=${placeholder "out"}" 77 "sysconfdir=/etc" 78 "systemdsystemunitdir=${placeholder "out"}/lib/systemd/system" 79 # contrib modules require these 80 "moduledir=${placeholder "out"}/lib/modules" 81 "mandir=${placeholder "out"}/share/man" 82 ]; 83 84 extraContribModules = [ 85 # https://git.openldap.org/openldap/openldap/-/tree/master/contrib/slapd-modules 86 "passwd/sha2" 87 "passwd/pbkdf2" 88 "passwd/totp" 89 ]; 90 91 postBuild = '' 92 for module in $extraContribModules; do 93 make $makeFlags CC=$CC -C contrib/slapd-modules/$module 94 done 95 ''; 96 97 preCheck = '' 98 substituteInPlace tests/scripts/all \ 99 --replace "/bin/rm" "rm" 100 ''; 101 102 doCheck = true; 103 104 # The directory is empty and serve no purpose. 105 preFixup = '' 106 rm -r $out/var 107 ''; 108 109 installFlags = [ 110 "prefix=${placeholder "out"}" 111 "sysconfdir=${placeholder "out"}/etc" 112 "moduledir=${placeholder "out"}/lib/modules" 113 "INSTALL=install" 114 ]; 115 116 postInstall = '' 117 for module in $extraContribModules; do 118 make $installFlags install -C contrib/slapd-modules/$module 119 done 120 chmod +x "$out"/lib/*.{so,dylib} 121 ''; 122 123 passthru.tests = { 124 inherit (nixosTests) openldap; 125 }; 126 127 meta = with lib; { 128 homepage = "https://www.openldap.org/"; 129 description = "An open source implementation of the Lightweight Directory Access Protocol"; 130 license = licenses.openldap; 131 maintainers = with maintainers; [ ajs124 das_j hexa ]; 132 platforms = platforms.unix; 133 }; 134}