12 pname = "shattered-pixel-dungeon";
15 src = fetchFromGitHub {
17 repo = "shattered-pixel-dungeon";
18 # NOTE: always use the commit sha, not the tag. Tags _will_ disappear!
19 # https://github.com/00-Evan/shattered-pixel-dungeon/issues/596
20 rev = "5d1a2dce6b554b40f6737ead45d411fd98f4c67d";
21 sha256 = "sha256-Vu7K0NnqFY298BIQV9AwNEahV0eJl14tAeq+rw6KrtM=";
25 # disable gradle plugins with native code and their targets
26 perl -i.bak1 -pe "s#(^\s*id '.+' version '.+'$)#// \1#" build.gradle
27 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
28 # Remove unbuildable Android/iOS stuff
29 rm android/build.gradle ios/build.gradle
32 # fake build to pre-download deps into fixed-output derivation
33 deps = stdenv.mkDerivation {
34 pname = "${pname}-deps";
35 inherit version src postPatch;
36 nativeBuildInputs = [ gradle_6 perl ];
38 export GRADLE_USER_HOME=$(mktemp -d)
39 # https://github.com/gradle/gradle/issues/4426
40 ${lib.optionalString stdenv.isDarwin "export TERM=dumb"}
41 gradle --no-daemon desktop:release
43 # 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)
45 find $GRADLE_USER_HOME/caches/modules-2 -type f -regex '.*\.\(jar\|pom\)' \
46 | perl -pe 's#(.*/([^/]+)/([^/]+)/([^/]+)/[0-9a-f]{30,40}/([^/\s]+))$# ($x = $2) =~ tr|\.|/|; "install -Dm444 $1 \$out/$x/$3/$4/$5" #e' \
49 outputHashMode = "recursive";
50 outputHash = "sha256-UI5/ZJbUtEz1Fr+qn6a8kzi9rrP+lVrpBbuDv8TG5y0=";
53 in stdenv.mkDerivation rec {
54 inherit pname version src postPatch;
56 nativeBuildInputs = [ gradle_6 perl makeWrapper ];
59 export GRADLE_USER_HOME=$(mktemp -d)
60 # https://github.com/gradle/gradle/issues/4426
61 ${lib.optionalString stdenv.isDarwin "export TERM=dumb"}
62 # point to offline repo
63 sed -ie "s#repositories {#repositories { maven { url '${deps}' };#g" build.gradle
64 gradle --offline --no-daemon desktop:release
68 install -Dm644 desktop/build/libs/desktop-${version}.jar $out/share/shattered-pixel-dungeon.jar
70 makeWrapper ${jre}/bin/java $out/bin/shattered-pixel-dungeon \
71 --prefix LD_LIBRARY_PATH : ${libpulseaudio}/lib \
72 --add-flags "-jar $out/share/shattered-pixel-dungeon.jar"
76 shattered-pixel-dungeon-starts = nixosTests.shattered-pixel-dungeon;
80 homepage = "https://shatteredpixel.com/";
81 downloadPage = "https://github.com/00-Evan/shattered-pixel-dungeon/releases";
82 description = "Traditional roguelike game with pixel-art graphics and simple interface";
83 sourceProvenance = with sourceTypes; [
87 license = licenses.gpl3Plus;
88 maintainers = with maintainers; [ fgaz ];
89 platforms = platforms.all;
90 # https://github.com/NixOS/nixpkgs/pull/99885#issuecomment-740065005
91 broken = stdenv.isDarwin;