summary refs log tree commit diff
path: root/pkgs/servers/ldap/389/default.nix
blob: 34bb901f671356010ff1b9bb758c682c85d06c70 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
{ stdenv
, autoreconfHook
, fetchFromGitHub
, lib

, bzip2
, cmocka
, cracklib
, cyrus_sasl
, db
, doxygen
, icu
, libevent
, libkrb5
, lm_sensors
, net-snmp
, nspr
, nss
, openldap
, openssl
, pcre
, perl
, perlPackages
, pkg-config
, python3
, svrcore
, zlib

, enablePamPassthru ? true
, pam

, enableCockpit ? true
, rsync

, enableDna ? true
, enableLdapi ? true
, enableAutobind ? false
, enableAutoDnSuffix ? false
, enableBitwise ? true
, enableAcctPolicy ? true
, enablePosixWinsync ? true
}:

stdenv.mkDerivation rec {
  pname = "389-ds-base";
  version = "2.0.6";

  src = fetchFromGitHub {
    owner = "389ds";
    repo = pname;
    rev = "${pname}-${version}";
    sha256 = "sha256-MYLRrH3PrNdPVuRffiG39zzJK6eHJcvIDWn1q0IHrZ8=";
  };

  nativeBuildInputs = [ autoreconfHook pkg-config doxygen ];

  buildInputs = [
    bzip2
    cracklib
    cyrus_sasl
    db
    icu
    libevent
    libkrb5
    lm_sensors
    net-snmp
    nspr
    nss
    openldap
    openssl
    pcre
    perl
    python3
    svrcore
    zlib

    # tests
    cmocka
    libevent

    # lib389
    (python3.withPackages (ps: with ps; [
      setuptools
      ldap
      six
      pyasn1
      pyasn1-modules
      python-dateutil
      argcomplete
      libselinux
    ]))

    # logconv.pl
    perlPackages.DBFile
    perlPackages.ArchiveTar
  ]
  ++ lib.optional enableCockpit rsync
  ++ lib.optional enablePamPassthru pam;

  postPatch = ''
    substituteInPlace Makefile.am \
      --replace 's,@perlpath\@,$(perldir),g' 's,@perlpath\@,$(perldir) $(PERLPATH),g'

    patchShebangs ./buildnum.py ./ldap/servers/slapd/mkDBErrStrs.py
  '';

  preConfigure = ''
    # Create perl paths for library imports in perl scripts
    PERLPATH=""
    for P in $(echo $PERL5LIB | sed 's/:/ /g'); do
      PERLPATH="$PERLPATH $(echo $P/*/*)"
    done
    export PERLPATH
  '';

  configureFlags =
    let
      mkEnable = cond: name: if cond then "--enable-${name}" else "--disable-${name}";
    in
    [
      "--enable-cmocka"
      "--localstatedir=/var"
      "--sysconfdir=/etc"
      "--with-db-inc=${db.dev}/include"
      "--with-db-lib=${db.out}/lib"
      "--with-db=yes"
      "--with-netsnmp-inc=${lib.getDev net-snmp}/include"
      "--with-netsnmp-lib=${lib.getLib net-snmp}/lib"
      "--with-netsnmp=yes"
      "--with-openldap"

      "${mkEnable enableCockpit "cockpit"}"
      "${mkEnable enablePamPassthru "pam-passthru"}"
      "${mkEnable enableDna "dna"}"
      "${mkEnable enableLdapi "ldapi"}"
      "${mkEnable enableAutobind "autobind"}"
      "${mkEnable enableAutoDnSuffix "auto-dn-suffix"}"
      "${mkEnable enableBitwise "bitwise"}"
      "${mkEnable enableAcctPolicy "acctpolicy"}"
      "${mkEnable enablePosixWinsync "posix-winsync"}"
    ];

  enableParallelBuilding = true;

  doCheck = true;

  installFlags = [
    "sysconfdir=${placeholder "out"}/etc"
    "localstatedir=${placeholder "TMPDIR"}"
  ];

  passthru.version = version;

  meta = with lib; {
    homepage = "https://www.port389.org/";
    description = "Enterprise-class Open Source LDAP server for Linux";
    license = licenses.gpl3Plus;
    platforms = platforms.linux;
  };
}