about summary refs log tree commit diff
path: root/pkgs/by-name/re/renpy/package.nix
blob: d31ad9ced8641e1d2c71fbdfdf2fedb6844d7a1c (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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
{
  lib,
  stdenv,
  fetchFromGitHub,
  python3,
  pkg-config,
  SDL2,
  libpng,
  ffmpeg,
  freetype,
  glew,
  libGL,
  libGLU,
  fribidi,
  zlib,
  harfbuzz,
  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.2.1";
  vc_version = "24030407";
  version = "${base_version}.${vc_version}";
in
stdenv.mkDerivation {
  pname = "renpy";
  inherit version;

  src = fetchFromGitHub {
    owner = "renpy";
    repo = "renpy";
    rev = version;
    hash = "sha256-07Hj8mJGR0+Pn1DQ+sK5YQ3x3CTMsZ5h5yEoz44b2TM=";
  };

  nativeBuildInputs = [
    pkg-config
    makeWrapper
    # Ren'Py currently does not compile on Cython 3.x.
    # See https://github.com/renpy/renpy/issues/5359
    python3.pkgs.cython_0
    python3.pkgs.setuptools
  ];

  buildInputs =
    [
      SDL2
      libpng
      ffmpeg
      freetype
      glew
      libGLU
      libGL
      fribidi
      zlib
      harfbuzz
    ]
    ++ (with python3.pkgs; [
      python
      pygame-sdl2
      tkinter
      future
      six
      pefile
      requests
      ecdsa
    ]);

  RENPY_DEPS_INSTALL = lib.concatStringsSep "::" [
    SDL2
    SDL2.dev
    libpng
    ffmpeg.lib
    freetype
    glew.dev
    libGLU
    libGL
    fribidi
    zlib
    harfbuzz.dev
  ];

  enableParallelBuilding = true;

  patches = [ ./shutup-erofs-errors.patch ];

  postPatch = ''
    cp tutorial/game/tutorial_director.rpy{m,}

    cat > renpy/vc_version.py << EOF
    version = '${version}'
    official = False
    nightly = False
    # Look at https://renpy.org/latest.html for what to put.
    version_name = '64bit Sensation'
    EOF
  '';

  buildPhase = with python3.pkgs; ''
    runHook preBuild
    ${python.pythonOnBuildForHost.interpreter} module/setup.py build --parallel=$NIX_BUILD_CORES
    runHook postBuild
  '';

  installPhase = with python3.pkgs; ''
    runHook preInstall

    ${python.pythonOnBuildForHost.interpreter} module/setup.py install_lib -d $out/${python.sitePackages}
    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 = {
    description = "Visual Novel Engine";
    mainProgram = "renpy";
    homepage = "https://renpy.org/";
    changelog = "https://renpy.org/doc/html/changelog.html";
    license = lib.licenses.mit;
    platforms = lib.platforms.linux;
    maintainers = with lib.maintainers; [ shadowrz ];
  };

  passthru = {
    inherit base_version vc_version;
  };
}