2016-09-18 21:54:43 +02:00
|
|
|
{ stdenv, fetchurl, unzip }:
|
2014-05-27 19:57:50 +02:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2019-08-15 14:41:18 +02:00
|
|
|
pname = "crafty";
|
2016-09-18 21:54:43 +02:00
|
|
|
version = "25.0.1";
|
|
|
|
|
2014-05-27 19:57:50 +02:00
|
|
|
src = fetchurl {
|
2016-09-18 21:54:43 +02:00
|
|
|
url = "http://www.craftychess.com/downloads/source/crafty-${version}.zip";
|
|
|
|
sha256 = "0aqgj2q7kdlgbha01qs869cwyja13bc7q2lh4nfhlba2pklknsm8";
|
2014-05-27 19:57:50 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
bookBin = fetchurl {
|
2020-04-01 03:11:51 +02:00
|
|
|
url = "http://www.craftychess.com/downloads/book/book.bin";
|
2016-09-18 21:54:43 +02:00
|
|
|
sha256 = "10rrgkr3hxm7pxdbc2jq8b5g74gfhzk4smahks3k8am1cmyq4p7r";
|
2014-05-27 19:57:50 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
startPgn = fetchurl {
|
2020-04-01 03:11:51 +02:00
|
|
|
url = "http://craftychess.com/downloads/book/start.pgn.gz";
|
2016-09-18 21:54:43 +02:00
|
|
|
sha256 = "12g70mgfifwssfvndzq94pin34dizlixhsga75vgj7dakysi2p7f";
|
2014-05-27 19:57:50 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
buildInputs = [ unzip ];
|
|
|
|
|
2016-09-18 21:54:43 +02:00
|
|
|
unpackPhase = ''
|
|
|
|
mkdir "craftysrc"
|
|
|
|
unzip $src -d craftysrc
|
|
|
|
gunzip -c $startPgn > "craftysrc/start.pgn"
|
|
|
|
'';
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
cd craftysrc
|
|
|
|
make unix-gcc
|
|
|
|
'';
|
2014-05-27 19:57:50 +02:00
|
|
|
|
|
|
|
installPhase = ''
|
2016-09-18 21:54:43 +02:00
|
|
|
BUILDDIR="$PWD"
|
2014-06-30 14:56:10 +02:00
|
|
|
mkdir -p $out/bin
|
2014-05-27 19:57:50 +02:00
|
|
|
cp -p ./crafty $out/bin
|
|
|
|
|
2014-06-30 14:56:10 +02:00
|
|
|
mkdir -p $out/share/crafty
|
2014-05-27 19:57:50 +02:00
|
|
|
cd $out/share/crafty
|
|
|
|
|
2016-09-18 21:54:43 +02:00
|
|
|
$out/bin/crafty "books create $BUILDDIR/start.pgn 60"
|
2014-05-27 19:57:50 +02:00
|
|
|
rm -f *.001
|
|
|
|
|
2016-09-18 21:54:43 +02:00
|
|
|
cp -p ${bookBin} $out/share/crafty/book.bin
|
2014-05-27 19:57:50 +02:00
|
|
|
|
|
|
|
mv $out/bin/crafty $out/bin/.crafty-wrapped
|
2016-09-18 21:54:43 +02:00
|
|
|
|
2014-05-27 19:57:50 +02:00
|
|
|
cat - > $out/bin/crafty <<EOF
|
|
|
|
#! ${stdenv.shell}
|
2016-09-18 21:54:43 +02:00
|
|
|
#
|
|
|
|
# The books are copied from share/crafty to ~/.crafty/books the first time
|
|
|
|
# this script is run. You can restore them at any time just copying them
|
|
|
|
# again.
|
|
|
|
if [[ ! -d "\$HOME/.crafty/books" ]]; then
|
|
|
|
mkdir "\$HOME/.crafty/books" -p
|
|
|
|
cp "$out/share/crafty/"book*.bin "\$HOME/.crafty/books"
|
|
|
|
chmod ug+w "\$HOME/.crafty/books/"*
|
|
|
|
fi
|
|
|
|
exec $out/bin/.crafty-wrapped bookpath=\$HOME/.crafty/books "\$@"
|
2014-05-27 19:57:50 +02:00
|
|
|
EOF
|
|
|
|
chmod +x $out/bin/crafty
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = {
|
2020-04-01 03:11:51 +02:00
|
|
|
homepage = "http://www.craftychess.com/";
|
2014-08-24 16:21:08 +02:00
|
|
|
description = "Chess program developed by Dr. Robert M. Hyatt";
|
2014-05-27 19:57:50 +02:00
|
|
|
license = stdenv.lib.licenses.unfree;
|
2014-06-08 11:28:11 +02:00
|
|
|
platforms = stdenv.lib.platforms.unix;
|
2014-05-27 19:57:50 +02:00
|
|
|
maintainers = [ stdenv.lib.maintainers.jwiegley ];
|
|
|
|
};
|
|
|
|
}
|