2023-03-27 19:17:25 +00:00
|
|
|
{ lib, stdenv, fetchurl, perl
|
|
|
|
# Update the enabled crypt scheme ids in passthru when the enabled hashes change
|
|
|
|
, enableHashes ? "strong"
|
|
|
|
, nixosTests
|
2023-05-24 13:37:59 +00:00
|
|
|
, runCommand
|
|
|
|
, python3
|
2023-03-27 19:17:25 +00:00
|
|
|
}:
|
2021-03-09 03:18:52 +00:00
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2021-03-09 03:18:52 +00:00
|
|
|
pname = "libxcrypt";
|
2023-08-04 22:07:22 +00:00
|
|
|
version = "4.4.36";
|
2021-03-09 03:18:52 +00:00
|
|
|
|
2022-10-30 15:09:59 +00:00
|
|
|
src = fetchurl {
|
2023-05-24 13:37:59 +00:00
|
|
|
url = "https://github.com/besser82/libxcrypt/releases/download/v${finalAttrs.version}/libxcrypt-${finalAttrs.version}.tar.xz";
|
2023-08-04 22:07:22 +00:00
|
|
|
hash = "sha256-5eH0yu4KAd4q7ibjE4gH1tPKK45nKHlm0f79ZeH9iUM=";
|
2021-03-09 03:18:52 +00:00
|
|
|
};
|
|
|
|
|
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
|
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace ./build-aux/m4-autogen/config.guess --replace-fail /usr/bin/uname uname
|
|
|
|
'';
|
|
|
|
|
2022-10-30 15:09:59 +00:00
|
|
|
outputs = [
|
|
|
|
"out"
|
|
|
|
"man"
|
2022-10-06 18:32:54 +00:00
|
|
|
];
|
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
configureFlags = [
|
2023-03-27 19:17:25 +00:00
|
|
|
"--enable-hashes=${enableHashes}"
|
2022-10-30 15:09:59 +00:00
|
|
|
"--enable-obsolete-api=glibc"
|
|
|
|
"--disable-failure-tokens"
|
2023-07-15 17:15:38 +00:00
|
|
|
# required for musl, android, march=native
|
2022-04-27 09:35:20 +00:00
|
|
|
"--disable-werror"
|
|
|
|
];
|
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
makeFlags = let
|
|
|
|
lld17Plus = stdenv.cc.bintools.isLLVM
|
|
|
|
&& lib.versionAtLeast stdenv.cc.bintools.version "17";
|
|
|
|
in []
|
|
|
|
# fixes: can't build x86_64-w64-mingw32 shared library unless -no-undefined is specified
|
|
|
|
++ lib.optionals stdenv.hostPlatform.isWindows [ "LDFLAGS+=-no-undefined" ]
|
|
|
|
|
|
|
|
# lld 17 sets `--no-undefined-version` by default and `libxcrypt`'s
|
|
|
|
# version script unconditionally lists legacy compatibility symbols, even
|
|
|
|
# when not exported: https://github.com/besser82/libxcrypt/issues/181
|
|
|
|
++ lib.optionals lld17Plus [ "LDFLAGS+=-Wl,--undefined-version" ]
|
|
|
|
;
|
2023-10-09 19:29:22 +00:00
|
|
|
|
2022-10-30 15:09:59 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
perl
|
|
|
|
];
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
2021-03-09 03:18:52 +00:00
|
|
|
|
2022-11-21 17:40:18 +00:00
|
|
|
doCheck = true;
|
2022-10-30 15:09:59 +00:00
|
|
|
|
2023-03-27 19:17:25 +00:00
|
|
|
passthru = {
|
|
|
|
tests = {
|
|
|
|
inherit (nixosTests) login shadow;
|
2023-05-24 13:37:59 +00:00
|
|
|
|
|
|
|
passthruMatches = runCommand "libxcrypt-test-passthru-matches" { } ''
|
|
|
|
${python3.interpreter} "${./check_passthru_matches.py}" ${lib.escapeShellArgs ([ finalAttrs.src enableHashes "--" ] ++ finalAttrs.passthru.enabledCryptSchemeIds)}
|
|
|
|
touch "$out"
|
|
|
|
'';
|
2023-03-27 19:17:25 +00:00
|
|
|
};
|
|
|
|
enabledCryptSchemeIds = [
|
2023-07-15 17:15:38 +00:00
|
|
|
# https://github.com/besser82/libxcrypt/blob/v4.4.35/lib/hashes.conf
|
2023-03-27 19:17:25 +00:00
|
|
|
"y" # yescrypt
|
|
|
|
"gy" # gost_yescrypt
|
|
|
|
"7" # scrypt
|
|
|
|
"2b" # bcrypt
|
|
|
|
"2y" # bcrypt_y
|
|
|
|
"2a" # bcrypt_a
|
|
|
|
"6" # sha512crypt
|
|
|
|
];
|
2022-10-30 15:09:59 +00:00
|
|
|
};
|
2021-03-09 03:18:52 +00:00
|
|
|
|
|
|
|
meta = with lib; {
|
2023-07-15 17:15:38 +00:00
|
|
|
changelog = "https://github.com/besser82/libxcrypt/blob/v${finalAttrs.version}/NEWS";
|
2021-03-09 03:18:52 +00:00
|
|
|
description = "Extended crypt library for descrypt, md5crypt, bcrypt, and others";
|
|
|
|
homepage = "https://github.com/besser82/libxcrypt/";
|
|
|
|
platforms = platforms.all;
|
2022-10-30 15:09:59 +00:00
|
|
|
maintainers = with maintainers; [ dottedmag hexa ];
|
2021-03-09 03:18:52 +00:00
|
|
|
license = licenses.lgpl21Plus;
|
|
|
|
};
|
2023-05-24 13:37:59 +00:00
|
|
|
})
|