1{ lib, stdenv, fetchFromGitHub, python3, pkg-config, SDL2
2, libpng, ffmpeg, freetype, glew, libGL, libGLU, fribidi, zlib
3, makeWrapper
4}:
5
6let
7 # https://renpy.org/doc/html/changelog.html#versioning
8 # base_version is of the form major.minor.patch
9 # vc_version is of the form YYMMDDCC
10 # version corresponds to the tag on GitHub
11 base_version = "8.1.0";
12 vc_version = "23051307";
13in stdenv.mkDerivation rec {
14 pname = "renpy";
15
16 version = "${base_version}.${vc_version}";
17
18 src = fetchFromGitHub {
19 owner = "renpy";
20 repo = "renpy";
21 rev = version;
22 sha256 = "sha256-5EU4jaBTU+a9UNHRs7xrKQ7ZivhDEqisO3l4W2E6F+c=";
23 };
24
25 nativeBuildInputs = [
26 pkg-config
27 makeWrapper
28 python3.pkgs.cython
29 python3.pkgs.setuptools
30 ];
31
32 buildInputs = [
33 SDL2 libpng ffmpeg freetype glew libGLU libGL fribidi zlib
34 ] ++ (with python3.pkgs; [
35 python pygame_sdl2 tkinter future six pefile requests ecdsa
36 ]);
37
38 RENPY_DEPS_INSTALL = lib.concatStringsSep "::" (map (path: path) [
39 SDL2 SDL2.dev libpng ffmpeg.lib freetype glew.dev libGLU libGL fribidi zlib
40 ]);
41
42 enableParallelBuilding = true;
43
44 patches = [
45 ./shutup-erofs-errors.patch
46 ];
47
48 postPatch = ''
49 cp tutorial/game/tutorial_director.rpy{m,}
50
51 cat > renpy/vc_version.py << EOF
52 vc_version = ${vc_version}
53 official = False
54 nightly = False
55 EOF
56 '';
57
58 buildPhase = with python3.pkgs; ''
59 runHook preBuild
60 ${python.pythonForBuild.interpreter} module/setup.py build --parallel=$NIX_BUILD_CORES
61 runHook postBuild
62 '';
63
64 installPhase = with python3.pkgs; ''
65 runHook preInstall
66
67 ${python.pythonForBuild.interpreter} module/setup.py install_lib -d $out/${python.sitePackages}
68 mkdir -p $out/share/renpy
69 cp -vr sdk-fonts gui launcher renpy the_question tutorial renpy.py $out/share/renpy
70
71 makeWrapper ${python.interpreter} $out/bin/renpy \
72 --set PYTHONPATH "$PYTHONPATH:$out/${python.sitePackages}" \
73 --add-flags "$out/share/renpy/renpy.py"
74
75 runHook postInstall
76 '';
77
78 env.NIX_CFLAGS_COMPILE = with python3.pkgs; "-I${pygame_sdl2}/include/${python.libPrefix}";
79
80 meta = with lib; {
81 description = "Visual Novel Engine";
82 homepage = "https://renpy.org/";
83 changelog = "https://renpy.org/doc/html/changelog.html";
84 license = licenses.mit;
85 platforms = platforms.linux;
86 maintainers = with maintainers; [ shadowrz ];
87 };
88
89 passthru = { inherit base_version vc_version; };
90}