diff --git a/pkgs/by-name/og/ogre-next/package.nix b/pkgs/by-name/og/ogre-next/package.nix new file mode 100644 index 000000000000..99e21f9fc2ac --- /dev/null +++ b/pkgs/by-name/og/ogre-next/package.nix @@ -0,0 +1,86 @@ +{ + lib, + stdenv, + fetchFromGitHub, + fetchpatch2, + + cmake, + ninja, + pkg-config, + + SDL2, + xorg, + libGL, + zlib, + freetype, + tinyxml, + openvr, + rapidjson, + zziplib, +}: +stdenv.mkDerivation (finalAttrs: { + pname = "ogre-next"; + version = "3.0.0"; + + src = fetchFromGitHub { + owner = "OGRECave"; + repo = "ogre-next"; + tag = "v${finalAttrs.version}"; + hash = "sha256-nJkCGKl9+6gApVtqk5OZjTOJllAJIiBKuquTYvR4NPs="; + }; + + patches = [ + (fetchpatch2 { + # https://github.com/OGRECave/ogre-next/pull/542 + url = "https://github.com/OGRECave/ogre-next/commit/c1dad50e8510dea9d75d97b0ace33a870993895c.patch?full_index=1"; + hash = "sha256-JYsksDxcLrkHqlgdP3KdHlFuvYxNazlchPGoTXE9LYQ="; + }) + ]; + + nativeBuildInputs = [ + cmake + pkg-config + ninja + ]; + + buildInputs = [ + SDL2 + freetype + zziplib + zlib + tinyxml + openvr + rapidjson + ] + ++ lib.optionals stdenv.hostPlatform.isLinux [ + libGL + xorg.libX11 + xorg.libXaw + xorg.libXrandr + xorg.libXt + xorg.libxcb + ]; + + # TODO: Figure out Vulkan plugin deps + + cmakeFlags = [ + (lib.cmakeBool "OGRE_BUILD_COMPONENT_PLANAR_REFLECTIONS" true) + + # Use STB instead of freeimage since the latter is marked as insecure + (lib.cmakeBool "OGRE_CONFIG_ENABLE_FREEIMAGE" false) + (lib.cmakeBool "OGRE_CONFIG_ENABLE_STBI" true) + ]; + + meta = { + description = "3D Object-Oriented Graphics Rendering Engine"; + homepage = "https://www.ogre3d.org/"; + maintainers = with lib.maintainers; [ + marcin-serwin + ]; + platforms = lib.platforms.linux; + license = lib.licenses.mit; + + # build problems around NEON intrinsics + broken = stdenv.hostPlatform.isAarch64; + }; +}) diff --git a/pkgs/by-name/st/stuntrally/mygui-use-pkg-config-for-ogre-next.patch b/pkgs/by-name/st/stuntrally/mygui-use-pkg-config-for-ogre-next.patch new file mode 100644 index 000000000000..e5f0fc0d3cb5 --- /dev/null +++ b/pkgs/by-name/st/stuntrally/mygui-use-pkg-config-for-ogre-next.patch @@ -0,0 +1,38 @@ +diff --git a/CMake/Dependencies.cmake b/CMake/Dependencies.cmake +index fcf7cc4..7239f20 100644 +--- a/CMake/Dependencies.cmake ++++ b/CMake/Dependencies.cmake +@@ -84,7 +84,10 @@ elseif(MYGUI_RENDERSYSTEM EQUAL 7) + endif() + elseif(MYGUI_RENDERSYSTEM EQUAL 8) + # Find OGRE +- find_package(OGRE_next) ++ find_package(PkgConfig REQUIRED) ++ pkg_check_modules(OGRE REQUIRED IMPORTED_TARGET GLOBAL OGRE) ++ pkg_check_modules(OGRE_HLMS REQUIRED IMPORTED_TARGET GLOBAL OGRE-Hlms) ++ set(OGRE_INCLUDE_DIR "${OGRE_INCLUDE_DIRS}") + macro_log_feature(OGRE_FOUND "ogre" "Support for the Ogre render system" "" TRUE "" "") + endif() + +diff --git a/Platforms/Ogre2/Ogre2Platform/CMakeLists.txt b/Platforms/Ogre2/Ogre2Platform/CMakeLists.txt +index c40cd8f..2647ae8 100644 +--- a/Platforms/Ogre2/Ogre2Platform/CMakeLists.txt ++++ b/Platforms/Ogre2/Ogre2Platform/CMakeLists.txt +@@ -1,6 +1,6 @@ + set (PROJECTNAME MyGUI.Ogre2Platform) + +-message(STATUS "Platform Ogre-next:" ${OGRE_NEXT}) ++message(STATUS "Platform Ogre-next: ${OGRE_HLMS_INCLUDE_DIRS}") + + include_directories( + include +@@ -8,8 +8,7 @@ include_directories( + ${OGRE_CONFIG_INCLUDE_DIR} + ${OGRE_INCLUDE_DIR} + ${OGRE_SOURCE_DIR} +- ${OGRE_NEXT}/Components/Hlms/Unlit/include +- ${OGRE_NEXT}/Components/Hlms/Common/include ++ ${OGRE_HLMS_INCLUDE_DIRS} + ) + + include(${PROJECTNAME}.list) diff --git a/pkgs/by-name/st/stuntrally/mygui.nix b/pkgs/by-name/st/stuntrally/mygui.nix new file mode 100644 index 000000000000..111d3fe2266d --- /dev/null +++ b/pkgs/by-name/st/stuntrally/mygui.nix @@ -0,0 +1,65 @@ +{ + stdenv, + lib, + fetchFromGitHub, + cmake, + pkg-config, + ninja, + boost, + freetype, + libuuid, + ois, + ogre-next, + libX11, +}: +stdenv.mkDerivation { + pname = "mygui"; + version = "0-unstable-2024-02-01"; + + __structuredAttrs = true; + strictDeps = true; + + src = fetchFromGitHub { + owner = "cryham"; + repo = "mygui-next"; + rev = "a1490ffe01d503c31a00d8277007ffcb27a4258e"; + hash = "sha256-R80rTsbmkYtrjIYqdYmbfciEM4rtEzLtsM4XfShJwns="; + }; + + patches = [ ./mygui-use-pkg-config-for-ogre-next.patch ]; + + postPatch = '' + substituteInPlace CMakeLists.txt \ + --replace-fail 'cmake_minimum_required(VERSION 2.6)' \ + 'cmake_minimum_required(VERSION 3.10)' + ''; + + nativeBuildInputs = [ + cmake + pkg-config + ninja + ]; + + buildInputs = [ + boost + freetype + libuuid + ois + ogre-next + libX11 + ]; + + cmakeFlags = [ + (lib.cmakeBool "MYGUI_BUILD_DEMOS" false) + (lib.cmakeBool "MYGUI_BUILD_TOOLS" false) + (lib.cmakeBool "MYGUI_DONT_USE_OBSOLETE" true) + (lib.cmakeFeature "MYGUI_RENDERSYSTEM" "8") + ]; + + meta = { + description = "Library for creating GUIs for games and 3D applications (Stunt Rally fork)"; + homepage = "http://mygui.info/"; + license = lib.licenses.mit; + platforms = lib.platforms.linux; + }; +} diff --git a/pkgs/by-name/st/stuntrally/package.nix b/pkgs/by-name/st/stuntrally/package.nix new file mode 100644 index 000000000000..5bbe921d5529 --- /dev/null +++ b/pkgs/by-name/st/stuntrally/package.nix @@ -0,0 +1,118 @@ +{ + lib, + fetchFromGitHub, + stdenv, + callPackage, + cmake, + boost, + SDL2, + libvorbis, + pkg-config, + makeWrapper, + enet, + bullet, + openal, + tinyxml-2, + rapidjson, + ogre-next, + ninja, + libX11, +}: + +let + mygui = callPackage ./mygui.nix { }; +in +stdenv.mkDerivation (finalAttrs: { + pname = "stuntrally"; + version = "3.3"; + + src = fetchFromGitHub { + owner = "stuntrally"; + repo = "stuntrally3"; + tag = finalAttrs.version; + hash = "sha256-BJMMsJ/ONZTpvXetaaHlgm6rih9oZmtJNBXv0IM855Y="; + }; + + tracks = fetchFromGitHub { + owner = "stuntrally"; + repo = "tracks3"; + tag = finalAttrs.version; + hash = "sha256-nvIN5hIfTfnuJdlLNlmpmYo3WQhUxYWz14OFra/55w4="; + }; + + patches = [ + ./stuntrally-use-pkg-config-for-ogre-next.patch + ./stuntrally-init-data-dirs-to-nix-paths.patch + ]; + + postPatch = '' + substituteInPlace bin/Release/plugins.cfg \ + --replace-fail "PluginFolder=." "PluginFolder=${ogre-next}/lib/OGRE/" + substituteInPlace src/vdrift/paths.cpp \ + --replace-fail "@GAME_DATA_DIR@" "$out/share/stuntrally3/data" \ + --replace-fail "@GAME_CONFIG_DIR@" "$out/share/stuntrally3/config" + ''; + + strictDeps = true; + nativeBuildInputs = [ + cmake + pkg-config + ninja + makeWrapper + ]; + + buildInputs = [ + boost + ogre-next + mygui + rapidjson + SDL2 + libvorbis + enet + bullet + openal + tinyxml-2 + libX11 + ]; + + installPhase = '' + runHook preInstall + + pushd .. + + share_dir=$out/share/stuntrally3 + mkdir -p $share_dir + cp -r config $share_dir/config + cp bin/Release/plugins.cfg $share_dir/config + cp -r data $share_dir/data + cp -r ${finalAttrs.tracks} $share_dir/data/tracks + + install -Dm644 -t $out/share/icons/hicolor/512x512/apps data/gui/{stuntrally,sr-editor}.png + install -Dm644 -t $out/share/applications dist/{stuntrally3,sr-editor3}.desktop + + for binary in sr-editor3 sr-translator stuntrally3 + do + install -Dm755 -t $out/bin bin/Release/$binary + # Force X11, otherwise fails with `OGRE EXCEPTION(9:UnimplementedException)` + wrapProgram $out/bin/$binary \ + --set SDL_VIDEODRIVER x11 + done + + popd + + runHook postInstall + ''; + + passthru = { + inherit mygui; + }; + + meta = { + description = "3D racing game with Sci-Fi elements and own Track Editor"; + homepage = "https://cryham.org/stuntrally/"; + mainProgram = "stuntrally3"; + license = lib.licenses.gpl3Plus; + maintainers = with lib.maintainers; [ pSub ]; + platforms = lib.platforms.linux; + }; +}) diff --git a/pkgs/by-name/st/stuntrally/stuntrally-init-data-dirs-to-nix-paths.patch b/pkgs/by-name/st/stuntrally/stuntrally-init-data-dirs-to-nix-paths.patch new file mode 100644 index 000000000000..f02c20842004 --- /dev/null +++ b/pkgs/by-name/st/stuntrally/stuntrally-init-data-dirs-to-nix-paths.patch @@ -0,0 +1,26 @@ +diff --git a/src/common/Main.cpp b/src/common/Main.cpp +index f63a5b8..8260bcf 100644 +--- a/src/common/Main.cpp ++++ b/src/common/Main.cpp +@@ -154,7 +154,7 @@ void MainEntryPoints::createSystems( + PATHS::UserConfigDir()+"/", + PATHS::CacheDir()+"/", + PATHS::GameConfigDir()+"/", +- String("./") ); ++ PATHS::GameConfigDir()+"/" ); + + app->mGraphicsSystem = graphicsSystem; + +diff --git a/src/vdrift/paths.cpp b/src/vdrift/paths.cpp +index 9122031..d06bb59 100755 +--- a/src/vdrift/paths.cpp ++++ b/src/vdrift/paths.cpp +@@ -145,6 +145,8 @@ void PATHS::Init(bool log_paths) + fs::path exe = execname(); // binary dir + game_bin = exe.parent_path().string(); + ++ game_data = "@GAME_DATA_DIR@"; ++ game_config = "@GAME_CONFIG_DIR@"; + + // Find game data dir and defaults config dir + char *datadir = getenv("STUNTRALLY3_DATA_ROOT"); diff --git a/pkgs/by-name/st/stuntrally/stuntrally-use-pkg-config-for-ogre-next.patch b/pkgs/by-name/st/stuntrally/stuntrally-use-pkg-config-for-ogre-next.patch new file mode 100644 index 000000000000..6271caaea3f8 --- /dev/null +++ b/pkgs/by-name/st/stuntrally/stuntrally-use-pkg-config-for-ogre-next.patch @@ -0,0 +1,45 @@ +diff --git a/CMake/DependenciesConfig.cmake b/CMake/DependenciesConfig.cmake +index aca28ea..76f4186 100644 +--- a/CMake/DependenciesConfig.cmake ++++ b/CMake/DependenciesConfig.cmake +@@ -7,11 +7,14 @@ find_package(Bullet REQUIRED) + find_package(enet REQUIRED) + find_package(MyGUI REQUIRED) + find_package(Ogg REQUIRED) +-find_package(OGRE REQUIRED) ++find_package(PkgConfig REQUIRED) ++pkg_check_modules(OGRE REQUIRED IMPORTED_TARGET GLOBAL OGRE) ++pkg_check_modules(OGRE-Hlms REQUIRED IMPORTED_TARGET GLOBAL OGRE-Hlms) ++pkg_check_modules(OGRE-Overlay REQUIRED IMPORTED_TARGET GLOBAL OGRE-Overlay) + find_package(OpenAL REQUIRED) + find_package(RapidJSON REQUIRED) + find_package(SDL2 REQUIRED) + find_package(tinyxml2 REQUIRED) + find_package(Vorbis REQUIRED) + +-include(AddMissingTargets) +\ No newline at end of file ++include(AddMissingTargets) +diff --git a/CMakeLists.txt b/CMakeLists.txt +index d84ae0c..22c367d 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -175,14 +175,16 @@ foreach( EXE ${EXE_LIST} ) + endif () + + target_link_libraries( +- ${EXE} ++ ${EXE} + PRIVATE + boost::boost + Bullet::Bullet + enet::enet + MyGUI::MyGUI + Ogg::ogg +- OGRE::OGRE ++ PkgConfig::OGRE ++ PkgConfig::OGRE-Hlms ++ PkgConfig::OGRE-Overlay + OpenAL::OpenAL + rapidjson + SDL2::SDL2 diff --git a/pkgs/games/stuntrally/default.nix b/pkgs/games/stuntrally/default.nix deleted file mode 100644 index 656d4ca91510..000000000000 --- a/pkgs/games/stuntrally/default.nix +++ /dev/null @@ -1,93 +0,0 @@ -{ - lib, - fetchFromGitHub, - stdenv, - cmake, - boost, - ogre_13, - mygui, - ois, - SDL2, - libX11, - libvorbis, - pkg-config, - makeWrapper, - enet, - libXcursor, - bullet, - openal, - tinyxml, - tinyxml-2, -}: - -let - stuntrally_ogre = ogre_13.overrideAttrs (old: { - cmakeFlags = old.cmakeFlags ++ [ - "-DOGRE_NODELESS_POSITIONING=ON" - "-DOGRE_RESOURCEMANAGER_STRICT=0" - ]; - }); - stuntrally_mygui = mygui.override { - withOgre = true; - ogre = stuntrally_ogre; - }; -in - -stdenv.mkDerivation rec { - pname = "stuntrally"; - version = "2.7"; - - src = fetchFromGitHub { - owner = "stuntrally"; - repo = "stuntrally"; - rev = version; - hash = "sha256-0Eh9ilIHSh/Uz8TuPnXxLQfy7KF7qqNXUgBXQUCz9ys="; - }; - tracks = fetchFromGitHub { - owner = "stuntrally"; - repo = "tracks"; - rev = version; - hash = "sha256-fglm1FetFGHM/qGTtpxDb8+k2iAREn5DQR5GPujuLms="; - }; - - postPatch = '' - substituteInPlace config/*-default.cfg \ - --replace "screenshot_png = off" "screenshot_png = on" - substituteInPlace source/*/BaseApp_Create.cpp \ - --replace "Codec_FreeImage" "Codec_STBI" - ''; - - preConfigure = '' - rmdir data/tracks - ln -s ${tracks}/ data/tracks - ''; - - nativeBuildInputs = [ - cmake - pkg-config - makeWrapper - ]; - buildInputs = [ - boost - stuntrally_ogre - stuntrally_mygui - ois - SDL2 - libX11 - libvorbis - enet - libXcursor - bullet - openal - tinyxml - tinyxml-2 - ]; - - meta = { - description = "Stunt Rally game with Track Editor, based on VDrift and OGRE"; - homepage = "http://stuntrally.tuxfamily.org/"; - license = lib.licenses.gpl3Plus; - maintainers = with lib.maintainers; [ pSub ]; - platforms = lib.platforms.linux; - }; -} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 374ceef037f5..6c9f8607a5ef 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -12447,8 +12447,6 @@ with pkgs; protonup-ng = with python3Packages; toPythonApplication protonup-ng; - stuntrally = callPackage ../games/stuntrally { boost = boost183; }; - the-powder-toy = callPackage ../by-name/th/the-powder-toy/package.nix { lua = lua5_2; };