core/pkgs/by-name/li/libxcrypt/default.nix

72 lines
2 KiB
Nix
Raw Normal View History

2024-05-02 00:46:19 +00:00
{ lib, stdenv, fetchurl, perl
# Update the enabled crypt scheme ids in passthru when the enabled hashes change
, enableHashes ? "strong"
2024-05-13 21:24:10 +00:00
# , nixosTests
, runCommand, python3 }:
2024-05-02 00:46:19 +00:00
stdenv.mkDerivation (finalAttrs: {
pname = "libxcrypt";
version = "4.4.36";
src = fetchurl {
2024-05-13 21:24:10 +00:00
url =
"https://github.com/besser82/libxcrypt/releases/download/v${finalAttrs.version}/libxcrypt-${finalAttrs.version}.tar.xz";
2024-05-02 00:46:19 +00:00
hash = "sha256-5eH0yu4KAd4q7ibjE4gH1tPKK45nKHlm0f79ZeH9iUM=";
};
2024-05-13 21:24:10 +00:00
outputs = [ "out" "man" ];
2024-05-02 00:46:19 +00:00
configureFlags = [
"--enable-hashes=${enableHashes}"
"--enable-obsolete-api=glibc"
"--disable-failure-tokens"
# required for musl, android, march=native
"--disable-werror"
];
# fixes: can't build x86_64-w64-mingw32 shared library unless -no-undefined is specified
2024-05-13 21:24:10 +00:00
makeFlags =
lib.optionals stdenv.hostPlatform.isWindows [ "LDFLAGS=-no-undefined" ];
2024-05-02 00:46:19 +00:00
2024-05-13 21:24:10 +00:00
nativeBuildInputs = [ perl ];
2024-05-02 00:46:19 +00:00
enableParallelBuilding = true;
doCheck = true;
passthru = {
tests = {
# inherit (nixosTests) login shadow;
passthruMatches = runCommand "libxcrypt-test-passthru-matches" { } ''
2024-05-13 21:24:10 +00:00
${python3.interpreter} "${./check_passthru_matches.py}" ${
lib.escapeShellArgs ([ finalAttrs.src enableHashes "--" ]
++ finalAttrs.passthru.enabledCryptSchemeIds)
}
2024-05-02 00:46:19 +00:00
touch "$out"
'';
};
enabledCryptSchemeIds = [
# https://github.com/besser82/libxcrypt/blob/v4.4.35/lib/hashes.conf
2024-05-13 21:24:10 +00:00
"y" # yescrypt
"gy" # gost_yescrypt
"7" # scrypt
"2b" # bcrypt
"2y" # bcrypt_y
"2a" # bcrypt_a
"6" # sha512crypt
2024-05-02 00:46:19 +00:00
];
};
meta = with lib; {
2024-05-13 21:24:10 +00:00
changelog =
"https://github.com/besser82/libxcrypt/blob/v${finalAttrs.version}/NEWS";
description =
"Extended crypt library for descrypt, md5crypt, bcrypt, and others";
2024-05-02 00:46:19 +00:00
homepage = "https://github.com/besser82/libxcrypt/";
platforms = platforms.all;
maintainers = with maintainers; [ dottedmag hexa ];
license = licenses.lgpl21Plus;
};
})