diff --git a/flake.nix b/flake.nix index 2db559f..2c3e627 100644 --- a/flake.nix +++ b/flake.nix @@ -54,6 +54,7 @@ ) // { overlays.default = final: prev: { + apotris = final.callPackage ./packages/apotris { }; attic = final.callPackage ./packages/attic { }; attic-client = final.attic.override { clientOnly = true; }; cups-dymo-patched = final.callPackage ./packages/cups-dymo { }; diff --git a/packages/apotris/default.nix b/packages/apotris/default.nix new file mode 100644 index 0000000..7952719 --- /dev/null +++ b/packages/apotris/default.nix @@ -0,0 +1,78 @@ +{ + lib, + stdenv, + fetchFromGitea, + cmake, + meson, + ninja, + pkg-config, + python3, + xxd, + + SDL2, + SDL2_mixer, + libX11, + libXScrnSaver, + libXcursor, + libXext, + libXfixes, + libXi, + libXrandr, + libogg, + libopus, + zlib, +}: + +stdenv.mkDerivation rec { + pname = "apotris"; + version = "4.0.2"; + + src = fetchFromGitea { + domain = "gitea.com"; + owner = "akouzoukos"; + repo = pname; + fetchSubmodules = true; + rev = "v${version}"; + hash = "sha256-w9uv7A1UIn82ORyyvT8dxWHUK9chVfJ191bnI53sANU="; + }; + + patches = [ ./paths.patch ]; + + nativeBuildInputs = [ + meson + cmake + ninja + pkg-config + python3 + xxd + ]; + + buildInputs = [ + SDL2 + SDL2_mixer + libX11 + libXScrnSaver + libXcursor + libXext + libXfixes + libXi + libXrandr + libogg + libopus + zlib + ]; + + postPatch = '' + patchShebangs --build tools + substituteAllInPlace source/liba_window.cpp + ''; + + meta = with lib; { + description = "Multiplatform open-source block stacking game"; + mainProgram = "Apotris"; + homepage = "https://apotris.com"; + license = licenses.agpl3Only; + maintainers = with maintainers; [ artemist ]; + platforms = platforms.unix; + }; +} diff --git a/packages/apotris/paths.patch b/packages/apotris/paths.patch new file mode 100644 index 0000000..7363df7 --- /dev/null +++ b/packages/apotris/paths.patch @@ -0,0 +1,52 @@ +diff --git a/source/liba_window.cpp b/source/liba_window.cpp +index 5c05b92..b3dfacf 100644 +--- a/source/liba_window.cpp ++++ b/source/liba_window.cpp +@@ -6,6 +6,7 @@ + #include + #include + #include ++#include + + #include "def.h" + +@@ -85,7 +86,7 @@ void windowInit(){ + + refreshWindowSize(); + +- loadAudio(""); ++ loadAudio("@out@/"); + + nanotime_step_init(&stepper, (uint64_t) (NANOTIME_NSEC_PER_SEC / FPS_TARGET), nanotime_now_max(),nanotime_now,nanotime_sleep); + +@@ -334,9 +335,20 @@ void toggleRendering(bool r){ + + void initRumble(){}; + ++static std::string savePath() { ++ char *home; ++ if((home = getenv("XDG_DATA_HOME")) != NULL) { ++ return std::string(home) + "/Apotris.sav"; ++ } ++ if((home = getenv("HOME")) != NULL) { ++ return std::string(home) + "/.local/share/Apotris.sav"; ++ } ++ return "Apotris.sav"; ++} ++ + void loadSavefile(){ + +- std::ifstream input("Apotris.sav",std::ios::binary | std::ios::in); ++ std::ifstream input(savePath(),std::ios::binary | std::ios::in); + + if(savefile == nullptr) + savefile = new Save(); +@@ -355,7 +367,7 @@ void loadSavefile(){ + + void saveSavefile(){ + +- std::ofstream output("Apotris.sav",std::ios::binary | std::ios::out); ++ std::ofstream output(savePath(),std::ios::binary | std::ios::out); + + char * dst = (char * ) savefile; +