about summary refs log tree commit diff
path: root/pkgs/by-name/sr/srb2
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/by-name/sr/srb2')
-rw-r--r--pkgs/by-name/sr/srb2/cmake.patch61
-rw-r--r--pkgs/by-name/sr/srb2/package.nix120
-rw-r--r--pkgs/by-name/sr/srb2/thirdparty.patch12
3 files changed, 193 insertions, 0 deletions
diff --git a/pkgs/by-name/sr/srb2/cmake.patch b/pkgs/by-name/sr/srb2/cmake.patch
new file mode 100644
index 0000000000000..91af532e86fb3
--- /dev/null
+++ b/pkgs/by-name/sr/srb2/cmake.patch
@@ -0,0 +1,61 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 80a3bdcd6..380a1573a 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -61,7 +61,7 @@ option(
+ 	"Link dependencies using CMake's find_package and do not use internal builds"
+ 	${SRB2_CONFIG_SYSTEM_LIBRARIES_DEFAULT}
+ )
+-option(SRB2_CONFIG_ENABLE_TESTS "Build the test suite" ON)
++option(SRB2_CONFIG_ENABLE_TESTS "Build the test suite" OFF)
+ # This option isn't recommended for distribution builds and probably won't work (yet).
+ cmake_dependent_option(
+ 	SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES
+@@ -80,25 +80,6 @@ option(SRB2_CONFIG_ZDEBUG "Compile with ZDEBUG defined." OFF)
+ option(SRB2_CONFIG_PROFILEMODE "Compile for profiling (GCC only)." OFF)
+ set(SRB2_CONFIG_ASSET_DIRECTORY "" CACHE PATH "Path to directory that contains all asset files for the installer. If set, assets will be part of installation and cpack.")
+ 
+-if(SRB2_CONFIG_ENABLE_TESTS)
+-	# https://github.com/catchorg/Catch2
+-	CPMAddPackage(
+-		NAME Catch2
+-		VERSION 3.4.0
+-		GITHUB_REPOSITORY catchorg/Catch2
+-		OPTIONS
+-			"CATCH_INSTALL_DOCS OFF"
+-	)
+-	list(APPEND CMAKE_MODULE_PATH "${Catch2_SOURCE_DIR}/extras")
+-	include(CTest)
+-	include(Catch)
+-	add_executable(srb2tests)
+-	# To add tests, use target_sources to add individual test files to the target in subdirs.
+-	target_link_libraries(srb2tests PRIVATE Catch2::Catch2 Catch2::Catch2WithMain)
+-	target_compile_features(srb2tests PRIVATE c_std_11 cxx_std_17)
+-	catch_discover_tests(srb2tests)
+-endif()
+-
+ # Enable CCache
+ # (Set USE_CCACHE=ON to use, CCACHE_OPTIONS for options)
+ if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL Windows)
+@@ -113,12 +94,6 @@ if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL Windows)
+ 			message(WARNING "USE_CCACHE was set but ccache is not found (set CCACHE_TOOL_PATH)")
+ 		endif()
+ 	endif()
+-else()
+-	CPMAddPackage(
+-		NAME Ccache.cmake
+-		GITHUB_REPOSITORY TheLartians/Ccache.cmake
+-		VERSION 1.2
+-	)
+ endif()
+ 
+ # Dependencies
+@@ -179,7 +154,7 @@ include(GitUtilities)
+ if("${SRB2_SDL2_EXE_NAME}" STREQUAL "")
+ 	# cause a reconfigure if the branch changes
+ 	get_git_dir(SRB2_GIT_DIR)
+-	configure_file("${SRB2_GIT_DIR}/HEAD" HEAD COPYONLY)
++	#configure_file("${SRB2_GIT_DIR}/HEAD" HEAD COPYONLY)
+ 
+ 	git_current_branch(SRB2_GIT_REVISION)
+ 
diff --git a/pkgs/by-name/sr/srb2/package.nix b/pkgs/by-name/sr/srb2/package.nix
new file mode 100644
index 0000000000000..023f04c7f8242
--- /dev/null
+++ b/pkgs/by-name/sr/srb2/package.nix
@@ -0,0 +1,120 @@
+{ lib
+, stdenv
+, fetchgit
+, fetchFromGitHub
+, cmake
+, curl
+, nasm
+, libopenmpt
+, game-music-emu
+, libpng
+, SDL2
+, SDL2_mixer
+, zlib
+, makeWrapper
+, makeDesktopItem
+, copyDesktopItems
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "srb2";
+  version = "2.2.13";
+
+  src = fetchFromGitHub {
+    owner = "STJr";
+    repo = "SRB2";
+    rev = "SRB2_release_${finalAttrs.version}";
+    hash = "sha256-OSkkjCz7ZW5+0vh6l7+TpnHLzXmd/5QvTidRQSHJYX8=";
+  };
+
+  nativeBuildInputs = [
+    cmake
+    nasm
+    makeWrapper
+    copyDesktopItems
+  ];
+
+  buildInputs = [
+    curl
+    game-music-emu
+    libpng
+    libopenmpt
+    SDL2
+    SDL2_mixer
+    zlib
+  ];
+
+  assets = stdenv.mkDerivation {
+    pname = "srb2-data";
+    version = finalAttrs.version;
+
+    src = fetchgit {
+      url = "https://git.do.srb2.org/STJr/srb2assets-public";
+      rev = "SRB2_release_${finalAttrs.version}";
+      hash = "sha256-OXvO5ZlujIYmYevc62Dtx192dxoujQMNFUCrH5quBBg=";
+      fetchLFS = true;
+    };
+
+    installPhase = ''
+      runHook preInstall
+
+      mkdir -p $out/share/srb2
+      cp -r * $out/share/srb2
+
+      runHook postInstall
+    '';
+  };
+
+  cmakeFlags = [
+    "-DSRB2_ASSET_DIRECTORY=${finalAttrs.assets}/share/srb2"
+    "-DGME_INCLUDE_DIR=${game-music-emu}/include"
+    "-DOPENMPT_INCLUDE_DIR=${libopenmpt.dev}/include"
+    "-DSDL2_MIXER_INCLUDE_DIR=${lib.getDev SDL2_mixer}/include/SDL2"
+    "-DSDL2_INCLUDE_DIR=${lib.getDev SDL2.dev}/include/SDL2"
+  ];
+
+  patches = [
+    # Make the build work without internet connectivity
+    # See: https://build.opensuse.org/request/show/1109889
+    ./cmake.patch
+    ./thirdparty.patch
+  ];
+
+  desktopItems = [
+    (makeDesktopItem rec {
+      name = "Sonic Robo Blast 2";
+      exec = finalAttrs.pname;
+      icon = finalAttrs.pname;
+      comment = finalAttrs.meta.description;
+      desktopName = name;
+      genericName = name;
+      categories = [ "Game" ];
+      startupWMClass = ".srb2-wrapped";
+    })
+  ];
+
+  installPhase = ''
+    runHook preInstall
+
+    mkdir -p $out/bin $out/share/applications $out/share/pixmaps $out/share/icons
+
+    copyDesktopItems
+
+    cp ../srb2.png $out/share/pixmaps/.
+    cp ../srb2.png $out/share/icons/.
+
+    cp bin/lsdlsrb2 $out/bin/srb2
+    wrapProgram $out/bin/srb2 --set SRB2WADDIR "${finalAttrs.assets}/share/srb2"
+
+    runHook postInstall
+  '';
+
+  meta = with lib; {
+    description = "Sonic Robo Blast 2 is a 3D Sonic the Hedgehog fangame based on a modified version of Doom Legacy";
+    homepage = "https://www.srb2.org/";
+    platforms = platforms.linux;
+    license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ zeratax donovanglover ];
+    mainProgram = "srb2";
+  };
+})
diff --git a/pkgs/by-name/sr/srb2/thirdparty.patch b/pkgs/by-name/sr/srb2/thirdparty.patch
new file mode 100644
index 0000000000000..bb550290d85d5
--- /dev/null
+++ b/pkgs/by-name/sr/srb2/thirdparty.patch
@@ -0,0 +1,12 @@
+diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt
+index f33b3bf3f..1214f179c 100644
+--- a/thirdparty/CMakeLists.txt
++++ b/thirdparty/CMakeLists.txt
+@@ -16,6 +16,5 @@ if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}")
+ 	include("cpm-png.cmake")
+ 	include("cpm-curl.cmake")
+ 	include("cpm-openmpt.cmake")
++	include("cpm-libgme.cmake")
+ endif()
+-
+-include("cpm-libgme.cmake")