at master 2.8 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchurl, 5 perl, 6 # Update the enabled crypt scheme ids in passthru when the enabled hashes change 7 enableHashes ? "strong", 8 nixosTests, 9 runCommand, 10 python3, 11}: 12 13stdenv.mkDerivation (finalAttrs: { 14 pname = "libxcrypt"; 15 version = "4.4.38"; 16 17 src = fetchurl { 18 url = "https://github.com/besser82/libxcrypt/releases/download/v${finalAttrs.version}/libxcrypt-${finalAttrs.version}.tar.xz"; 19 hash = "sha256-gDBLnDBup5kyfwHZp1Sb2ygxd4kYJjHxtU9FEbQgbdY="; 20 }; 21 22 # this could be accomplished by updateAutotoolsGnuConfigScriptsHook, but that causes infinite recursion 23 # necessary for FreeBSD code path in configure 24 postPatch = '' 25 substituteInPlace ./build-aux/m4-autogen/config.guess --replace-fail /usr/bin/uname uname 26 ''; 27 28 outputs = [ 29 "out" 30 "man" 31 ]; 32 33 configureFlags = [ 34 "--enable-hashes=${enableHashes}" 35 "--enable-obsolete-api=glibc" 36 "--disable-failure-tokens" 37 # required for musl, android, march=native 38 "--disable-werror" 39 ]; 40 41 makeFlags = 42 let 43 lld17Plus = stdenv.cc.bintools.isLLVM && lib.versionAtLeast stdenv.cc.bintools.version "17"; 44 in 45 [ ] 46 # fixes: can't build x86_64-w64-mingw32 shared library unless -no-undefined is specified 47 ++ lib.optionals stdenv.hostPlatform.isWindows [ "LDFLAGS+=-no-undefined" ] 48 49 # lld 17 sets `--no-undefined-version` by default and `libxcrypt`'s 50 # version script unconditionally lists legacy compatibility symbols, even 51 # when not exported: https://github.com/besser82/libxcrypt/issues/181 52 ++ lib.optionals lld17Plus [ "LDFLAGS+=-Wl,--undefined-version" ]; 53 54 nativeBuildInputs = [ 55 perl 56 ]; 57 58 enableParallelBuilding = true; 59 60 doCheck = true; 61 62 passthru = { 63 tests = { 64 inherit (nixosTests) login shadow; 65 66 passthruMatches = runCommand "libxcrypt-test-passthru-matches" { } '' 67 ${python3.interpreter} "${./check_passthru_matches.py}" ${ 68 lib.escapeShellArgs ( 69 [ 70 finalAttrs.src 71 enableHashes 72 "--" 73 ] 74 ++ finalAttrs.passthru.enabledCryptSchemeIds 75 ) 76 } 77 touch "$out" 78 ''; 79 }; 80 enabledCryptSchemeIds = [ 81 # https://github.com/besser82/libxcrypt/blob/v4.4.35/lib/hashes.conf 82 "y" # yescrypt 83 "gy" # gost_yescrypt 84 "7" # scrypt 85 "2b" # bcrypt 86 "2y" # bcrypt_y 87 "2a" # bcrypt_a 88 "6" # sha512crypt 89 ]; 90 }; 91 92 meta = with lib; { 93 changelog = "https://github.com/besser82/libxcrypt/blob/v${finalAttrs.version}/NEWS"; 94 description = "Extended crypt library for descrypt, md5crypt, bcrypt, and others"; 95 homepage = "https://github.com/besser82/libxcrypt/"; 96 platforms = platforms.all; 97 maintainers = with maintainers; [ 98 dottedmag 99 hexa 100 ]; 101 license = licenses.lgpl21Plus; 102 }; 103})