Merge pull request #254749 from fgaz/shattered-pixel-dungeon/mods

This commit is contained in:
Franz Pletz 2023-10-31 15:56:21 +01:00 committed by GitHub
commit a7aba55a13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 323 additions and 106 deletions

View File

@ -1,16 +1,9 @@
{ lib, stdenv
, makeWrapper
{ callPackage
, fetchFromGitHub
, nixosTests
, gradle
, perl
, jre
, libpulseaudio
, makeDesktopItem
, copyDesktopItems
}:
let
callPackage ./generic.nix rec {
pname = "shattered-pixel-dungeon";
version = "2.1.4";
@ -21,103 +14,17 @@ let
hash = "sha256-WbRvsHxTYYlhJavYVGMGK25fXEfSfnIztJ6KuCgBjF8=";
};
patches = [
./disable-beryx.patch
];
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|robovm)/ ... /^}/" build.gradle
# Remove unbuildable Android/iOS stuff
rm android/build.gradle ios/build.gradle
'';
# fake build to pre-download deps into fixed-output derivation
deps = stdenv.mkDerivation {
pname = "${pname}-deps";
inherit version src patches postPatch;
nativeBuildInputs = [ gradle perl ];
buildPhase = ''
export GRADLE_USER_HOME=$(mktemp -d)
# https://github.com/gradle/gradle/issues/4426
${lib.optionalString stdenv.isDarwin "export TERM=dumb"}
gradle --no-daemon desktop:release
'';
# 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";
outputHash = "sha256-i4k5tdo07E1NJwywroaGvRjZ+/xrDp6ra+GTYwTB7uk=";
};
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" ];
};
in stdenv.mkDerivation rec {
inherit pname version src patches postPatch;
nativeBuildInputs = [ gradle perl makeWrapper copyDesktopItems ];
desktopItems = [ desktopItem ];
buildPhase = ''
runHook preBuild
export GRADLE_USER_HOME=$(mktemp -d)
# https://github.com/gradle/gradle/issues/4426
${lib.optionalString stdenv.isDarwin "export TERM=dumb"}
# point to offline repo
sed -ie "s#repositories {#repositories { maven { url '${deps}' };#g" build.gradle
gradle --offline --no-daemon desktop:release
runHook postBuild
'';
installPhase = ''
runHook preInstall
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 \
--prefix LD_LIBRARY_PATH : ${libpulseaudio}/lib \
--add-flags "-jar $out/share/shattered-pixel-dungeon.jar"
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
'';
depsHash = "sha256-i4k5tdo07E1NJwywroaGvRjZ+/xrDp6ra+GTYwTB7uk=";
passthru.tests = {
shattered-pixel-dungeon-starts = nixosTests.shattered-pixel-dungeon;
};
meta = with lib; {
desktopName = "Shattered Pixel Dungeon";
meta = {
homepage = "https://shatteredpixel.com/";
downloadPage = "https://github.com/00-Evan/shattered-pixel-dungeon/releases";
description = "Traditional roguelike game with pixel-art graphics and simple interface";
sourceProvenance = with sourceTypes; [
fromSource
binaryBytecode # deps
];
license = licenses.gpl3Plus;
maintainers = with maintainers; [ fgaz ];
platforms = platforms.all;
# https://github.com/NixOS/nixpkgs/pull/99885#issuecomment-740065005
broken = stdenv.isDarwin;
};
}

View File

@ -38,10 +38,3 @@ index 97f35f7..afd5116 100644
dependencies {
implementation project(':core')
@@ -123,4 +124,4 @@ dependencies {
implementation project(':services:updates:githubUpdates')
implementation project(':services:news:shatteredNews')
-}
\ No newline at end of file
+}

View File

@ -0,0 +1,29 @@
diff --git a/build.gradle b/build.gradle
--- a/build.gradle
+++ b/build.gradle
@@ -11,7 +11,6 @@ buildscript {
//FIXME the version of R8 coming with gradle plugin 4.0.0 causes serious problems
//noinspection GradleDependency
classpath 'com.android.tools.build:gradle:3.6.4'
- classpath "com.palantir.gradle.gitversion:gradle-git-version:0.12.3"
}
}
@@ -19,16 +18,13 @@ buildscript {
allprojects {
- apply plugin: "com.palantir.git-version"
-
- def details = versionDetails()
ext {
appName = 'Summoning Pixel Dungeon'
appPackageName = 'com.trashboxbobylev.summoningpixeldungeon'
appVersionCode = 430
- appVersionName = '@version@-' + details.gitHash.substring(0, 7)
+ appVersionName = '@version@'
appAndroidCompileSDK = 33
appAndroidMinSDK = 15

View File

@ -0,0 +1,30 @@
{ callPackage
, fetchFromGitHub
}:
callPackage ./generic.nix rec {
pname = "experienced-pixel-dungeon";
version = "2.15.3";
src = fetchFromGitHub {
owner = "TrashboxBobylev";
repo = "Experienced-Pixel-Dungeon-Redone";
rev = "ExpPD-${version}";
hash = "sha256-qwZk08e+GX8YAVnOZCQ6sIIfV06lWn5bM6/PKD0PAH0=";
};
postPatch = ''
substituteInPlace build.gradle \
--replace "gdxControllersVersion = '2.2.3-SNAPSHOT'" "gdxControllersVersion = '2.2.3'"
'';
depsHash = "sha256-MUUeWZUCVPakK1MJwn0lPnjAlLpPWB/J17Ad68XRcHg=";
desktopName = "Experienced Pixel Dungeon";
meta = {
homepage = "https://github.com/TrashboxBobylev/Experienced-Pixel-Dungeon-Redone";
downloadPage = "https://github.com/TrashboxBobylev/Experienced-Pixel-Dungeon-Redone/releases";
description = "A fork of the Shattered Pixel Dungeon roguelike without limits on experience and items";
};
}

View File

@ -0,0 +1,137 @@
# Generic builder for shattered pixel forks/mods
{ pname
, version
, src
, depsHash
, meta
, desktopName
, patches ? [ ./disable-beryx.patch ]
, lib
, stdenv
, makeWrapper
, gradle
, perl
, jre
, libpulseaudio
, makeDesktopItem
, copyDesktopItems
, ...
}@attrs:
let
cleanAttrs = builtins.removeAttrs attrs [
"lib"
"stdenv"
"makeWrapper"
"gradle"
"perl"
"jre"
"libpulseaudio"
"makeDesktopItem"
"copyDesktopItems"
];
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|robovm|git-version)/ ... /^}/" build.gradle
# Remove unbuildable Android/iOS stuff
rm -f android/build.gradle ios/build.gradle
${attrs.postPatch or ""}
'';
desktopItem = makeDesktopItem {
name = pname;
inherit desktopName;
comment = meta.description;
icon = pname;
exec = pname;
terminal = false;
categories = [ "Game" "AdventureGame" ];
keywords = [ "roguelike" "dungeon" "crawler" ];
};
# fake build to pre-download deps into fixed-output derivation
deps = stdenv.mkDerivation {
pname = "${pname}-deps";
inherit version src patches postPatch;
nativeBuildInputs = [ gradle perl ] ++ attrs.nativeBuildInputs or [];
buildPhase = ''
export GRADLE_USER_HOME=$(mktemp -d)
# https://github.com/gradle/gradle/issues/4426
${lib.optionalString stdenv.isDarwin "export TERM=dumb"}
gradle --no-daemon desktop:release
'';
# 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";
outputHash = depsHash;
};
in stdenv.mkDerivation (cleanAttrs // {
inherit pname version src patches postPatch;
nativeBuildInputs = [
gradle
perl
makeWrapper
copyDesktopItems
] ++ attrs.nativeBuildInputs or [];
desktopItems = [ desktopItem ];
buildPhase = ''
runHook preBuild
export GRADLE_USER_HOME=$(mktemp -d)
# https://github.com/gradle/gradle/issues/4426
${lib.optionalString stdenv.isDarwin "export TERM=dumb"}
# point to offline repo
sed -ie "s#repositories {#repositories { maven { url '${deps}' };#g" build.gradle
gradle --offline --no-daemon desktop:release
runHook postBuild
'';
installPhase = ''
runHook preInstall
install -Dm644 desktop/build/libs/desktop-*.jar $out/share/${pname}.jar
mkdir $out/bin
makeWrapper ${jre}/bin/java $out/bin/${pname} \
--prefix LD_LIBRARY_PATH : ${libpulseaudio}/lib \
--add-flags "-jar $out/share/${pname}.jar"
for s in 16 32 48 64 128 256; do
# Some forks only have some icons and/or name them slightly differently
if [ -f desktop/src/main/assets/icons/icon_$s.png ]; then
install -Dm644 desktop/src/main/assets/icons/icon_$s.png \
$out/share/icons/hicolor/''${s}x$s/apps/${pname}.png
fi
if [ -f desktop/src/main/assets/icons/icon_''${s}x$s.png ]; then
install -Dm644 desktop/src/main/assets/icons/icon_''${s}x$s.png \
$out/share/icons/hicolor/''${s}x$s/apps/${pname}.png
fi
done
runHook postInstall
'';
meta = with lib; {
sourceProvenance = with sourceTypes; [
fromSource
binaryBytecode # deps
];
license = licenses.gpl3Plus;
maintainers = with maintainers; [ fgaz ];
platforms = platforms.all;
# https://github.com/NixOS/nixpkgs/pull/99885#issuecomment-740065005
broken = stdenv.isDarwin;
mainProgram = pname;
} // meta;
})

