2019-09-11 09:09:51 +01:00
|
|
|
{ stdenv
|
|
|
|
, makeWrapper
|
|
|
|
, fetchFromGitHub
|
|
|
|
, gradle_5
|
|
|
|
, perl
|
|
|
|
, jre
|
2020-05-16 14:22:38 +01:00
|
|
|
, libpulseaudio
|
2019-09-11 09:09:51 +01:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
pname = "shattered-pixel-dungeon";
|
2020-06-29 11:27:13 +01:00
|
|
|
version = "0.8.1";
|
2019-09-11 09:09:51 +01:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "00-Evan";
|
2020-05-16 14:22:38 +01:00
|
|
|
repo = "shattered-pixel-dungeon";
|
2019-09-11 09:09:51 +01:00
|
|
|
rev = "v${version}";
|
2020-06-29 11:27:13 +01:00
|
|
|
sha256 = "1n459xdvqf974hs91xfq5fdj29s4w5w83dg3m2vp7gqmrmm2jykf";
|
2019-09-11 09:09:51 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
# disable gradle plugins with native code and their targets
|
|
|
|
perl -i.bak1 -pe "s#(^\s*id '.+' version '.+'$)#// \1#" build.gradle
|
|
|
|
perl -i.bak2 -pe "s#(.*)#// \1# if /^(buildscript|task portable|task nsis|task proguard|task tgz|task\(afterEclipseImport\)|launch4j|macAppBundle|buildRpm|buildDeb|shadowJar)/ ... /^}/" build.gradle
|
2020-05-16 14:22:38 +01:00
|
|
|
# Remove unbuildable android stuff
|
|
|
|
rm android/build.gradle
|
2019-09-11 09:09:51 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
# fake build to pre-download deps into fixed-output derivation
|
|
|
|
deps = stdenv.mkDerivation {
|
|
|
|
pname = "${pname}-deps";
|
|
|
|
inherit version src postPatch;
|
|
|
|
nativeBuildInputs = [ gradle_5 perl ];
|
|
|
|
buildPhase = ''
|
|
|
|
export GRADLE_USER_HOME=$(mktemp -d)
|
2020-05-16 14:22:38 +01:00
|
|
|
gradle --no-daemon desktop:release
|
2019-09-11 09:09:51 +01:00
|
|
|
'';
|
|
|
|
# perl code mavenizes pathes (com.squareup.okio/okio/1.13.0/a9283170b7305c8d92d25aff02a6ab7e45d06cbe/okio-1.13.0.jar -> com/squareup/okio/okio/1.13.0/okio-1.13.0.jar)
|
|
|
|
installPhase = ''
|
|
|
|
find $GRADLE_USER_HOME/caches/modules-2 -type f -regex '.*\.\(jar\|pom\)' \
|
|
|
|
| perl -pe 's#(.*/([^/]+)/([^/]+)/([^/]+)/[0-9a-f]{30,40}/([^/\s]+))$# ($x = $2) =~ tr|\.|/|; "install -Dm444 $1 \$out/$x/$3/$4/$5" #e' \
|
|
|
|
| sh
|
|
|
|
'';
|
|
|
|
outputHashAlgo = "sha256";
|
|
|
|
outputHashMode = "recursive";
|
2020-05-16 14:22:38 +01:00
|
|
|
outputHash = "0ih10c6c85vhrqgilqmkzqjx3dc8cscvs9wkh90zgdj10qv0iba3";
|
2019-09-11 09:09:51 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
in stdenv.mkDerivation rec {
|
|
|
|
inherit pname version src postPatch;
|
|
|
|
|
|
|
|
nativeBuildInputs = [ gradle_5 perl makeWrapper ];
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
export GRADLE_USER_HOME=$(mktemp -d)
|
|
|
|
# point to offline repo
|
2020-05-16 14:22:38 +01:00
|
|
|
sed -ie "s#repositories {#repositories { maven { url '${deps}' };#g" build.gradle
|
|
|
|
gradle --offline --no-daemon desktop:release
|
2019-09-11 09:09:51 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
install -Dm644 desktop/build/libs/desktop-${version}.jar $out/share/shattered-pixel-dungeon.jar
|
|
|
|
mkdir $out/bin
|
|
|
|
makeWrapper ${jre}/bin/java $out/bin/shattered-pixel-dungeon \
|
2020-05-16 14:22:38 +01:00
|
|
|
--prefix LD_LIBRARY_PATH : ${libpulseaudio}/lib \
|
2019-09-11 09:09:51 +01:00
|
|
|
--add-flags "-jar $out/share/shattered-pixel-dungeon.jar"
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
|
|
|
homepage = "https://shatteredpixel.com/";
|
2020-05-16 14:22:38 +01:00
|
|
|
downloadPage = "https://github.com/00-Evan/shattered-pixel-dungeon/releases";
|
2019-09-11 09:09:51 +01:00
|
|
|
description = "Traditional roguelike game with pixel-art graphics and simple interface";
|
|
|
|
license = licenses.gpl3;
|
|
|
|
maintainers = with maintainers; [ fgaz ];
|
|
|
|
platforms = platforms.all;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|