1{
2 stdenv,
3 lib,
4 fetchFromGitHub,
5 fetchpatch,
6 gitUpdater,
7 cmake,
8 pkg-config,
9 ffmpeg,
10 libGLU,
11 alsa-lib,
12 libX11,
13 libXrandr,
14 sndio,
15 qtbase,
16 qtsvg,
17 qttools,
18 wrapQtAppsHook,
19}:
20
21stdenv.mkDerivation (finalAttrs: {
22 pname = "punes";
23 version = "0.111";
24
25 src = fetchFromGitHub {
26 owner = "punesemu";
27 repo = "puNES";
28 rev = "v${finalAttrs.version}";
29 hash = "sha256-TIXjYkInWV3yVnvXrdHcmeWYeps5TcvkG2Xjg4roIds=";
30 };
31
32 patches = [
33 # Fix FTBFS with Qt 6.7.1
34 # Remove when version > 0.111
35 (fetchpatch {
36 name = "0001-punes-Fix-compatibility-with-Qt-6.7.1.patch";
37 url = "https://github.com/punesemu/puNES/commit/6e51b1a6107ad3de97edd40ae4ec2d41b32d804f.patch";
38 hash = "sha256-xRalKIOb1qWgqJsFLcm7uUOblEfHDYbkukmcr4/+4Qc=";
39 })
40
41 # Fix FTBFS with Qt 6.9
42 # Remove when version > 0.111
43 (fetchpatch {
44 name = "0002-punes-Updated-code-for-Qt-6.9.0-compatibility.patch";
45 url = "https://github.com/punesemu/puNES/commit/ff906e0a79eeac9a2d16783e0accf65748bb275e.patch";
46 hash = "sha256-+s7AdaUBgCseQs6Mxat/cDmQ77s6K6J0fUfyihP82jM=";
47 })
48 ];
49
50 nativeBuildInputs = [
51 cmake
52 pkg-config
53 qttools
54 wrapQtAppsHook
55 ];
56
57 buildInputs = [
58 ffmpeg
59 libGLU
60 qtbase
61 qtsvg
62 ]
63 ++ lib.optionals stdenv.hostPlatform.isLinux [
64 alsa-lib
65 libX11
66 libXrandr
67 ]
68 ++ lib.optionals stdenv.hostPlatform.isBSD [
69 sndio
70 ];
71
72 cmakeFlags = [
73 "-DENABLE_GIT_INFO=OFF"
74 "-DENABLE_RELEASE=ON"
75 "-DENABLE_FFMPEG=ON"
76 "-DENABLE_OPENGL=ON"
77 "-DENABLE_QT6_LIBS=${if lib.versionAtLeast qtbase.version "6.0" then "ON" else "OFF"}"
78 ];
79
80 passthru.updateScript = gitUpdater {
81 rev-prefix = "v";
82 };
83
84 meta = with lib; {
85 description = "Qt-based Nintendo Entertainment System emulator and NSF/NSFe Music Player";
86 mainProgram = "punes";
87 homepage = "https://github.com/punesemu/puNES";
88 changelog = "https://github.com/punesemu/puNES/blob/v${finalAttrs.version}/ChangeLog";
89 license = licenses.gpl2Plus;
90 maintainers = with maintainers; [ OPNA2608 ];
91 platforms = with platforms; linux ++ freebsd ++ openbsd ++ windows;
92 };
93})