about summary refs log tree commit diff
path: root/pkgs/development/interpreters/renpy/default.nix
blob: d18c9ef2b38c69da2b1d0c9b338d6b72cf5129ad (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
{ lib, stdenv, fetchFromGitHub, python3, pkg-config, SDL2
, libpng, ffmpeg, freetype, glew, libGL, libGLU, fribidi, zlib
, makeWrapper
}:

let
  # 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.3";
  vc_version = "22090809";
in stdenv.mkDerivation rec {
  pname = "renpy";

  version = "${base_version}.${vc_version}";

  src = fetchFromGitHub {
    owner = "renpy";
    repo = "renpy";
    rev = version;
    sha256 = "sha256-0/wkUk7PMPbBSGzDuSd82yxRzvAYxkbEhM5LTVt4bMA=";
  };

  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.lib freetype glew.dev libGLU libGL fribidi zlib
  ]);

  enableParallelBuilding = true;

  patches = [
    ./renpy-system-fribidi.diff
    ./shutup-erofs-errors.patch
  ];

  postPatch = ''
    substituteInPlace module/setup.py \
      --replace "@fribidi@" "${fribidi.dev}"

    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.pythonForBuild.interpreter} module/setup.py build --parallel=$NIX_BUILD_CORES
    runHook postBuild
  '';

  installPhase = with python3.pkgs; ''
    runHook preInstall

    ${python.pythonForBuild.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 "$out/share/renpy/renpy.py"

    runHook postInstall
  '';

  env.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 ];
  };

  passthru = { inherit base_version vc_version; };
}