From 007597179526ac13e3fd7a39169f6dc9b0ee03f1 Mon Sep 17 00:00:00 2001 From: TomaSajt <62384384+TomaSajt@users.noreply.github.com> Date: Mon, 17 Jul 2023 17:06:45 +0200 Subject: [PATCH] smb3-foundry: init at 1.2 --- .../misc/smb3-foundry/default.nix | 52 +++++++++++++++++++ .../misc/smb3-foundry/fix-relative-dirs.patch | 34 ++++++++++++ .../python-modules/py65/default.nix | 6 +-- pkgs/top-level/all-packages.nix | 2 + 4 files changed, 91 insertions(+), 3 deletions(-) create mode 100644 pkgs/applications/misc/smb3-foundry/default.nix create mode 100644 pkgs/applications/misc/smb3-foundry/fix-relative-dirs.patch diff --git a/pkgs/applications/misc/smb3-foundry/default.nix b/pkgs/applications/misc/smb3-foundry/default.nix new file mode 100644 index 000000000000..81e54007b8bf --- /dev/null +++ b/pkgs/applications/misc/smb3-foundry/default.nix @@ -0,0 +1,52 @@ +{ lib +, stdenv +, fetchFromGitHub +, python3 +, makeWrapper +}: + +let + pythonEnv = (python3.withPackages (ps: with ps; [ + pyside6 + py65 + qdarkstyle + ])); +in +stdenv.mkDerivation (finalAttrs: { + pname = "smb3-foundry"; + version = "1.2"; + + src = fetchFromGitHub { + owner = "mchlnix"; + repo = "SMB3-Foundry"; + rev = "refs/tags/${finalAttrs.version}"; + hash = "sha256-iqqIyGp/sqWgShxk52omVcn7Q3WL2hK8sTLH4dashLE="; + }; + + patches = [ ./fix-relative-dirs.patch ]; + + nativeBuildInputs = [ makeWrapper ]; + + installPhase = '' + runHook preInstall + + mkdir -p $out/app + cp -R smb3parse foundry scribe data doc VERSION smb3-foundry.py smb3-scribe.py $out/app + + makeWrapper ${pythonEnv}/bin/python $out/bin/smb3-foundry \ + --add-flags "$out/app/smb3-foundry.py" + makeWrapper ${pythonEnv}/bin/python $out/bin/smb3-scribe \ + --add-flags "$out/app/smb3-scribe.py" + + runHook postInstall + ''; + + meta = { + homepage = "https://github.com/mchlnix/SMB3-Foundry"; + description = "A modern Super Mario Bros. 3 Level Editor"; + changelog = "https://github.com/mchlnix/SMB3-Foundry/releases/tag/${finalAttrs.version}"; + license = lib.licenses.gpl3Only; + platforms = lib.platforms.unix; + maintainers = with lib.maintainers; [ tomasajt ]; + }; +}) diff --git a/pkgs/applications/misc/smb3-foundry/fix-relative-dirs.patch b/pkgs/applications/misc/smb3-foundry/fix-relative-dirs.patch new file mode 100644 index 000000000000..d49ddde897b4 --- /dev/null +++ b/pkgs/applications/misc/smb3-foundry/fix-relative-dirs.patch @@ -0,0 +1,34 @@ +diff --git a/foundry/gui/WarningList.py b/foundry/gui/WarningList.py +index ace83d7..46012df 100644 +--- a/foundry/gui/WarningList.py ++++ b/foundry/gui/WarningList.py +@@ -5,6 +5,7 @@ from PySide6.QtCore import QEvent, QRect, Qt, Signal, SignalInstance + from PySide6.QtGui import QCursor, QFocusEvent + from PySide6.QtWidgets import QLabel, QVBoxLayout, QWidget + ++from foundry import root_dir + from foundry.game import GROUND + from foundry.game.ObjectDefinitions import GeneratorType + from foundry.game.gfx.objects import EnemyItem +@@ -216,7 +217,7 @@ class WarningList(QWidget): + return [enemy for enemy in self.level_ref.level.enemies if enemy.type == enemy_id] + + def _build_enemy_clan_dict(self): +- with open("data/enemy_data.json", "r") as enemy_data_file: ++ with open(root_dir.joinpath("data", "enemy_data.json"), "r") as enemy_data_file: + enemy_data = json.loads(enemy_data_file.read()) + + self._enemy_dict.clear() +diff --git a/smb3parse/util/parser/__init__.py b/smb3parse/util/parser/__init__.py +index ecef169..8bba57e 100644 +--- a/smb3parse/util/parser/__init__.py ++++ b/smb3parse/util/parser/__init__.py +@@ -302,7 +302,7 @@ def gen_levels_in_rom( + + print("---------------------", level_count, "------------------------") + +- level_data = pathlib.Path("data/levels.dat") ++ level_data = pathlib.Path(__file__).parent.parent.parent.joinpath("data", "levels.dat") + + missing = 0 + levels: dict[int, set[int]] = defaultdict(set) diff --git a/pkgs/development/python-modules/py65/default.nix b/pkgs/development/python-modules/py65/default.nix index b0b93b50995e..5748b8c16938 100644 --- a/pkgs/development/python-modules/py65/default.nix +++ b/pkgs/development/python-modules/py65/default.nix @@ -24,7 +24,7 @@ buildPythonPackage rec { --replace "test_argv_combination_rom_mpu" "dont_test_argv_combination_rom_mpu" ''; - meta = with lib; { + meta = { homepage = "https://py65.readthedocs.io/"; description = "Emulate 6502-based microcomputer systems in Python"; longDescription = '' @@ -33,7 +33,7 @@ buildPythonPackage rec { debugger. Py65Mon provides a command line with many convenient commands for interacting with the simulated 6502-based system. ''; - license = licenses.bsd3; - maintainers = with maintainers; [ AndersonTorres tomasajt ]; + license = lib.licenses.bsd3; + maintainers = with lib.maintainers; [ AndersonTorres tomasajt ]; }; } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index ada043f08949..cf4fcc344741 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -1829,6 +1829,8 @@ with pkgs; sorted-grep = callPackage ../tools/text/sorted-grep { }; + smb3-foundry = callPackage ../applications/misc/smb3-foundry { }; + smbmap = callPackage ../tools/security/smbmap { }; smbscan = callPackage ../tools/security/smbscan { };