2021-01-11 08:54:33 +01:00
|
|
|
{ lib, stdenv
|
2019-09-11 10:09:51 +02:00
|
|
|
, makeWrapper
|
|
|
|
, fetchFromGitHub
|
2020-08-09 15:20:17 +02:00
|
|
|
, nixosTests
|
2023-05-28 14:42:56 +02:00
|
|
|
, gradle
|
2019-09-11 10:09:51 +02:00
|
|
|
, perl
|
|
|
|
, jre
|
2020-05-16 15:22:38 +02:00
|
|
|
, libpulseaudio
|
2023-07-01 09:00:33 +02:00
|
|
|
, makeDesktopItem
|
|
|
|
, copyDesktopItems
|
2019-09-11 10:09:51 +02:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
pname = "shattered-pixel-dungeon";
|
2023-07-06 06:07:44 +02:00
|
|
|
version = "2.1.3";
|
2019-09-11 10:09:51 +02:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "00-Evan";
|
2020-05-16 15:22:38 +02:00
|
|
|
repo = "shattered-pixel-dungeon";
|
2023-05-28 14:42:56 +02:00
|
|
|
rev = "v${version}";
|
2023-07-06 06:07:44 +02:00
|
|
|
hash = "sha256-eyl5bMIoVpQB4QIQdJvPw4gjMG6OeQPahx6h46YsIXs=";
|
2019-09-11 10:09:51 +02:00
|
|
|
};
|
|
|
|
|
2023-05-28 14:42:56 +02:00
|
|
|
patches = [
|
|
|
|
./disable-beryx.patch
|
|
|
|
];
|
|
|
|
|
2019-09-11 10:09:51 +02:00
|
|
|
postPatch = ''
|
|
|
|
# disable gradle plugins with native code and their targets
|
|
|
|
perl -i.bak1 -pe "s#(^\s*id '.+' version '.+'$)#// \1#" build.gradle
|
2021-08-17 22:40:48 +02:00
|
|
|
perl -i.bak2 -pe "s#(.*)#// \1# if /^(buildscript|task portable|task nsis|task proguard|task tgz|task\(afterEclipseImport\)|launch4j|macAppBundle|buildRpm|buildDeb|shadowJar|robovm)/ ... /^}/" build.gradle
|
|
|
|
# Remove unbuildable Android/iOS stuff
|
|
|
|
rm android/build.gradle ios/build.gradle
|
2019-09-11 10:09:51 +02:00
|
|
|
'';
|
|
|
|
|
|
|
|
# fake build to pre-download deps into fixed-output derivation
|
|
|
|
deps = stdenv.mkDerivation {
|
|
|
|
pname = "${pname}-deps";
|
2023-05-28 14:42:56 +02:00
|
|
|
inherit version src patches postPatch;
|
|
|
|
nativeBuildInputs = [ gradle perl ];
|
2019-09-11 10:09:51 +02:00
|
|
|
buildPhase = ''
|
|
|
|
export GRADLE_USER_HOME=$(mktemp -d)
|
2020-12-02 16:36:44 +01:00
|
|
|
# https://github.com/gradle/gradle/issues/4426
|
2021-01-24 01:40:18 +01:00
|
|
|
${lib.optionalString stdenv.isDarwin "export TERM=dumb"}
|
2020-05-16 15:22:38 +02:00
|
|
|
gradle --no-daemon desktop:release
|
2019-09-11 10:09:51 +02: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
|
|
|
|
'';
|
|
|
|
outputHashMode = "recursive";
|
2023-06-19 12:07:07 +02:00
|
|
|
outputHash = "sha256-i4k5tdo07E1NJwywroaGvRjZ+/xrDp6ra+GTYwTB7uk=";
|
2019-09-11 10:09:51 +02:00
|
|
|
};
|
|
|
|
|
2023-07-01 09:00:33 +02:00
|
|
|
desktopItem = makeDesktopItem {
|
|
|
|
name = "shattered-pixel-dungeon";
|
|
|
|
desktopName = "Shattered Pixel Dungeon";
|
|
|
|
comment = "An open-source traditional roguelike dungeon crawler";
|
|
|
|
icon = "shattered-pixel-dungeon";
|
|
|
|
exec = "shattered-pixel-dungeon";
|
|
|
|
terminal = false;
|
|
|
|
categories = [ "Game" "AdventureGame" ];
|
|
|
|
keywords = [ "roguelike" "dungeon" "crawler" ];
|
|
|
|
};
|
|
|
|
|
2019-09-11 10:09:51 +02:00
|
|
|
in stdenv.mkDerivation rec {
|
2023-05-28 14:42:56 +02:00
|
|
|
inherit pname version src patches postPatch;
|
2019-09-11 10:09:51 +02:00
|
|
|
|
2023-07-01 09:00:33 +02:00
|
|
|
nativeBuildInputs = [ gradle perl makeWrapper copyDesktopItems ];
|
|
|
|
|
|
|
|
desktopItems = [ desktopItem ];
|
2019-09-11 10:09:51 +02:00
|
|
|
|
|
|
|
buildPhase = ''
|
2023-07-01 09:00:33 +02:00
|
|
|
runHook preBuild
|
|
|
|
|
2019-09-11 10:09:51 +02:00
|
|
|
export GRADLE_USER_HOME=$(mktemp -d)
|
2020-12-02 16:36:44 +01:00
|
|
|
# https://github.com/gradle/gradle/issues/4426
|
2021-01-24 01:40:18 +01:00
|
|
|
${lib.optionalString stdenv.isDarwin "export TERM=dumb"}
|
2019-09-11 10:09:51 +02:00
|
|
|
# point to offline repo
|
2020-05-16 15:22:38 +02:00
|
|
|
sed -ie "s#repositories {#repositories { maven { url '${deps}' };#g" build.gradle
|
|
|
|
gradle --offline --no-daemon desktop:release
|
2023-07-01 09:00:33 +02:00
|
|
|
|
|
|
|
runHook postBuild
|
2019-09-11 10:09:51 +02:00
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
2023-07-01 09:00:33 +02:00
|
|
|
runHook preInstall
|
|
|
|
|
2019-09-11 10:09:51 +02:00
|
|
|
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 15:22:38 +02:00
|
|
|
--prefix LD_LIBRARY_PATH : ${libpulseaudio}/lib \
|
2019-09-11 10:09:51 +02:00
|
|
|
--add-flags "-jar $out/share/shattered-pixel-dungeon.jar"
|
2023-07-01 09:00:33 +02:00
|
|
|
|
|
|
|
for s in 16 32 48 64 128 256; do
|
|
|
|
install -Dm644 desktop/src/main/assets/icons/icon_$s.png \
|
|
|
|
$out/share/icons/hicolor/''${s}x$s/apps/shattered-pixel-dungeon.png
|
|
|
|
done
|
|
|
|
|
|
|
|
runHook postInstall
|
2019-09-11 10:09:51 +02:00
|
|
|
'';
|
|
|
|
|
2020-08-09 15:20:17 +02:00
|
|
|
passthru.tests = {
|
|
|
|
shattered-pixel-dungeon-starts = nixosTests.shattered-pixel-dungeon;
|
|
|
|
};
|
|
|
|
|
2021-01-11 08:54:33 +01:00
|
|
|
meta = with lib; {
|
2019-09-11 10:09:51 +02:00
|
|
|
homepage = "https://shatteredpixel.com/";
|
2020-05-16 15:22:38 +02:00
|
|
|
downloadPage = "https://github.com/00-Evan/shattered-pixel-dungeon/releases";
|
2019-09-11 10:09:51 +02:00
|
|
|
description = "Traditional roguelike game with pixel-art graphics and simple interface";
|
2022-06-04 20:07:20 +02:00
|
|
|
sourceProvenance = with sourceTypes; [
|
|
|
|
fromSource
|
|
|
|
binaryBytecode # deps
|
|
|
|
];
|
2021-03-04 13:01:35 +01:00
|
|
|
license = licenses.gpl3Plus;
|
2019-09-11 10:09:51 +02:00
|
|
|
maintainers = with maintainers; [ fgaz ];
|
|
|
|
platforms = platforms.all;
|
2020-12-02 16:36:44 +01:00
|
|
|
# https://github.com/NixOS/nixpkgs/pull/99885#issuecomment-740065005
|
|
|
|
broken = stdenv.isDarwin;
|
2019-09-11 10:09:51 +02:00
|
|
|
};
|
|
|
|
}
|