summary refs log tree commit diff
path: root/pkgs/games/shattered-pixel-dungeon
diff options
context:
space:
mode:
authorFrancesco Gazzetta <fgaz@fgaz.me>2019-09-11 10:09:51 +0200
committerLassulus <github@lassul.us>2019-10-25 20:29:24 +0200
commit7ff539d1d113f9f69aaca9fd8ee1ba7f46cc7b07 (patch)
tree98def663ac927625393a0abad1e51ee840e60e9a /pkgs/games/shattered-pixel-dungeon
parent5d1910c83c2779dea5dd493a7826ab6cc7e4d2f1 (diff)
downloadnixpkgs-7ff539d1d113f9f69aaca9fd8ee1ba7f46cc7b07.tar
nixpkgs-7ff539d1d113f9f69aaca9fd8ee1ba7f46cc7b07.tar.gz
nixpkgs-7ff539d1d113f9f69aaca9fd8ee1ba7f46cc7b07.tar.bz2
nixpkgs-7ff539d1d113f9f69aaca9fd8ee1ba7f46cc7b07.tar.lz
nixpkgs-7ff539d1d113f9f69aaca9fd8ee1ba7f46cc7b07.tar.xz
nixpkgs-7ff539d1d113f9f69aaca9fd8ee1ba7f46cc7b07.tar.zst
nixpkgs-7ff539d1d113f9f69aaca9fd8ee1ba7f46cc7b07.zip
shattered-pixel-dungeon: init at 0.7.4c
Diffstat (limited to 'pkgs/games/shattered-pixel-dungeon')
-rw-r--r--pkgs/games/shattered-pixel-dungeon/default.nix78
1 files changed, 78 insertions, 0 deletions
diff --git a/pkgs/games/shattered-pixel-dungeon/default.nix b/pkgs/games/shattered-pixel-dungeon/default.nix
new file mode 100644
index 00000000000..96ef04045b7
--- /dev/null
+++ b/pkgs/games/shattered-pixel-dungeon/default.nix
@@ -0,0 +1,78 @@
+{ stdenv
+, fetchurl
+, makeWrapper
+, fetchFromGitHub
+, gradle_5
+, perl
+, jre
+, xorg
+, openal
+}:
+
+let
+  pname = "shattered-pixel-dungeon";
+  version = "0.7.4c";
+
+  src = fetchFromGitHub {
+    owner = "00-Evan";
+    repo = "shattered-pixel-dungeon-gdx";
+    rev = "v${version}";
+    sha256 = "0bsr8fnc4pips0dbpizzp347nr875b14vkh4jkgnsv03myq2nva4";
+  };
+
+  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
+  '';
+
+  # 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)
+      gradle --no-daemon desktop:dist
+    '';
+    # 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";
+    outputHash = "1xi0km54rhlfsis50j1v5pqs6fr36dqkmqgvk0j7qyij7i6qjrnj";
+  };
+
+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
+    sed -ie "s#mavenLocal()#mavenLocal(); maven { url '${deps}' }#g" build.gradle
+    gradle --offline --no-daemon desktop:dist
+  '';
+
+  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 \
+      --prefix LD_LIBRARY_PATH : ${xorg.libXxf86vm}/lib:${openal}/lib \
+      --add-flags "-jar $out/share/shattered-pixel-dungeon.jar"
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = "https://shatteredpixel.com/";
+    downloadPage = "https://github.com/00-Evan/shattered-pixel-dungeon-gdx/releases";
+    description = "Traditional roguelike game with pixel-art graphics and simple interface";
+    license = licenses.gpl3;
+    maintainers = with maintainers; [ fgaz ];
+    platforms = platforms.all;
+  };
+}
+