(define-module (glicid packages openldap)
 #:use-module (guix build-system gnu)
 #:use-module (guix download)
 #:use-module ((guix licenses) #:prefix license:)
 #:use-module (guix packages)
 #:use-module (guix utils)
 #:use-module (gnu packages autotools)
 #:use-module (gnu packages compression)
 #:use-module (gnu packages cyrus-sasl)
 #:use-module (gnu packages databases)
 #:use-module (gnu packages dbm)
 #:use-module (gnu packages gnupg)
 #:use-module (gnu packages groff)
 #:use-module (gnu packages kerberos)
 #:use-module (gnu packages libevent)
 #:use-module (gnu packages linux)
 #:use-module ((gnu packages openldap) #:prefix gnu:)
 #:use-module (gnu packages password-utils)
 #:use-module (gnu packages perl)
 #:use-module (gnu packages python)
 #:use-module (gnu packages pkg-config)
 #:use-module (gnu packages tls)
)

(define-public openldap
  (package
    (name "openldap")
    (version "2.6.2")
    (source (origin
      (method url-fetch)
      (uri (list
        (string-append "https://www.openldap.org/software/download/OpenLDAP/openldap-release/openldap-" version ".tgz")
      ))
      (sha256 (base32 "11ygl4iilhkz5rhndh68lss4a33cqp9arb7mxj329dif4d2r7l41"))
      )
    )
    (build-system gnu-build-system)
    (inputs (list argon2 cyrus-sasl libevent libgcrypt libltdl lz4 openssl perl snappy unixodbc wiredtiger zlib))
    (native-inputs (list bdb groff libtool pkg-config))
    (arguments '(
      ; this is needed because the make check does not work inside guix
      #:tests? #f
      #:configure-flags '(
        "--enable-debug"
        "--enable-dynamic"
        "--enable-syslog"
        "--enable-ipv6"
        "--enable-local"
        "--enable-slapd"
        "--enable-dynacl"
        "--enable-aci"
        "--enable-cleartext"
        "--enable-crypt"
        "--enable-spasswd"
        "--enable-modules"
        "--enable-rlookups"
        "--enable-slapi"
        "--enable-backends=mod"
        "--enable-overlays=mod"
        "--enable-argon2"
        "--enable-balancer"
        "--disable-static"
        "--enable-shared"
        "--with-tls=openssl"
      )
      #:make-flags '("STRIP=")
      #:phases (modify-phases %standard-phases
        (add-before 'build 'make-depend
          (lambda* (#:key input #:allow-other-keys)
            (invoke "make" "depend")
          )
        )
      )
    ))
    (synopsis "Implementation of the Lightweight Directory Access Protocol")
    (description "OpenLDAP is a free implementation of the Lightweight Directory Access Protocol.")
    (license license:openldap2.8)
    (home-page "https://www.openldap.org/")
  )
)

(define-public openldap-2.4.58
  (package
    (inherit openldap)
    (name "openldap")
    (version "2.4.58")
    (source (origin
      (method url-fetch)
      (uri (list
        (string-append "https://www.openldap.org/software/download/OpenLDAP/openldap-release/openldap-" version ".tgz")
      ))
      (sha256 (base32 "0yzlz1l49jc7989k65994chv0xspq30i9mdkk9mbzl0mpra95dap"))
      )
    )
  )
)

(define-public openldap-2.4.59
  (package
    (inherit openldap)
    (name "openldap")
    (version "2.4.59")
    (source (origin
      (method url-fetch)
      (uri (list
        (string-append "https://www.openldap.org/software/download/OpenLDAP/openldap-release/openldap-" version ".tgz")
      ))
      (sha256 (base32 "0d1gw898gbkv46mw0gll3q0w2j2y9midlzh6f320d0nq8xkpvwwr"))
      )
    )
  )
)

(define-public openldap-2.5.4
  (package
    (inherit openldap)
    (name "openldap")
    (version "2.5.4")
    (source (origin
      (method url-fetch)
      (uri (list
        (string-append "https://www.openldap.org/software/download/OpenLDAP/openldap-release/openldap-" version ".tgz")
      ))
      (sha256 (base32 "0mmk9wz23z4ahaga7ri99gnnwhjjgmfmbaaga2g8bkbhil3krh31"))
      )
    )
  )
)

(define-public openldap-2.5.5
  (package
    (inherit openldap)
    (name "openldap")
    (version "2.5.5")
    (source (origin
      (method url-fetch)
      (uri (list
        (string-append "https://www.openldap.org/software/download/OpenLDAP/openldap-release/openldap-" version ".tgz")
      ))
      (sha256 (base32 "1cznvccwgj9v3207l254wyfzm1v5prk93hkx5i6ha3pw5bdfzv3l"))
      )
    )
  )
)

(define-public openldap-2.5.6
  (package
    (inherit openldap)
    (name "openldap")
    (version "2.5.6")
    (source (origin
      (method url-fetch)
      (uri (list
        (string-append "https://www.openldap.org/software/download/OpenLDAP/openldap-release/openldap-" version ".tgz")
      ))
      (sha256 (base32 "07y1r9a0k07z9s9w5m477bb6ib1hr3xx9qll8i57gn9vklx4489z"))
      )
    )
  )
)

(define-public openldap-2.5.7
  (package
    (inherit openldap)
    (name "openldap")
    (version "2.5.7")
    (source (origin
      (method url-fetch)
      (uri (list
        (string-append "https://www.openldap.org/software/download/OpenLDAP/openldap-release/openldap-" version ".tgz")
      ))
      (sha256 (base32 "1ayr76sa5hjwldqzis5v71sbp88hd3hysc00gw1raqn33c05g5za"))
      )
    )
  )
)

