2021-01-15 04:31:39 +00:00
|
|
|
{ lib, stdenv, fetchurl, unzip }:
|
2014-05-27 17:57:50 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2019-08-15 12:41:18 +00:00
|
|
|
pname = "crafty";
|
2016-09-18 19:54:43 +00:00
|
|
|
version = "25.0.1";
|
|
|
|
|
2014-05-27 17:57:50 +00:00
|
|
|
src = fetchurl {
|
2016-09-18 19:54:43 +00:00
|
|
|
url = "http://www.craftychess.com/downloads/source/crafty-${version}.zip";
|
|
|
|
sha256 = "0aqgj2q7kdlgbha01qs869cwyja13bc7q2lh4nfhlba2pklknsm8";
|
2014-05-27 17:57:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
bookBin = fetchurl {
|
2020-04-01 01:11:51 +00:00
|
|
|
url = "http://www.craftychess.com/downloads/book/book.bin";
|
2016-09-18 19:54:43 +00:00
|
|
|
sha256 = "10rrgkr3hxm7pxdbc2jq8b5g74gfhzk4smahks3k8am1cmyq4p7r";
|
2014-05-27 17:57:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
startPgn = fetchurl {
|
2020-04-01 01:11:51 +00:00
|
|
|
url = "http://craftychess.com/downloads/book/start.pgn.gz";
|
2016-09-18 19:54:43 +00:00
|
|
|
sha256 = "12g70mgfifwssfvndzq94pin34dizlixhsga75vgj7dakysi2p7f";
|
2014-05-27 17:57:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
buildInputs = [ unzip ];
|
|
|
|
|
2016-09-18 19:54:43 +00:00
|
|
|
unpackPhase = ''
|
|
|
|
mkdir "craftysrc"
|
|
|
|
unzip $src -d craftysrc
|
|
|
|
gunzip -c $startPgn > "craftysrc/start.pgn"
|
|
|
|
'';
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
cd craftysrc
|
|
|
|
make unix-gcc
|
|
|
|
'';
|
2014-05-27 17:57:50 +00:00
|
|
|
|
|
|
|
installPhase = ''
|
2016-09-18 19:54:43 +00:00
|
|
|
BUILDDIR="$PWD"
|
2014-06-30 12:56:10 +00:00
|
|
|
mkdir -p $out/bin
|
2014-05-27 17:57:50 +00:00
|
|
|
cp -p ./crafty $out/bin
|
|
|
|
|
2014-06-30 12:56:10 +00:00
|
|
|
mkdir -p $out/share/crafty
|
2014-05-27 17:57:50 +00:00
|
|
|
cd $out/share/crafty
|
|
|
|
|
2016-09-18 19:54:43 +00:00
|
|
|
$out/bin/crafty "books create $BUILDDIR/start.pgn 60"
|
2014-05-27 17:57:50 +00:00
|
|
|
rm -f *.001
|
|
|
|
|
2016-09-18 19:54:43 +00:00
|
|
|
cp -p ${bookBin} $out/share/crafty/book.bin
|
2014-05-27 17:57:50 +00:00
|
|
|
|
|
|
|
mv $out/bin/crafty $out/bin/.crafty-wrapped
|
2016-09-18 19:54:43 +00:00
|
|
|
|
2014-05-27 17:57:50 +00:00
|
|
|
cat - > $out/bin/crafty <<EOF
|
|
|
|
#! ${stdenv.shell}
|
2016-09-18 19:54:43 +00: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 17:57:50 +00:00
|
|
|
EOF
|
|
|
|
chmod +x $out/bin/crafty
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = {
|
2020-04-01 01:11:51 +00:00
|
|
|
homepage = "http://www.craftychess.com/";
|
2014-08-24 14:21:08 +00:00
|
|
|
description = "Chess program developed by Dr. Robert M. Hyatt";
|
2021-01-15 04:31:39 +00:00
|
|
|
license = lib.licenses.unfree;
|
|
|
|
platforms = lib.platforms.unix;
|
|
|
|
maintainers = [ lib.maintainers.jwiegley ];
|
2014-05-27 17:57:50 +00:00
|
|
|
};
|
|
|
|
}
|