From ff90ff193ef03199e3e3ac47a90ec06ccf29f4fb Mon Sep 17 00:00:00 2001 From: quartz Date: Thu, 24 Jul 2025 02:05:25 -0400 Subject: [PATCH] rimsort: init at 1.0.30 --- pkgs/by-name/ri/rimsort/package.nix | 182 +++++++++++++++++++++++ pkgs/by-name/ri/rimsort/steam-run.patch | 26 ++++ pkgs/by-name/ri/rimsort/todds-path.patch | 17 +++ 3 files changed, 225 insertions(+) create mode 100644 pkgs/by-name/ri/rimsort/package.nix create mode 100644 pkgs/by-name/ri/rimsort/steam-run.patch create mode 100644 pkgs/by-name/ri/rimsort/todds-path.patch diff --git a/pkgs/by-name/ri/rimsort/package.nix b/pkgs/by-name/ri/rimsort/package.nix new file mode 100644 index 000000000000..d5f569cf45ef --- /dev/null +++ b/pkgs/by-name/ri/rimsort/package.nix @@ -0,0 +1,182 @@ +{ + lib, + stdenv, + python3Packages, + fetchFromGitHub, + fetchzip, + makeBinaryWrapper, + + makeDesktopItem, + replaceVars, + + todds, + + steam, +}: +let + pname = "rimsort"; + version = "1.0.30"; + + src = fetchFromGitHub { + owner = "RimSort"; + repo = "RimSort"; + rev = "v${version}"; + hash = "sha256-f1wYoBC0EbkvYNJHkVuoMukJZMY7eNjCIzJra7/hpLs="; + fetchSubmodules = true; + }; + steamworksSrc = fetchzip { + url = "https://web.archive.org/web/20250527013243/https://partner.steamgames.com/downloads/steamworks_sdk_162.zip"; # Steam sometimes requires auth to download. + hash = "sha256-yDA92nGj3AKTNI4vnoLaa+7mDqupQv0E4YKRRUWqyZw="; + }; + + steamfiles = python3Packages.buildPythonPackage { + pname = "steamfiles"; + inherit version; + format = "setuptools"; + + src = "${src}/submodules/steamfiles"; + dependencies = with python3Packages; [ + protobuf + protobuf3-to-dict + ]; + }; + + steam-run = + (steam.override { + privateTmp = false; + }).run; +in + +stdenv.mkDerivation { + inherit pname; + inherit version; + + unpackPhase = '' + runHook preUnpack + + cp -r ${src} source + chmod -R 755 source + cp ${steamworksSrc}/redistributable_bin/linux64/libsteam_api.so source/ + + runHook postUnpack + ''; + + sourceRoot = "source"; + + patches = [ + (replaceVars ./todds-path.patch { inherit todds; }) + (replaceVars ./steam-run.patch { inherit steam-run; }) + ]; + + nativeBuildInputs = [ + makeBinaryWrapper + ]; + + buildInputs = + [ + todds + steamfiles + ] + ++ builtins.attrValues { + inherit (python3Packages) + beautifulsoup4 + certifi + chardet + imageio + loguru + lxml + msgspec + natsort + networkx + packaging + platformdirs + psutil + pygit2 + pygithub + pyperclip + pyside6 + requests + sqlalchemy + steam + toposort + watchdog + xmltodict + steamworkspy + ; + }; + + dontBuild = true; + + nativeCheckInputs = with python3Packages; [ + pytestCheckHook + pytest-cov-stub + pytest-qt + pytest-xvfb + ]; + + doCheck = true; + + preCheck = '' + export QT_DEBUG_PLUGINS=1 + export QT_QPA_PLATFORM=offscreen + export HOME=$(mktemp -d) # Some tests require a writable directory + ''; + + disabledTestPaths = [ + # requires network + "tests/models/metadata/test_metadata_factory.py" + ]; + + pytestFlags = [ "--doctest-modules" ]; + + desktopItems = [ + (makeDesktopItem { + name = "RimSort"; + desktopName = "RimSort"; + exec = "rimsort"; + icon = "io.github.rimsort.rimsort"; + comment = "RimWorld Mod Manager"; + categories = [ "Game" ]; + }) + ]; + + installPhase = '' + runHook preInstall + + mkdir -p $out/lib/rimsort + cp -r ./* $out/lib/rimsort/ + + mkdir -p $out/bin + + makeBinaryWrapper \ + ${python3Packages.python.interpreter} \ + $out/bin/rimsort \ + --add-flags "-m app" \ + --chdir $out/lib/rimsort \ + --prefix PYTHONPATH : "$PYTHONPATH" \ + --set RIMSORT_DISABLE_UPDATER 1 + + install -D ./themes/default-icons/AppIcon_a.png $out/share/icons/hicolor/512x512/apps/io.github.rimsort.rimsort + + runHook postInstall + ''; + + meta = { + description = "Open source mod manager for the video game RimWorld"; + homepage = "https://github.com/RimSort/RimSort"; + license = with lib.licenses; [ + gpl3Only + # For libsteam_api.so + ( + unfreeRedistributable + // { + url = "https://partner.steamgames.com/documentation/sdk_access_agreement"; + } + ) + ]; + maintainers = with lib.maintainers; [ weirdrock ]; + mainProgram = "rimsort"; + # steamworksSrc is x86_64-linux only + platforms = [ "x86_64-linux" ]; + }; +} diff --git a/pkgs/by-name/ri/rimsort/steam-run.patch b/pkgs/by-name/ri/rimsort/steam-run.patch new file mode 100644 index 000000000000..4969dacb75b6 --- /dev/null +++ b/pkgs/by-name/ri/rimsort/steam-run.patch @@ -0,0 +1,26 @@ +diff --git a/app/utils/generic.py b/app/utils/generic.py +--- a/app/utils/generic.py ++++ b/app/utils/generic.py +@@ -255,7 +255,7 @@ + popen_args.extend(args) + p = subprocess.Popen(popen_args) + else: +- popen_args = [executable_path] ++ popen_args = ["@steam-run@/bin/steam-run", executable_path] + popen_args.extend(args) + + if sys.platform == "win32": +diff --git a/app/utils/steam/steamcmd/wrapper.py b/app/utils/steam/steamcmd/wrapper.py +--- a/app/utils/steam/steamcmd/wrapper.py ++++ b/app/utils/steam/steamcmd/wrapper.py +@@ -316,8 +316,8 @@ + script_output.write("\n".join(script)) + runner.message(f"Compiled & using script: {script_path}") + runner.execute( +- self.steamcmd, +- [f'+runscript "{script_path}"'], ++ "@steam-run@/bin/steam-run", ++ [self.steamcmd, f'+runscript "{script_path}"'], + len(publishedfileids), + ) + else: diff --git a/pkgs/by-name/ri/rimsort/todds-path.patch b/pkgs/by-name/ri/rimsort/todds-path.patch new file mode 100644 index 000000000000..0174a2954b2e --- /dev/null +++ b/pkgs/by-name/ri/rimsort/todds-path.patch @@ -0,0 +1,17 @@ +diff --git a/app/utils/todds/wrapper.py b/app/utils/todds/wrapper.py +index a239fe0..3375b70 100644 +--- a/app/utils/todds/wrapper.py ++++ b/app/utils/todds/wrapper.py +@@ -66,11 +66,7 @@ class ToddsInterface: + :param todds_arguments: list of todds args to be passed to the todds executable + """ + +- if self.system == "Windows": +- todds_executable = "todds.exe" +- else: +- todds_executable = "todds" +- todds_exe_path = str(AppInfo().application_folder / "todds" / todds_executable) ++ todds_exe_path = "@todds@/bin/todds" + logger.info("Checking for todds...") + if os.path.exists(todds_exe_path): + logger.debug(f"Found todds executable at: {todds_exe_path}")