2021-04-05 15:23:46 +00:00
|
|
|
{ lib, stdenv, fetchurl, pkg-config, perl, bison, bootstrap_cmds
|
2024-01-02 11:29:13 +00:00
|
|
|
, openssl, openldap, libedit, keyutils, libverto, darwin
|
2023-01-20 10:41:00 +00:00
|
|
|
|
|
|
|
# for passthru.tests
|
|
|
|
, bind
|
|
|
|
, curl
|
2022-08-12 12:06:08 +00:00
|
|
|
, nixosTests
|
2023-01-20 10:41:00 +00:00
|
|
|
, openssh
|
|
|
|
, postgresql
|
|
|
|
, python3
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# Extra Arguments
|
|
|
|
, type ? ""
|
|
|
|
# This is called "staticOnly" because krb5 does not support
|
|
|
|
# builting both static and shared, see below.
|
|
|
|
, staticOnly ? false
|
2024-02-29 20:09:43 +00:00
|
|
|
, withLdap ? false
|
2023-04-12 12:48:02 +00:00
|
|
|
, withVerto ? false
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
2020-08-20 17:08:02 +00:00
|
|
|
# Note: this package is used for bootstrapping fetchurl, and thus
|
|
|
|
# cannot use fetchpatch! All mutable patches (generated by GitHub or
|
|
|
|
# cgit) that are needed here should be included directly in Nixpkgs as
|
|
|
|
# files.
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
let
|
|
|
|
libOnly = type == "lib";
|
|
|
|
in
|
2024-02-29 20:09:43 +00:00
|
|
|
|
|
|
|
assert withLdap -> !libOnly;
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2022-04-15 01:41:22 +00:00
|
|
|
pname = "${type}krb5";
|
2024-01-02 11:29:13 +00:00
|
|
|
version = "1.21.2";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2022-08-12 12:06:08 +00:00
|
|
|
url = "https://kerberos.org/dist/krb5/${lib.versions.majorMinor version}/krb5-${version}.tar.gz";
|
2024-01-02 11:29:13 +00:00
|
|
|
hash = "sha256-lWCUGp2EPAJDpxsXp6xv4xx867W845g9t55Srn6FBJE=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
outputs = [ "out" "dev" ];
|
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
configureFlags = [ "--localstatedir=/var/lib" ]
|
2020-04-24 23:36:52 +00:00
|
|
|
# krb5's ./configure does not allow passing --enable-shared and --enable-static at the same time.
|
|
|
|
# See https://bbs.archlinux.org/viewtopic.php?pid=1576737#p1576737
|
2022-10-30 15:09:59 +00:00
|
|
|
++ lib.optionals staticOnly [ "--enable-static" "--disable-shared" ]
|
2024-02-29 20:09:43 +00:00
|
|
|
++ lib.optional withLdap "--with-ldap"
|
2023-04-12 12:48:02 +00:00
|
|
|
++ lib.optional withVerto "--with-system-verto"
|
2024-06-05 15:53:02 +00:00
|
|
|
++ lib.optional stdenv.isFreeBSD ''WARN_CFLAGS=''
|
2022-08-12 12:06:08 +00:00
|
|
|
++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform)
|
2020-04-24 23:36:52 +00:00
|
|
|
[ "krb5_cv_attr_constructor_destructor=yes,yes"
|
|
|
|
"ac_cv_func_regcomp=yes"
|
|
|
|
"ac_cv_printf_positional=yes"
|
|
|
|
];
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
nativeBuildInputs = [ pkg-config perl ]
|
2022-08-12 12:06:08 +00:00
|
|
|
++ lib.optional (!libOnly) bison
|
2020-04-24 23:36:52 +00:00
|
|
|
# Provides the mig command used by the build scripts
|
2022-08-12 12:06:08 +00:00
|
|
|
++ lib.optional stdenv.isDarwin bootstrap_cmds;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
buildInputs = [ openssl ]
|
2022-08-12 12:06:08 +00:00
|
|
|
++ lib.optionals (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.libc != "bionic" && !(stdenv.hostPlatform.useLLVM or false)) [ keyutils ]
|
2024-02-29 20:09:43 +00:00
|
|
|
++ lib.optionals (!libOnly) [ libedit ]
|
|
|
|
++ lib.optionals withLdap [ openldap ]
|
2023-04-12 12:48:02 +00:00
|
|
|
++ lib.optionals withVerto [ libverto ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
propagatedBuildInputs = lib.optionals stdenv.isDarwin (with darwin.apple_sdk; [
|
|
|
|
libs.xpc
|
|
|
|
frameworks.Kerberos
|
|
|
|
]);
|
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
sourceRoot = "krb5-${version}/src";
|
|
|
|
|
2023-02-16 17:41:37 +00:00
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace config/shlib.conf \
|
|
|
|
--replace "'ld " "'${stdenv.cc.targetPrefix}ld "
|
2024-06-20 14:57:18 +00:00
|
|
|
''
|
|
|
|
# this could be accomplished by updateAutotoolsGnuConfigScriptsHook, but that causes infinite recursion
|
|
|
|
# necessary for FreeBSD code path in configure
|
|
|
|
+ ''
|
|
|
|
substituteInPlace ./config/config.guess --replace-fail /usr/bin/uname uname
|
2023-02-16 17:41:37 +00:00
|
|
|
'';
|
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
libFolders = [ "util" "include" "lib" "build-tools" ];
|
|
|
|
|
|
|
|
buildPhase = lib.optionalString libOnly ''
|
|
|
|
runHook preBuild
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-10-21 18:38:19 +00:00
|
|
|
MAKE="make -j $NIX_BUILD_CORES"
|
2022-08-12 12:06:08 +00:00
|
|
|
for folder in $libFolders; do
|
|
|
|
$MAKE -C $folder
|
|
|
|
done
|
|
|
|
|
|
|
|
runHook postBuild
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
installPhase = lib.optionalString libOnly ''
|
|
|
|
runHook preInstall
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
mkdir -p "$out"/{bin,sbin,lib/pkgconfig,share/{et,man/man1}} \
|
|
|
|
"$dev"/include/{gssapi,gssrpc,kadm5,krb5}
|
2022-08-12 12:06:08 +00:00
|
|
|
for folder in $libFolders; do
|
|
|
|
$MAKE -C $folder install
|
|
|
|
done
|
|
|
|
|
|
|
|
runHook postInstall
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
# not via outputBin, due to reference from libkrb5.so
|
|
|
|
postInstall = ''
|
|
|
|
moveToOutput bin/krb5-config "$dev"
|
|
|
|
'';
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
doCheck = false; # fails with "No suitable file for testing purposes"
|
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "MIT Kerberos 5";
|
|
|
|
homepage = "http://web.mit.edu/kerberos/";
|
|
|
|
license = licenses.mit;
|
|
|
|
platforms = platforms.unix ++ platforms.windows;
|
|
|
|
};
|
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
passthru = {
|
|
|
|
implementation = "krb5";
|
2023-01-20 10:41:00 +00:00
|
|
|
tests = {
|
|
|
|
inherit (nixosTests) kerberos;
|
|
|
|
inherit (python3.pkgs) requests-credssp;
|
|
|
|
bind = bind.override { enableGSSAPI = true; };
|
|
|
|
curl = curl.override { gssSupport = true; };
|
|
|
|
openssh = openssh.override { withKerberos = true; };
|
|
|
|
postgresql = postgresql.override { gssSupport = true; };
|
|
|
|
};
|
2022-08-12 12:06:08 +00:00
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
}
|