View File

@ -0,0 +1,25 @@
{ callPackage
, fetchFromGitHub
}:
callPackage ./generic.nix rec {
pname = "rat-king-adventure";
version = "1.5.2a";
src = fetchFromGitHub {
owner = "TrashboxBobylev";
repo = "Rat-King-Adventure";
rev = version;
hash = "sha256-UgUm7GIn1frS66YYrx+ax+oqMKnQnDlqpn9e1kWwDzo=";
};
depsHash = "sha256-yE6zuLnFLtNq76AhtyE+giGLF2vcCqF7sfIvcY8W6Lg=";
desktopName = "Rat King Adventure";
meta = {
homepage = "https://github.com/TrashboxBobylev/Rat-King-Adventure";
downloadPage = "https://github.com/TrashboxBobylev/Rat-King-Adventure/releases";
description = "An expansive fork of RKPD2, itself a fork of the Shattered Pixel Dungeon roguelike";
};
}

View File

@ -0,0 +1,25 @@
{ callPackage
, fetchFromGitHub
}:
callPackage ./generic.nix rec {
pname = "rkpd2";
version = "1.0.0";
src = fetchFromGitHub {
owner = "Zrp200";
repo = "rkpd2";
rev = "v${version}";
hash = "sha256-3WKQCXFDyliObXaIRp3x0kRh3XeNd24SCoTgdFA8/rM=";
};
depsHash = "sha256-yE6zuLnFLtNq76AhtyE+giGLF2vcCqF7sfIvcY8W6Lg=";
desktopName = "Rat King Pixel Dungeon 2";
meta = {
homepage = "https://github.com/Zrp200/rkpd2";
downloadPage = "https://github.com/Zrp200/rkpd2/releases";
description = "Fork of popular roguelike game Shattered Pixel Dungeon that drastically buffs heroes and thus makes the game significantly easier";
};
}

