1 { lib, stdenv, fetchurl, pkg-config, perl, bison, bootstrap_cmds
2 , openssl, openldap, libedit, keyutils
6 # This is called "staticOnly" because krb5 does not support
7 # builting both static and shared, see below.
11 # Note: this package is used for bootstrapping fetchurl, and thus
12 # cannot use fetchpatch! All mutable patches (generated by GitHub or
13 # cgit) that are needed here should be included directly in Nixpkgs as
17 libOnly = type == "lib";
20 stdenv.mkDerivation rec {
21 name = "${type}krb5-${version}";
22 majorVersion = "1.18"; # remove patches below with next upgrade
23 version = majorVersion;
26 url = "https://kerberos.org/dist/krb5/${majorVersion}/krb5-${version}.tar.gz";
27 sha256 = "121c5xsy3x0i4wdkrpw62yhvji6virbh6n30ypazkp0isws3k4bk";
30 patches = optionals stdenv.hostPlatform.isMusl [
31 # TODO: Remove with next release > 1.18
32 # Patches to fix musl build with 1.18.
33 # Not using `fetchpatch` for these for now to avoid infinite recursion
34 # errors in downstream projects (unclear if it's a nixpkgs issue so far).
35 ./krb5-Fix-Linux-build-error-with-musl-libc.patch
36 ./krb5-Fix-typo-in-musl-build-fix.patch
39 outputs = [ "out" "dev" ];
41 configureFlags = [ "--with-tcl=no" "--localstatedir=/var/lib"]
42 # krb5's ./configure does not allow passing --enable-shared and --enable-static at the same time.
43 # See https://bbs.archlinux.org/viewtopic.php?pid=1576737#p1576737
44 ++ optional staticOnly [ "--enable-static" "--disable-shared" ]
45 ++ optional stdenv.isFreeBSD ''WARN_CFLAGS=""''
46 ++ optionals (stdenv.buildPlatform != stdenv.hostPlatform)
47 [ "krb5_cv_attr_constructor_destructor=yes,yes"
48 "ac_cv_func_regcomp=yes"
49 "ac_cv_printf_positional=yes"
52 nativeBuildInputs = [ pkg-config perl ]
53 ++ optional (!libOnly) bison
54 # Provides the mig command used by the build scripts
55 ++ optional stdenv.isDarwin bootstrap_cmds;
57 buildInputs = [ openssl ]
58 ++ optionals (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.libc != "bionic" && !(stdenv.hostPlatform.useLLVM or false)) [ keyutils ]
59 ++ optionals (!libOnly) [ openldap libedit ];
61 preConfigure = "cd ./src";
63 buildPhase = optionalString libOnly ''
64 MAKE="make -j $NIX_BUILD_CORES -l $NIX_BUILD_CORES"
68 (cd build-tools; $MAKE)
71 installPhase = optionalString libOnly ''
72 mkdir -p "$out"/{bin,sbin,lib/pkgconfig,share/{et,man/man1}} \
73 "$dev"/include/{gssapi,gssrpc,kadm5,krb5}
74 (cd util; $MAKE install)
75 (cd include; $MAKE install)
76 (cd lib; $MAKE install)
77 (cd build-tools; $MAKE install)
81 # not via outputBin, due to reference from libkrb5.so
83 moveToOutput bin/krb5-config "$dev"
86 enableParallelBuilding = true;
87 doCheck = false; # fails with "No suitable file for testing purposes"
90 description = "MIT Kerberos 5";
91 homepage = "http://web.mit.edu/kerberos/";
92 license = licenses.mit;
93 platforms = platforms.unix ++ platforms.windows;
96 passthru.implementation = "krb5";