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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
{ lib
, stdenv
, nixosTests
, enableNvidiaCgToolkit ? false
, withAssets ? false
, withCoreInfo ? false
, withGamemode ? stdenv.isLinux
, withVulkan ? stdenv.isLinux
, withWayland ? stdenv.isLinux
, alsa-lib
, dbus
, fetchFromGitHub
, fetchpatch
, ffmpeg_4
, flac
, freetype
, gamemode
, libdrm
, libGL
, libGLU
, libpulseaudio
, libretro-core-info
, libv4l
, libX11
, libXdmcp
, libXext
, libxkbcommon
, libxml2
, libXxf86vm
, makeWrapper
, mbedtls_2
, mesa
, nvidia_cg_toolkit
, pkg-config
, python3
, retroarch-assets
, SDL2
, substituteAll
, udev
, vulkan-loader
, wayland
, zlib
}:
let
runtimeLibs =
lib.optional withVulkan vulkan-loader ++
lib.optional withGamemode (lib.getLib gamemode);
in
stdenv.mkDerivation rec {
pname = "retroarch-bare";
version = "1.14.0";
src = fetchFromGitHub {
owner = "libretro";
repo = "RetroArch";
hash = "sha256-oEENGehbzjJq1kTiz6gkXHMMe/rXjWPxxMoe4RqdqK4=";
rev = "v${version}";
};
patches = [
./use-default-values-for-libretro_info_path-assets_directory.patch
# TODO: remove those two patches in the next RetroArch release
(fetchpatch {
url = "https://github.com/libretro/RetroArch/commit/894c44c5ea7f1eada9207be3c29e8d5c0a7a9e1f.patch";
hash = "sha256-ThB6jd9pmsipT8zjehz7znK/s0ofHHCJeEYBKur6sO8=";
})
(fetchpatch {
url = "https://github.com/libretro/RetroArch/commit/c5bfd52159cf97312bb28fc42203c39418d1bbbd.patch";
hash = "sha256-rb1maAvCSUgq2VtJ67iqUY+Fz00Fchl8YGG0EPm0+F0=";
})
];
nativeBuildInputs = [ pkg-config ] ++
lib.optional withWayland wayland ++
lib.optional (runtimeLibs != [ ]) makeWrapper;
buildInputs = [
ffmpeg_4
flac
freetype
libGL
libGLU
libxml2
mbedtls_2
python3
SDL2
zlib
] ++
lib.optional enableNvidiaCgToolkit nvidia_cg_toolkit ++
lib.optional withVulkan vulkan-loader ++
lib.optional withWayland wayland ++
lib.optionals stdenv.isLinux [
alsa-lib
dbus
libX11
libXdmcp
libXext
libXxf86vm
libdrm
libpulseaudio
libv4l
libxkbcommon
mesa
udev
];
enableParallelBuilding = true;
configureFlags = [
"--disable-update_cores"
"--disable-builtinmbedtls"
"--enable-systemmbedtls"
"--disable-builtinzlib"
"--disable-builtinflac"
] ++
lib.optionals withAssets [
"--disable-update_assets"
"--with-assets_dir=${retroarch-assets}/share"
] ++
lib.optionals withCoreInfo [
"--disable-update_core_info"
"--with-core_info_dir=${libretro-core-info}/share"
] ++
lib.optionals stdenv.isLinux [
"--enable-dbus"
"--enable-egl"
"--enable-kms"
];
postInstall = lib.optionalString (runtimeLibs != [ ]) ''
wrapProgram $out/bin/retroarch \
--prefix LD_LIBRARY_PATH ':' ${lib.makeLibraryPath runtimeLibs}
'' +
lib.optionalString enableNvidiaCgToolkit ''
wrapProgram $out/bin/retroarch-cg2glsl \
--prefix PATH ':' ${lib.makeBinPath [ nvidia_cg_toolkit ]}
'';
preFixup = lib.optionalString (!enableNvidiaCgToolkit) ''
rm $out/bin/retroarch-cg2glsl
rm $out/share/man/man6/retroarch-cg2glsl.6*
'';
passthru.tests = nixosTests.retroarch;
meta = with lib; {
homepage = "https://libretro.com";
description = "Multi-platform emulator frontend for libretro cores";
license = licenses.gpl3Plus;
platforms = platforms.unix;
changelog = "https://github.com/libretro/RetroArch/blob/v${version}/CHANGES.md";
maintainers = with maintainers; teams.libretro.members ++ [ matthewbauer kolbycrouch ];
mainProgram = "retroarch";
# If you want to (re)-add support for macOS, see:
# https://docs.libretro.com/development/retroarch/compilation/osx/
# and
# https://github.com/libretro/RetroArch/blob/71eb74d256cb4dc5b8b43991aec74980547c5069/.gitlab-ci.yml#L330
broken = stdenv.isDarwin;
};
}
|