View File

@ -0,0 +1,30 @@
{ callPackage
, fetchFromGitHub
}:
callPackage ./generic.nix rec {
pname = "shorter-pixel-dungeon";
version = "1.2.0";
src = fetchFromGitHub {
owner = "TrashboxBobylev";
repo = "Shorter-Pixel-Dungeon";
rev = "Short-${version}";
hash = "sha256-8vmh65XlNqfIh4WHLPuWU68tb3ajKI8kBMI68CYlsSk=";
};
postPatch = ''
substituteInPlace build.gradle \
--replace "gdxControllersVersion = '2.2.4-SNAPSHOT'" "gdxControllersVersion = '2.2.3'"
'';
depsHash = "sha256-MUUeWZUCVPakK1MJwn0lPnjAlLpPWB/J17Ad68XRcHg=";
desktopName = "Shorter Pixel Dungeon";
meta = {
homepage = "https://github.com/TrashboxBobylev/Shorter-Pixel-Dungeon";
downloadPage = "https://github.com/TrashboxBobylev/Shorter-Pixel-Dungeon/releases";
description = "A shorter fork of the Shattered Pixel Dungeon roguelike";
};
}

View File

@ -0,0 +1,36 @@
{ callPackage
, fetchFromGitHub
, gradle_6
, substitute
}:
callPackage ./generic.nix rec {
pname = "summoning-pixel-dungeon";
version = "1.2.5";
src = fetchFromGitHub {
owner = "TrashboxBobylev";
repo = "Summoning-Pixel-Dungeon";
# The GH release is named "$version-$hash", but it's actually a mutable "_latest" tag
rev = "fc63a89a0f9bdf9cb86a750dfec65bc56d9fddcb";
hash = "sha256-n1YR7jYJ8TQFe654aERgmOHRgaPZ82eXxu0K12/5MGw=";
};
patches = [(substitute {
src = ./disable-git-version.patch;
replacements = [ "--subst-var-by" "version" version ];
})];
depsHash = "sha256-0P/BcjNnbDN25DguRcCyzPuUG7bouxEx1ySodIbSwvg=";
desktopName = "Summoning Pixel Dungeon";
meta = {
homepage = "https://github.com/TrashboxBobylev/Summoning-Pixel-Dungeon";
downloadPage = "https://github.com/TrashboxBobylev/Summoning-Pixel-Dungeon/releases";
description = "A fork of the Shattered Pixel Dungeon roguelike with added summoning mechanics";
};
# Probably due to https://github.com/gradle/gradle/issues/17236
gradle = gradle_6;
}

View File

@ -38324,6 +38324,11 @@ with pkgs;
};
shattered-pixel-dungeon = callPackage ../games/shattered-pixel-dungeon { };
rkpd2 = callPackage ../games/shattered-pixel-dungeon/rkpd2.nix { };
rat-king-adventure = callPackage ../games/shattered-pixel-dungeon/rat-king-adventure.nix { };
experienced-pixel-dungeon = callPackage ../games/shattered-pixel-dungeon/experienced-pixel-dungeon.nix { };
summoning-pixel-dungeon = callPackage ../games/shattered-pixel-dungeon/summoning-pixel-dungeon.nix { };
shorter-pixel-dungeon = callPackage ../games/shattered-pixel-dungeon/shorter-pixel-dungeon.nix { };
shticker-book-unwritten = callPackage ../games/shticker-book-unwritten { };