depot/third_party/nixpkgs/pkgs/development/libraries/libxcrypt/default.nix
Default email 94427deb9d Project import generated by Copybara.
GitOrigin-RevId: f91ee3065de91a3531329a674a45ddcb3467a650
2023-05-24 16:37:59 +03:00

67 lines
1.7 KiB
Nix

{ lib, stdenv, fetchurl, perl
# Update the enabled crypt scheme ids in passthru when the enabled hashes change
, enableHashes ? "strong"
, nixosTests
, runCommand
, python3
}:
stdenv.mkDerivation (finalAttrs: {
pname = "libxcrypt";
version = "4.4.33";
src = fetchurl {
url = "https://github.com/besser82/libxcrypt/releases/download/v${finalAttrs.version}/libxcrypt-${finalAttrs.version}.tar.xz";
hash = "sha256-6HrPnGUsVzpHE9VYIVn5jzBdVu1fdUzmT1fUGU1rOm8=";
};
outputs = [
"out"
"man"
];
configureFlags = [
"--enable-hashes=${enableHashes}"
"--enable-obsolete-api=glibc"
"--disable-failure-tokens"
] ++ lib.optionals (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.libc == "bionic") [
"--disable-werror"
];
nativeBuildInputs = [
perl
];
enableParallelBuilding = true;
doCheck = true;
passthru = {
tests = {
inherit (nixosTests) login shadow;
passthruMatches = runCommand "libxcrypt-test-passthru-matches" { } ''
${python3.interpreter} "${./check_passthru_matches.py}" ${lib.escapeShellArgs ([ finalAttrs.src enableHashes "--" ] ++ finalAttrs.passthru.enabledCryptSchemeIds)}
touch "$out"
'';
};
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
];
};
meta = with lib; {
description = "Extended crypt library for descrypt, md5crypt, bcrypt, and others";
homepage = "https://github.com/besser82/libxcrypt/";
platforms = platforms.all;
maintainers = with maintainers; [ dottedmag hexa ];
license = licenses.lgpl21Plus;
};
})