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";
|
2022-12-17 10:02:37 +00:00
|
|
|
version = "4.4.33";
|
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";
|
2022-12-17 10:02:37 +00:00
|
|
|
hash = "sha256-6HrPnGUsVzpHE9VYIVn5jzBdVu1fdUzmT1fUGU1rOm8=";
|
2021-03-09 03:18:52 +00:00
|
|
|
};
|
|
|
|
|
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"
|
2022-11-27 09:42:12 +00:00
|
|
|
] ++ lib.optionals (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.libc == "bionic") [
|
2022-04-27 09:35:20 +00:00
|
|
|
"--disable-werror"
|
|
|
|
];
|
|
|
|
|
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 = [
|
|
|
|
# https://github.com/besser82/libxcrypt/blob/v4.4.33/lib/hashes.conf
|
|
|
|
"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; {
|
|
|
|
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
|
|
|
})
|