(define-public openldap-2.5.8
  (package
    (inherit openldap)
    (name "openldap")
    (version "2.5.8")
    (source (origin
      (method url-fetch)
      (uri (list
        (string-append "https://www.openldap.org/software/download/OpenLDAP/openldap-release/openldap-" version ".tgz")
      ))
      (sha256 (base32 "1p3jck2kh7rsz6mkrqaailaf9ky050hn72wph52dw0j2nb1s2vin"))
      )
    )
  )
)

(define-public openldap-2.5.9
  (package
    (inherit openldap)
    (name "openldap")
    (version "2.5.9")
    (source (origin
      (method url-fetch)
      (uri (list
        (string-append "https://www.openldap.org/software/download/OpenLDAP/openldap-release/openldap-" version ".tgz")
      ))
      (sha256 (base32 "17pvwrj27jybbmjqpv0p7kd2qa4i6jnp134lz7cxa0sqrbs153n0"))
      )
    )
  )
)

(define-public openldap-2.5.10
  (package
    (inherit openldap)
    (name "openldap")
    (version "2.5.10")
    (source (origin
      (method url-fetch)
      (uri (list
        (string-append "https://www.openldap.org/software/download/OpenLDAP/openldap-release/openldap-" version ".tgz")
      ))
      (sha256 (base32 "1ygxy2l3kv6gmcdc8hpz8fjbg39wp8v2xcqh56xrzp51gn4k326i"))
      )
    )
  )
)

(define-public openldap-2.5.11
  (package
    (inherit openldap)
    (name "openldap")
    (version "2.5.11")
    (source (origin
      (method url-fetch)
      (uri (list
        (string-append "https://www.openldap.org/software/download/OpenLDAP/openldap-release/openldap-" version ".tgz")
      ))
      (sha256 (base32 "1wfp273g3dmw5bdnlllv43ydld2nrnap71bmm8wjx7yhfrvv054m"))
      )
    )
  )
)

(define-public openldap-2.5.12
  (package
    (inherit openldap)
    (name "openldap")
    (version "2.5.12")
    (source (origin
      (method url-fetch)
      (uri (list
        (string-append "https://www.openldap.org/software/download/OpenLDAP/openldap-release/openldap-" version ".tgz")
      ))
      (sha256 (base32 "15kvwfq7ly8jai1v5s3fn50x8lj50nljk93h0ryzm5wmqjznq26m"))
      )
    )
  )
)

(define-public openldap-2.6.0
  (package
    (inherit openldap)
    (name "openldap")
    (version "2.6.0")
    (source (origin
      (method url-fetch)
      (uri (list
        (string-append "https://www.openldap.org/software/download/OpenLDAP/openldap-release/openldap-" version ".tgz")
      ))
      (sha256 (base32 "0kqswk8pxgnlibh0kz6py3a2x3yh9pfk6pyr2nx9lgjpmh75h75p"))
      )
    )
  )
)

(define-public openldap-2.6.1
  (package
    (inherit openldap)
    (name "openldap")
    (version "2.6.1")
    (source (origin
      (method url-fetch)
      (uri (list
        (string-append "https://www.openldap.org/software/download/OpenLDAP/openldap-release/openldap-" version ".tgz")
      ))
      (sha256 (base32 "1wz6f3g3bbqgbbxs20zlappmmhapqbl791c0waibhz9djsk6wmwx"))
      )
    )
  )
)

(define-public nss-pam-ldapd
  (package
    (name "nss-pam-ldapd")
    (version "0.9.12")
    (source (origin
      (method url-fetch)
      (uri (string-append "https://arthurdejong.org/nss-pam-ldapd/nss-pam-ldapd-" version ".tar.gz"))
      (sha256 (base32 "050fzcmxmf6y15dlcffc4gxr3wkk7fliqqwhlwqzbjwk8vkn3mn6"))
    ))
    (build-system gnu-build-system)
    (arguments
     `(
        #:configure-flags
        (list (string-append
          "--with-pam-seclib-dir=" (assoc-ref %outputs "out") "/lib/security/")
          "--with-ldap-conf-file=/etc/nslcd.conf"
        )
        #:phases
        (modify-phases %standard-phases
          (add-after 'unpack 'override-nslcd.conf-install-path
            (lambda* (#:key outputs #:allow-other-keys)
              (substitute* "Makefile.in"
                (
                  ("\\$\\(DESTDIR\\)\\$\\(NSLCD_CONF_PATH\\)")
                  (string-append (assoc-ref outputs "out") "/etc/nslcd.conf.example")
                )
              )
            )
          )
        )
      )
    )
    (inputs `(
      ("linux-pam", linux-pam)
      ("mit-krb5", mit-krb5)
      ("openldap", openldap)
      ("python", python)
    ))
    (home-page "https://arthurdejong.org/nss-pam-ldapd")
    (synopsis "NSS and PAM modules for LDAP")
    (description "nss-pam-ldapd provides a @dfn{Name Service Switch} (NSS)
module that allows your LDAP server to provide user account, group, host name,
alias, netgroup, and basically any other information that you would normally
get from @file{/etc} flat files or NIS.  It also provides a @dfn{Pluggable
Authentication Module} (PAM) to do identity and authentication management with
an LDAP server.")
    (license license:lgpl2.1+)
  )
)
