From 5e3f31204c9d7a7c64ec8ed8b83c4ce249fa577c Mon Sep 17 00:00:00 2001 From: Marcin Serwin Date: Sat, 26 Apr 2025 00:42:12 +0200 Subject: [PATCH] devilutionx: modernize --- .../add-nix-share-path-to-mpq-search.patch | 12 +++ pkgs/games/devilutionx/default.nix | 76 +++++-------------- pkgs/top-level/all-packages.nix | 7 +- 3 files changed, 30 insertions(+), 65 deletions(-) create mode 100644 pkgs/games/devilutionx/add-nix-share-path-to-mpq-search.patch diff --git a/pkgs/games/devilutionx/add-nix-share-path-to-mpq-search.patch b/pkgs/games/devilutionx/add-nix-share-path-to-mpq-search.patch new file mode 100644 index 000000000000..ec8198fcc84e --- /dev/null +++ b/pkgs/games/devilutionx/add-nix-share-path-to-mpq-search.patch @@ -0,0 +1,12 @@ +diff --git a/Source/init.cpp b/Source/init.cpp +index 4e6fab1..ecd4ff9 100644 +--- a/Source/init.cpp ++++ b/Source/init.cpp +@@ -144,6 +144,7 @@ std::vector GetMPQSearchPaths() + paths.emplace_back("/usr/local/share/diasurgical/devilutionx/"); + paths.emplace_back("/usr/share/diasurgical/devilutionx/"); + } ++ paths.emplace_back("@assets@"); + #elif defined(NXDK) + paths.emplace_back("D:\\"); + #elif (defined(_WIN64) || defined(_WIN32)) && !defined(__UWP__) && !defined(NXDK) diff --git a/pkgs/games/devilutionx/default.nix b/pkgs/games/devilutionx/default.nix index ebd203843464..bf72f91e1285 100644 --- a/pkgs/games/devilutionx/default.nix +++ b/pkgs/games/devilutionx/default.nix @@ -8,10 +8,10 @@ pkg-config, gettext, libsodium, - SDL2_classic, + SDL2, SDL2_image, SDL_audiolib, - flac, + simpleini, fmt, libpng, libtiff, @@ -48,37 +48,21 @@ let rev = "d6c6a069a5041a3e89594c447ced3f15d77618b8"; sha256 = "sha256-ttRJLfaGHzhS4jd8db7BNPWROCti3ZxuRouqsL/M5ew="; }; - - # breaks without this version - SDL_audiolib' = SDL_audiolib.overrideAttrs (oldAttrs: { - src = fetchFromGitHub { - owner = "realnc"; - repo = "SDL_audiolib"; - rev = "cc1bb6af8d4cf5e200259072bde1edd1c8c5137e"; - sha256 = "sha256-xP7qlwwOkqVeTlCEZLinnvmx8LbU2co5+t//cf4n190="; - }; - - buildInputs = oldAttrs.buildInputs ++ [ flac ]; - }); - - # missing pkg-config and/or cmake file - simpleini = fetchurl { - url = "https://github.com/brofield/simpleini/archive/56499b5af5d2195c6acfc58c4630b70e0c9c4c21.tar.gz"; - sha256 = "sha256-29tQoz0+33kfwmIjCdnD1wGi+35+K0A9P6UE4E8K3g4="; - }; in -stdenv.mkDerivation rec { +stdenv.mkDerivation (finalAttrs: { pname = "devilutionx"; version = "1.5.4"; src = fetchFromGitHub { owner = "diasurgical"; repo = "devilutionX"; - rev = version; - sha256 = "sha256-F23MTe7vMOgIBH6qm7X1+8gIMmN9E+d/GZnFsQZt2cM="; + tag = finalAttrs.version; + hash = "sha256-F23MTe7vMOgIBH6qm7X1+8gIMmN9E+d/GZnFsQZt2cM="; }; + patches = [ ./add-nix-share-path-to-mpq-search.patch ]; + postPatch = '' substituteInPlace 3rdParty/asio/CMakeLists.txt --replace-fail "${asio.url}" "${asio}" substituteInPlace 3rdParty/libmpq/CMakeLists.txt --replace-fail "${libmpq.url}" "${libmpq}" @@ -86,7 +70,8 @@ stdenv.mkDerivation rec { substituteInPlace 3rdParty/libzt/CMakeLists.txt \ --replace-fail "GIT_REPOSITORY https://github.com/diasurgical/libzt.git" "" \ --replace-fail "GIT_TAG ${libzt.rev}" "SOURCE_DIR ${libzt}" - substituteInPlace 3rdParty/simpleini/CMakeLists.txt --replace-fail "${simpleini.url}" "${simpleini}" + substituteInPlace Source/init.cpp \ + --replace-fail "@assets@" "$out/share/diasurgical/devilutionx/" ''; nativeBuildInputs = [ @@ -103,49 +88,22 @@ stdenv.mkDerivation rec { libtiff libwebp libsodium - SDL2_classic + SDL2 SDL2_image - SDL_audiolib' + SDL_audiolib + simpleini ]; - installPhase = - '' - runHook preInstall - - '' - + ( - if stdenv.hostPlatform.isDarwin then - '' - mkdir -p $out/Applications - mv devilutionx.app $out/Applications - '' - else - '' - install -Dm755 -t $out/bin devilutionx - install -Dm755 -t $out/bin devilutionx.mpq - install -Dm755 -t $out/share/diasurgical/devilutionx devilutionx.mpq - install -Dm755 -t $out/share/applications ../Packaging/nix/devilutionx-hellfire.desktop ../Packaging/nix/devilutionx.desktop - install -Dm755 ../Packaging/resources/icon.png $out/share/icons/hicolor/512x512/apps/devilutionx.png - install -Dm755 ../Packaging/resources/hellfire.png $out/share/icons/hicolor/512x512/apps/devilutionx-hellfire.png - install -Dm755 ../Packaging/resources/icon_32.png $out/share/icons/hicolor/32x32/apps/devilutionx.png - install -Dm755 ../Packaging/resources/hellfire_32.png $out/share/icons/hicolor/32x32/apps/devilutionx-hellfire.png - '' - ) - + '' - - runHook postInstall - ''; - - meta = with lib; { + meta = { homepage = "https://github.com/diasurgical/devilutionX"; description = "Diablo build for modern operating systems"; mainProgram = "devilutionx"; longDescription = "In order to play this game a copy of diabdat.mpq is required. Place a copy of diabdat.mpq in ~/.local/share/diasurgical/devilution before executing the game."; - license = licenses.sustainableUse; - maintainers = with maintainers; [ + license = lib.licenses.sustainableUse; + maintainers = with lib.maintainers; [ karolchmist aanderse ]; - platforms = platforms.linux ++ platforms.windows; + platforms = with lib.platforms; linux ++ windows; }; -} +}) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 5e79fba3425e..c92f57c14875 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -17020,12 +17020,7 @@ with pkgs; ddnet-server = ddnet.override { buildClient = false; }; - devilutionx = callPackage ../games/devilutionx { - fmt = fmt_9; - SDL2_classic = SDL2_classic.override { - withStatic = true; - }; - }; + devilutionx = callPackage ../games/devilutionx { }; duckmarines = callPackage ../games/duckmarines { love = love_0_10; };