nixpkgs/pkgs/applications/emulators/retroarch/default.nix
Bjørn Forsman fbab0d0d31 retroarch: prefer wrapper over patch
* Remove the nixpkgs specific patch and configure the install paths
  to assets and core info with the wrapper. (The path to the cores
  themselves is configured in the wrapper, before *and* after this
  change.) Less rebuilds, easier maintenance.
* Remove the withAssets/withCoreInfo parameters from retroarch expr as
  they make little sense to keep now.
* Keep passing --disable-update_assets and --disable-update_core_info
  configure flags, as I think nixpkgs users prefer a declarative setup.
2023-07-22 19:19:11 +02:00

146 lines
3.1 KiB
Nix

{ lib
, stdenv
, nixosTests
, enableNvidiaCgToolkit ? 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
, qtbase
, retroarch-assets
, SDL2
, spirv-tools
, substituteAll
, udev
, vulkan-loader
, wayland
, wrapQtAppsHook
, zlib
}:
let
runtimeLibs =
lib.optional withVulkan vulkan-loader ++
lib.optional withGamemode (lib.getLib gamemode);
in
stdenv.mkDerivation rec {
pname = "retroarch-bare";
version = "1.15.0";
src = fetchFromGitHub {
owner = "libretro";
repo = "RetroArch";
hash = "sha256-kJOR3p3fKqGM8a5rgDPkz43uuf5AtS5fVnvr3tJgWbc=";
rev = "v${version}";
};
nativeBuildInputs = [ pkg-config wrapQtAppsHook ] ++
lib.optional withWayland wayland ++
lib.optional (runtimeLibs != [ ]) makeWrapper;
buildInputs = [
ffmpeg_4
flac
freetype
libGL
libGLU
libxml2
mbedtls_2
python3
qtbase
SDL2
spirv-tools
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"
"--disable-update_assets"
"--disable-update_core_info"
] ++
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;
};
}