nixpkgs/pkgs/applications/emulators/retroarch/default.nix

123 lines
3.1 KiB
Nix
Raw Normal View History

{ lib
, stdenv
, enableNvidiaCgToolkit ? false
2022-01-21 21:26:24 +00:00
, withGamemode ? stdenv.isLinux
, withVulkan ? stdenv.isLinux
, alsa-lib
, AppKit
, fetchFromGitHub
2022-02-05 21:28:01 +00:00
, ffmpeg_4
, Foundation
, freetype
2022-01-21 21:26:24 +00:00
, gamemode
, libdrm
, libGL
, libGLU
, libobjc
, libpulseaudio
, libv4l
, libX11
, libXdmcp
, libXext
, libxkbcommon
, libxml2
, libXxf86vm
, makeWrapper
, mesa
, nvidia_cg_toolkit
, pkg-config
, python3
, SDL2
, udev
, vulkan-loader
, wayland
, which
}:
let
2022-01-21 21:26:24 +00:00
version = "1.10.0";
libretroCoreInfo = fetchFromGitHub {
owner = "libretro";
repo = "libretro-core-info";
2022-01-21 21:26:24 +00:00
sha256 = "sha256-3j7fvcfbgyk71MmbUUKYi+/0cpQFNbYXO+DMDUjDqkQ=";
2021-12-06 13:49:07 +00:00
rev = "v${version}";
};
2022-01-21 21:26:24 +00:00
runtimeLibs = lib.optional withVulkan vulkan-loader
++ lib.optional withGamemode gamemode.lib;
in
stdenv.mkDerivation rec {
pname = "retroarch-bare";
2021-12-06 13:49:07 +00:00
inherit version;
2013-06-26 11:25:09 +00:00
src = fetchFromGitHub {
owner = "libretro";
repo = "RetroArch";
2022-01-21 21:26:24 +00:00
sha256 = "sha256-bpTSzODVRKRs1OW6JafjbU3e/AqdQeGzWcg1lb9SIyo=";
rev = "v${version}";
2013-06-26 11:25:09 +00:00
};
patches = [
./0001-Disable-menu_show_core_updater.patch
./0002-Use-fixed-paths-on-libretro_info_path.patch
];
postPatch = ''
substituteInPlace "frontend/drivers/platform_unix.c" \
--replace "@libretro_directory@" "$out/lib" \
--replace "@libretro_info_path@" "$out/share/libretro/info"
substituteInPlace "frontend/drivers/platform_darwin.m" \
--replace "@libretro_directory@" "$out/lib" \
--replace "@libretro_info_path@" "$out/share/libretro/info"
'';
nativeBuildInputs = [ pkg-config ] ++
2022-01-21 21:26:24 +00:00
lib.optional stdenv.isLinux wayland ++
lib.optional (runtimeLibs != [ ]) makeWrapper;
2013-06-26 11:25:09 +00:00
2022-02-05 21:28:01 +00:00
buildInputs = [ ffmpeg_4 freetype libxml2 libGLU libGL python3 SDL2 which ] ++
2022-01-21 21:26:24 +00:00
lib.optional enableNvidiaCgToolkit nvidia_cg_toolkit ++
lib.optional withVulkan vulkan-loader ++
lib.optionals stdenv.isDarwin [ libobjc AppKit Foundation ] ++
lib.optionals stdenv.isLinux [
alsa-lib
libX11
libXdmcp
libXext
libXxf86vm
2022-01-21 21:26:24 +00:00
libdrm
libpulseaudio
libv4l
libxkbcommon
mesa
udev
wayland
];
2018-03-03 02:09:35 +00:00
enableParallelBuilding = true;
2021-01-15 13:21:58 +00:00
configureFlags = lib.optionals stdenv.isLinux [ "--enable-kms" "--enable-egl" ];
2019-11-12 09:31:53 +00:00
2022-01-21 21:26:24 +00:00
postInstall = ''
mkdir -p $out/share/libretro/info
# TODO: ideally each core should have its own core information
2022-01-21 21:26:24 +00:00
cp -r ${libretroCoreInfo}/* $out/share/libretro/info
'' + lib.optionalString (runtimeLibs != [ ]) ''
wrapProgram $out/bin/retroarch \
--prefix LD_LIBRARY_PATH ':' ${lib.makeLibraryPath runtimeLibs}
'';
2018-03-03 02:09:35 +00:00
preFixup = "rm $out/bin/retroarch-cg2glsl";
2022-01-21 21:26:24 +00:00
meta = with lib; {
homepage = "https://libretro.com";
description = "Multi-platform emulator frontend for libretro cores";
2021-11-17 15:09:43 +00:00
license = licenses.gpl3Plus;
2021-11-28 17:50:21 +00:00
platforms = platforms.unix;
2022-01-22 14:01:48 +00:00
changelog = "https://github.com/libretro/RetroArch/blob/v${version}/CHANGES.md";
maintainers = with maintainers; [ MP2E edwtjo matthewbauer kolbycrouch thiagokokada ];
# FIXME: exits with error on macOS:
# No Info.plist file in application bundle or no NSPrincipalClass in the Info.plist file, exiting
broken = stdenv.isDarwin;
2013-06-26 11:25:09 +00:00
};
}