gnushogi: refactor, unbreak on darwin

This commit is contained in:
Weijia Wang 2023-05-26 12:39:40 +03:00
parent 027259f359
commit 60849da99a

View File

@ -1,21 +1,31 @@
{ lib, stdenv, fetchurl, zlib }:
{ lib
, stdenv
, fetchurl
, fetchpatch
, zlib
}:
stdenv.mkDerivation rec {
pname = "gnushogi";
version = "1.4.2";
buildInputs = [ zlib ];
src = fetchurl {
url = "mirror://gnu/gnushogi/${pname}-${version}.tar.gz";
sha256 = "0a9bsl2nbnb138lq0h14jfc5xvz7hpb2bcsj4mjn6g1hcsl4ik0y";
hash = "sha256-HsxIqGYwPGNlJVKzJdaF5+9emJMkQIApGmHZZQXVKyk=";
};
env.LDFLAGS = lib.optionalString (!stdenv.isDarwin) "-Wl,-z,muldefs";
patches = [
(fetchpatch {
url = "https://sources.debian.org/data/main/g/gnushogi/1.4.2-7/debian/patches/01-make-dont-ignore";
hash = "sha256-Aw0zfH+wkj+rQQzKIn6bSilP76YIO27FwJ8n1UzG6ow=";
})
(fetchpatch {
url = "https://sources.debian.org/data/main/g/gnushogi/1.4.2-7/debian/patches/globals";
hash = "sha256-wZJBPMYSz4n1kOyLmR9QOp70650R9xXQUWD5hvaMRok=";
})
];
# Makefile ignores errors, so the build may silently succeed erroneously
postBuild = ''
test -e gnushogi/gnushogi || { echo "ERROR: no binary produced"; exit 1; }
'';
buildInputs = [ zlib ];
meta = with lib; {
description = "GNU implementation of Shogi, also known as Japanese Chess";
@ -23,6 +33,5 @@ stdenv.mkDerivation rec {
license = licenses.gpl3;
maintainers = [ maintainers.ciil ];
platforms = platforms.unix;
broken = stdenv.isDarwin; # darwin does not support -z muldefs
};
}