Unverified Commit 30bdeaf6 authored by Sandro Jäckel's avatar Sandro Jäckel Committed by GitHub
Browse files

rimsort: init at 1.0.30 (#418507)

parents 0d00f23f ff90ff19
Loading
Loading
Loading
Loading
+182 −0
Original line number Diff line number Diff line
{
  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" ];
  };
}
+26 −0
Original line number Diff line number Diff line
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:
+17 −0
Original line number Diff line number Diff line
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}")
+41 −0
Original line number Diff line number Diff line
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,

  gevent,

  pytestCheckHook,

  setuptools,
}:
buildPythonPackage rec {
  pname = "gevent-eventemitter";
  version = "2.1";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "rossengeorgiev";
    repo = "gevent-eventemitter";
    tag = "v${version}";
    hash = "sha256-aW4OsQi3N5yAMdbTd8rxbb2qYMfFJBR4WQFIXvxpiMw=";
  };

  build-system = [ setuptools ];

  dependencies = [
    gevent
  ];

  nativeCheckInputs = [
    pytestCheckHook
  ];

  meta = {
    description = "EventEmitter using gevent";
    homepage = "https://github.com/rossengeorgiev/gevent-eventemitter";
    license = lib.licenses.mit;
    platforms = lib.platforms.linux;
    maintainers = with lib.maintainers; [ weirdrock ];
  };
}
+50 −0
Original line number Diff line number Diff line
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,

  six,
  pycryptodomex,
  requests,
  urllib3,
  vdf,
  gevent,
  protobuf,
  gevent-eventemitter,
  cachetools,
  setuptools,
}:
buildPythonPackage rec {
  pname = "steam";
  version = "1.4.4";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "ValvePython";
    repo = "steam";
    rev = "v${version}";
    hash = "sha256-OY04GsX3KMPvpsQl8sUurzFyJu+JKpES8B0iD6Z5uyw=";
  };

  build-system = [ setuptools ];

  dependencies = [
    six
    pycryptodomex
    requests
    urllib3
    vdf
    gevent
    protobuf
    gevent-eventemitter
    cachetools
  ];

  meta = {
    description = "Python package for interacting with Steam";
    homepage = "https://github.com/ValvePython/steam";
    license = lib.licenses.mit;
    platforms = lib.platforms.linux;
    maintainers = with lib.maintainers; [ weirdrock ];
  };
}
Loading