python3Packages.orjson: Disable failing tests on 32 bit
[NixPkgs.git] / pkgs / games / shattered-pixel-dungeon / default.nix
blob81baf3b664ba6d8bdeb2939ca2db2f1fca4044f2
1 { lib, stdenv
2 , makeWrapper
3 , fetchFromGitHub
4 , nixosTests
5 , gradle_6
6 , perl
7 , jre
8 , libpulseaudio
9 }:
11 let
12   pname = "shattered-pixel-dungeon";
13   version = "1.1.2";
15   src = fetchFromGitHub {
16     owner = "00-Evan";
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=";
22   };
24   postPatch = ''
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
30   '';
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 ];
37     buildPhase = ''
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
42     '';
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)
44     installPhase = ''
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' \
47         | sh
48     '';
49     outputHashMode = "recursive";
50     outputHash = "sha256-UI5/ZJbUtEz1Fr+qn6a8kzi9rrP+lVrpBbuDv8TG5y0=";
51   };
53 in stdenv.mkDerivation rec {
54   inherit pname version src postPatch;
56   nativeBuildInputs = [ gradle_6 perl makeWrapper ];
58   buildPhase = ''
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
65   '';
67   installPhase = ''
68     install -Dm644 desktop/build/libs/desktop-${version}.jar $out/share/shattered-pixel-dungeon.jar
69     mkdir $out/bin
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"
73   '';
75   passthru.tests = {
76     shattered-pixel-dungeon-starts = nixosTests.shattered-pixel-dungeon;
77   };
79   meta = with lib; {
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; [
84       fromSource
85       binaryBytecode  # deps
86     ];
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;
92   };