From b151a79d106b4c1c990db575e1ada27151562f6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9C=E5=9D=82=E9=9B=85?= <23130178+ShadowRZ@users.noreply.github.com> Date: Sun, 3 Jul 2022 15:55:38 +0800 Subject: [PATCH] renpy: init at 8.0.0 --- .../interpreters/renpy/default.nix | 89 +++++++++++++++++++ .../renpy/renpy-system-fribidi.diff | 51 +++++++++++ pkgs/top-level/aliases.nix | 1 - pkgs/top-level/all-packages.nix | 2 + 4 files changed, 142 insertions(+), 1 deletion(-) create mode 100644 pkgs/development/interpreters/renpy/default.nix create mode 100644 pkgs/development/interpreters/renpy/renpy-system-fribidi.diff diff --git a/pkgs/development/interpreters/renpy/default.nix b/pkgs/development/interpreters/renpy/default.nix new file mode 100644 index 000000000000..73c95c740596 --- /dev/null +++ b/pkgs/development/interpreters/renpy/default.nix @@ -0,0 +1,89 @@ +{ lib, stdenv, fetchFromGitHub, python3, pkg-config, SDL2 +, libpng, ffmpeg, freetype, glew, libGL, libGLU, fribidi, zlib +, makeWrapper +}: + +stdenv.mkDerivation rec { + pname = "renpy"; + + # https://renpy.org/doc/html/changelog.html#versioning + # base_version is of the form major.minor.patch + # vc_version is of the form YYMMDDCC + # version corresponds to the tag on GitHub + base_version = "8.0.0"; + vc_version = "22062402"; + version = "${base_version}.${vc_version}"; + + src = fetchFromGitHub { + owner = "renpy"; + repo = "renpy"; + rev = version; + sha256 = "sha256-37Hbs0i5eXMjVaETX7ImJCak0y8XtEHUaRFceA9J39A="; + }; + + nativeBuildInputs = [ + pkg-config + makeWrapper + python3.pkgs.cython + ]; + + buildInputs = [ + SDL2 libpng ffmpeg freetype glew libGLU libGL fribidi zlib + ] ++ (with python3.pkgs; [ + python pygame_sdl2 tkinter future six pefile requests + ]); + + RENPY_DEPS_INSTALL = lib.concatStringsSep "::" (map (path: path) [ + SDL2 SDL2.dev libpng ffmpeg.out freetype glew.dev libGLU libGL fribidi zlib + ]); + + enableParallelBuilding = true; + + patches = [ + ./renpy-system-fribidi.diff + ]; + + postPatch = '' + substituteInPlace module/setup.py \ + --replace "@fribidi@" "${fribidi}" + + cp tutorial/game/tutorial_director.rpy{m,} + + cat > renpy/vc_version.py << EOF + vc_version = ${vc_version} + official = False + nightly = False + EOF + ''; + + buildPhase = with python3.pkgs; '' + runHook preBuild + ${python.interpreter} module/setup.py build --parallel=$NIX_BUILD_CORES + runHook postBuild + ''; + + installPhase = with python3.pkgs; '' + runHook preInstall + + ${python.interpreter} module/setup.py install --prefix=$out + mkdir -p $out/share/renpy + cp -vr sdk-fonts gui launcher renpy the_question tutorial renpy.py $out/share/renpy + + makeWrapper ${python.interpreter} $out/bin/renpy \ + --set PYTHONPATH "$PYTHONPATH:$out/${python.sitePackages}" \ + --add-flags "-O $out/share/renpy/renpy.py" + + runHook postInstall + ''; + + NIX_CFLAGS_COMPILE = with python3.pkgs; "-I${pygame_sdl2}/include/${python.libPrefix}"; + + meta = with lib; { + description = "Visual Novel Engine"; + homepage = "https://renpy.org/"; + changelog = "https://renpy.org/doc/html/changelog.html"; + license = licenses.mit; + platforms = platforms.linux; + maintainers = with maintainers; [ shadowrz ]; + }; +} diff --git a/pkgs/development/interpreters/renpy/renpy-system-fribidi.diff b/pkgs/development/interpreters/renpy/renpy-system-fribidi.diff new file mode 100644 index 000000000000..8c93b75a7b0f --- /dev/null +++ b/pkgs/development/interpreters/renpy/renpy-system-fribidi.diff @@ -0,0 +1,51 @@ +diff --git a/module/renpybidicore.c b/module/renpybidicore.c +index 849430d..d883a52 100644 +--- a/module/renpybidicore.c ++++ b/module/renpybidicore.c +@@ -1,10 +1,6 @@ + #include + +-#ifdef RENPY_BUILD + #include +-#else +-#include +-#endif + + #include + +diff --git a/module/setup.py b/module/setup.py +index bd16816..f6b8794 100755 +--- a/module/setup.py ++++ b/module/setup.py +@@ -118,29 +118,17 @@ cython( + sdl + [ png, 'z', 'm' ]) + + FRIBIDI_SOURCES = """ +-fribidi-src/lib/fribidi.c +-fribidi-src/lib/fribidi-arabic.c +-fribidi-src/lib/fribidi-bidi.c +-fribidi-src/lib/fribidi-bidi-types.c +-fribidi-src/lib/fribidi-deprecated.c +-fribidi-src/lib/fribidi-joining.c +-fribidi-src/lib/fribidi-joining-types.c +-fribidi-src/lib/fribidi-mem.c +-fribidi-src/lib/fribidi-mirroring.c +-fribidi-src/lib/fribidi-run.c +-fribidi-src/lib/fribidi-shape.c + renpybidicore.c + """.split() + cython( + "_renpybidi", + FRIBIDI_SOURCES, ++ ["fribidi"], + includes=[ +- BASE + "/fribidi-src/", +- BASE + "/fribidi-src/lib/", ++ "@fribidi@/include/fribidi/", + ], + define_macros=[ + ("FRIBIDI_ENTRY", ""), +- ("HAVE_CONFIG_H", "1"), + ]) + + if not (android or ios or emscripten): diff --git a/pkgs/top-level/aliases.nix b/pkgs/top-level/aliases.nix index a9c0377ba5bc..5f8902bb890e 100644 --- a/pkgs/top-level/aliases.nix +++ b/pkgs/top-level/aliases.nix @@ -1210,7 +1210,6 @@ mapAliases ({ redkite = throw "redkite was archived by upstream"; # Added 2021-04-12 redshift-wlr = throw "redshift-wlr has been replaced by gammastep"; # Added 2021-12-25 reicast = throw "reicast has been removed from nixpkgs as it is unmaintained, please use flycast instead"; # Added 2022-03-07 - renpy = throw "renpy has been removed from nixpkgs, it was unmaintained and the latest packaged version required python2"; # Added 2022-01-12 # 3 resholve aliases below added 2022-04-08; drop after 2022-11-30? resholvePackage = throw "resholvePackage has been renamed to resholve.mkDerivation"; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 2c792d0ee16e..ce816f645cd8 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -10030,6 +10030,8 @@ with pkgs; redsocks = callPackage ../tools/networking/redsocks { }; + renpy = callPackage ../development/interpreters/renpy { }; + rep = callPackage ../development/tools/rep { }; repseek = callPackage ../applications/science/biology/repseek { };