1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 fetchpatch,
6 fixDarwinDylibNames,
7}:
8
9stdenv.mkDerivation rec {
10 pname = "libargon2";
11 version = "20190702";
12
13 src = fetchFromGitHub {
14 owner = "P-H-C";
15 repo = "phc-winner-argon2";
16 rev = version;
17 sha256 = "0p4ry9dn0mi9js0byijxdyiwx74p1nr8zj7wjpd1fjgqva4sk23i";
18 };
19
20 nativeBuildInputs = lib.optionals stdenv.hostPlatform.isDarwin [
21 fixDarwinDylibNames
22 ];
23
24 patches = [
25 # TODO: remove when https://github.com/P-H-C/phc-winner-argon2/pull/277 is merged + released
26 (fetchpatch {
27 url = "https://github.com/P-H-C/phc-winner-argon2/commit/cd1c1d8d204e4ec4557e358013567c097cb70562.patch";
28 sha256 = "0whqv8b6q9602n7vxpzbd8bk8wz22r1jz9x5lrm9z7ib3wz81c8a";
29 })
30 ];
31
32 makeFlags = [
33 "AR=${stdenv.cc.targetPrefix}ar" # Fix cross-compilation
34 "PREFIX=${placeholder "out"}"
35 "ARGON2_VERSION=${version}"
36 "LIBRARY_REL=lib"
37 "PKGCONFIG_REL=lib"
38 ]
39 ++ lib.optionals stdenv.hostPlatform.isStatic [
40 "LIBRARIES=$(LIB_ST)"
41 "LINKED_LIB_EXT="
42 ];
43
44 meta = with lib; {
45 description = "Key derivation function that was selected as the winner of the Password Hashing Competition in July 2015";
46 longDescription = ''
47 A password-hashing function created by by Alex Biryukov, Daniel Dinu, and
48 Dmitry Khovratovich. Argon2 was declared the winner of the Password
49 Hashing Competition (PHC). There were 24 submissions and 9 finalists.
50 Catena, Lyra2, Makwa and yescrypt were given special recognition. The PHC
51 recommends using Argon2 rather than legacy algorithms.
52 '';
53 homepage = "https://www.argon2.com/";
54 license = with licenses; [
55 asl20
56 cc0
57 ];
58 maintainers = with maintainers; [
59 taeer
60 olynch
61 ];
62 mainProgram = "argon2";
63 platforms = platforms.all;
64 };
65}