libargon2: fixed cross-compilation

Makefile had a hardcoded unprefixed ar. I wrote a patch (sending it
upstream) and added an optional make flag to override it in case we're
cross-compiling.

Unfortunately, this causes a rebuild of native packages.

This commit also fixes the pkg-config file to be generated correctly,
patch was provided by @worldofpeace.
This commit is contained in:
Vika 2019-08-26 13:40:21 +03:00
parent 3f6d0a981a
commit 06073ae7df

View File

@ -1,4 +1,4 @@
{ stdenv, fetchFromGitHub }: { stdenv, fetchFromGitHub, fetchpatch }:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "libargon2"; pname = "libargon2";
@ -11,18 +11,21 @@ stdenv.mkDerivation rec {
sha256 = "0p4ry9dn0mi9js0byijxdyiwx74p1nr8zj7wjpd1fjgqva4sk23i"; sha256 = "0p4ry9dn0mi9js0byijxdyiwx74p1nr8zj7wjpd1fjgqva4sk23i";
}; };
installPhase = '' patches = [
runHook preInstall # TODO: remove when https://github.com/P-H-C/phc-winner-argon2/pull/277 is merged + released
mkdir -p $out/lib/pkgconfig (fetchpatch {
substitute libargon2.pc $out/lib/pkgconfig/libargon2.pc \ url = "https://github.com/P-H-C/phc-winner-argon2/commit/cd1c1d8d204e4ec4557e358013567c097cb70562.patch";
--replace @UPSTREAM_VER@ "${version}" \ sha256 = "0whqv8b6q9602n7vxpzbd8bk8wz22r1jz9x5lrm9z7ib3wz81c8a";
--replace @HOST_MULTIARCH@ "" \ })
--replace 'prefix=/usr' "prefix=$out" ];
make install PREFIX=$out LIBRARY_REL=lib makeFlags = [
ln -s $out/lib/libargon2.so $out/lib/libargon2.so.0 "AR=${stdenv.cc.targetPrefix}ar" # Fix cross-compilation
runHook postInstall "PREFIX=${placeholder "out"}"
''; "ARGON2_VERSION=${version}"
"LIBRARY_REL=lib"
"PKGCONFIG_REL=lib"
];
meta = with stdenv.lib; { meta = with stdenv.lib; {
description = "A key derivation function that was selected as the winner of the Password Hashing Competition in July 2015"; description = "A key derivation function that was selected as the winner of the Password Hashing Competition in July 2015";