1{ lib, stdenv, fetchurl, perl
2# Update the enabled crypt scheme ids in passthru when the enabled hashes change
3, enableHashes ? "strong"
4, nixosTests
5, runCommand
6, python3
7}:
8
9stdenv.mkDerivation (finalAttrs: {
10 pname = "libxcrypt";
11 version = "4.4.33";
12
13 src = fetchurl {
14 url = "https://github.com/besser82/libxcrypt/releases/download/v${finalAttrs.version}/libxcrypt-${finalAttrs.version}.tar.xz";
15 hash = "sha256-6HrPnGUsVzpHE9VYIVn5jzBdVu1fdUzmT1fUGU1rOm8=";
16 };
17
18 outputs = [
19 "out"
20 "man"
21 ];
22
23 configureFlags = [
24 "--enable-hashes=${enableHashes}"
25 "--enable-obsolete-api=glibc"
26 "--disable-failure-tokens"
27 ] ++ lib.optionals (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.libc == "bionic") [
28 "--disable-werror"
29 ];
30
31 nativeBuildInputs = [
32 perl
33 ];
34
35 enableParallelBuilding = true;
36
37 doCheck = true;
38
39 passthru = {
40 tests = {
41 inherit (nixosTests) login shadow;
42
43 passthruMatches = runCommand "libxcrypt-test-passthru-matches" { } ''
44 ${python3.interpreter} "${./check_passthru_matches.py}" ${lib.escapeShellArgs ([ finalAttrs.src enableHashes "--" ] ++ finalAttrs.passthru.enabledCryptSchemeIds)}
45 touch "$out"
46 '';
47 };
48 enabledCryptSchemeIds = [
49 # https://github.com/besser82/libxcrypt/blob/v4.4.33/lib/hashes.conf
50 "y" # yescrypt
51 "gy" # gost_yescrypt
52 "7" # scrypt
53 "2b" # bcrypt
54 "2y" # bcrypt_y
55 "2a" # bcrypt_a
56 "6" # sha512crypt
57 ];
58 };
59
60 meta = with lib; {
61 description = "Extended crypt library for descrypt, md5crypt, bcrypt, and others";
62 homepage = "https://github.com/besser82/libxcrypt/";
63 platforms = platforms.all;
64 maintainers = with maintainers; [ dottedmag hexa ];
65 license = licenses.lgpl21Plus;
66 };
67})