2021-12-06 16:07:01 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, enableNvidiaCgToolkit ? false
|
2022-01-25 03:21:06 +00:00
|
|
|
, withGamemode ? stdenv.isLinux
|
2021-12-06 16:07:01 +00:00
|
|
|
, withVulkan ? stdenv.isLinux
|
|
|
|
, alsa-lib
|
|
|
|
, AppKit
|
|
|
|
, fetchFromGitHub
|
2022-02-10 20:34:41 +00:00
|
|
|
, ffmpeg_4
|
2021-12-06 16:07:01 +00:00
|
|
|
, Foundation
|
|
|
|
, freetype
|
2022-01-25 03:21:06 +00:00
|
|
|
, gamemode
|
2021-12-06 16:07:01 +00:00
|
|
|
, libdrm
|
|
|
|
, libGL
|
|
|
|
, libGLU
|
|
|
|
, libobjc
|
|
|
|
, libpulseaudio
|
|
|
|
, libv4l
|
|
|
|
, libX11
|
|
|
|
, libXdmcp
|
|
|
|
, libXext
|
2020-04-24 23:36:52 +00:00
|
|
|
, libxkbcommon
|
2021-12-06 16:07:01 +00:00
|
|
|
, libxml2
|
|
|
|
, libXxf86vm
|
|
|
|
, makeWrapper
|
|
|
|
, mesa
|
|
|
|
, nvidia_cg_toolkit
|
|
|
|
, pkg-config
|
|
|
|
, python3
|
|
|
|
, SDL2
|
|
|
|
, udev
|
|
|
|
, vulkan-loader
|
|
|
|
, wayland
|
|
|
|
, which
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
let
|
2022-04-27 09:35:20 +00:00
|
|
|
version = "1.10.3";
|
2022-01-25 03:21:06 +00:00
|
|
|
libretroCoreInfo = fetchFromGitHub {
|
2021-12-06 16:07:01 +00:00
|
|
|
owner = "libretro";
|
|
|
|
repo = "libretro-core-info";
|
2022-04-27 09:35:20 +00:00
|
|
|
sha256 = "sha256-wIIMEWrria8bZe/rcoJwDA9aCMWwbkDQFyEU80TZXFQ=";
|
2021-12-19 01:06:50 +00:00
|
|
|
rev = "v${version}";
|
2021-12-06 16:07:01 +00:00
|
|
|
};
|
2022-01-25 03:21:06 +00:00
|
|
|
runtimeLibs = lib.optional withVulkan vulkan-loader
|
|
|
|
++ lib.optional withGamemode gamemode.lib;
|
2021-12-06 16:07:01 +00:00
|
|
|
in
|
2020-04-24 23:36:52 +00:00
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "retroarch-bare";
|
2021-12-19 01:06:50 +00:00
|
|
|
inherit version;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "libretro";
|
|
|
|
repo = "RetroArch";
|
2022-04-27 09:35:20 +00:00
|
|
|
sha256 = "sha256-nAv1yv0laqlOmB8UUkK5wSYy/ySqXloEErm+yV30bbA=";
|
2020-04-24 23:36:52 +00:00
|
|
|
rev = "v${version}";
|
|
|
|
};
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
patches = [
|
2022-04-15 01:41:22 +00:00
|
|
|
./disable-menu_show_core_updater.patch
|
|
|
|
./use-fixed-paths-on-libretro_info_path.patch
|
2021-12-06 16:07:01 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
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-25 03:21:06 +00:00
|
|
|
lib.optional stdenv.isLinux wayland ++
|
|
|
|
lib.optional (runtimeLibs != [ ]) makeWrapper;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-02-10 20:34:41 +00:00
|
|
|
buildInputs = [ ffmpeg_4 freetype libxml2 libGLU libGL python3 SDL2 which ] ++
|
2022-01-25 03:21:06 +00:00
|
|
|
lib.optional enableNvidiaCgToolkit nvidia_cg_toolkit ++
|
|
|
|
lib.optional withVulkan vulkan-loader ++
|
|
|
|
lib.optionals stdenv.isDarwin [ libobjc AppKit Foundation ] ++
|
|
|
|
lib.optionals stdenv.isLinux [
|
2021-12-06 16:07:01 +00:00
|
|
|
alsa-lib
|
|
|
|
libX11
|
|
|
|
libXdmcp
|
|
|
|
libXext
|
|
|
|
libXxf86vm
|
2022-01-25 03:21:06 +00:00
|
|
|
libdrm
|
|
|
|
libpulseaudio
|
|
|
|
libv4l
|
|
|
|
libxkbcommon
|
2021-12-06 16:07:01 +00:00
|
|
|
mesa
|
|
|
|
udev
|
|
|
|
wayland
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2021-01-17 00:15:33 +00:00
|
|
|
configureFlags = lib.optionals stdenv.isLinux [ "--enable-kms" "--enable-egl" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-01-25 03:21:06 +00:00
|
|
|
postInstall = ''
|
2021-12-06 16:07:01 +00:00
|
|
|
mkdir -p $out/share/libretro/info
|
|
|
|
# TODO: ideally each core should have its own core information
|
2022-01-25 03:21:06 +00:00
|
|
|
cp -r ${libretroCoreInfo}/* $out/share/libretro/info
|
|
|
|
'' + lib.optionalString (runtimeLibs != [ ]) ''
|
|
|
|
wrapProgram $out/bin/retroarch \
|
|
|
|
--prefix LD_LIBRARY_PATH ':' ${lib.makeLibraryPath runtimeLibs}
|
2022-04-15 01:41:22 +00:00
|
|
|
'' + lib.optionalString stdenv.isDarwin ''
|
|
|
|
# https://github.com/libretro/RetroArch/blob/master/retroarch-apple-packaging.sh
|
|
|
|
app=$out/Applications/RetroArch.app
|
|
|
|
mkdir -p $app/Contents/MacOS
|
|
|
|
cp -r pkg/apple/OSX/* $app/Contents
|
|
|
|
cp $out/bin/retroarch $app/Contents/MacOS
|
|
|
|
# FIXME: using Info_Metal.plist results in input not working
|
|
|
|
# mv $app/Contents/Info_Metal.plist $app/Contents/Info.plist
|
|
|
|
|
|
|
|
substituteInPlace $app/Contents/Info.plist \
|
|
|
|
--replace '${"\${EXECUTABLE_NAME}"}' 'RetroArch' \
|
|
|
|
--replace '$(PRODUCT_BUNDLE_IDENTIFIER)' 'com.libretro.RetroArch' \
|
|
|
|
--replace '${"\${PRODUCT_NAME}"}' 'RetroArch' \
|
|
|
|
--replace '${"\${MACOSX_DEPLOYMENT_TARGET}"}' '10.13'
|
|
|
|
|
|
|
|
cp media/retroarch.icns $app/Contents/Resources/
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
preFixup = "rm $out/bin/retroarch-cg2glsl";
|
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
# Workaround for the following error affecting newer versions of Clang:
|
|
|
|
# ./config.def.h:xxx:x: error: 'TARGET_OS_TV' is not defined, evaluates to 0 [-Werror,-Wundef-prefix=TARGET_OS_]
|
2022-06-16 17:23:12 +00:00
|
|
|
NIX_CFLAGS_COMPILE = lib.optionals stdenv.cc.isClang [ "-Wno-undef-prefix" ]
|
|
|
|
# Workaround build failure on -fno-common toolchains:
|
|
|
|
# duplicate symbol '_apple_platform' in:ui_cocoa.o cocoa_common.o
|
|
|
|
# TODO: drop when upstream gets a fix for it:
|
|
|
|
# https://github.com/libretro/RetroArch/issues/14025
|
|
|
|
++ lib.optionals stdenv.isDarwin [ "-fcommon" ];
|
2022-04-15 01:41:22 +00:00
|
|
|
|
2022-01-25 03:21:06 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "https://libretro.com";
|
|
|
|
description = "Multi-platform emulator frontend for libretro cores";
|
2021-12-06 16:07:01 +00:00
|
|
|
license = licenses.gpl3Plus;
|
|
|
|
platforms = platforms.unix;
|
2022-01-25 03:21:06 +00:00
|
|
|
changelog = "https://github.com/libretro/RetroArch/blob/v${version}/CHANGES.md";
|
2021-12-06 16:07:01 +00:00
|
|
|
maintainers = with maintainers; [ MP2E edwtjo matthewbauer kolbycrouch thiagokokada ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|