{ lib, stdenv, fetchgit, fetchFromGitHub, fetchFromGitLab, fetchpatch, cmake, pkg-config, makeWrapper, python27, python37, retroarch
, alsaLib, fluidsynth, curl, hidapi, libGLU, gettext, glib, gtk2, portaudio, SDL, SDL_net, SDL2, SDL2_image, libGL
, ffmpeg_3, pcre, libevdev, libpng, libjpeg, libzip, udev, libvorbis, snappy, which, hexdump
, miniupnpc, sfml, xorg, zlib, nasm, libpcap, boost, icu, openssl
, buildPackages }:
let
d2u = lib.replaceChars ["-"] ["_"];
mkLibRetroCore = { core, src, description, license, broken ? false, ... }@a:
lib.makeOverridable stdenv.mkDerivation ((rec {
name = "libretro-${a.core}-${version}";
version = "2020-03-06";
inherit (a) src;
buildInputs = [ zlib ] ++ a.extraBuildInputs or [];
nativeBuildInputs = [ makeWrapper ] ++ a.extraNativeBuildInputs or [];
makefile = "Makefile.libretro";
makeFlags = [
"platform=${{
linux = "unix";
darwin = "osx";
windows = "win";
}.${stdenv.hostPlatform.parsed.kernel.name} or stdenv.hostPlatform.parsed.kernel.name}"
"ARCH=${{
armv7l = "arm";
armv6l = "arm";
i686 = "x86";
}.${stdenv.hostPlatform.parsed.cpu.name} or stdenv.hostPlatform.parsed.cpu.name}"
] ++ (a.makeFlags or []);
installPhase = ''
COREDIR="$out/lib/retroarch/cores"
mkdir -p $out/bin
mkdir -p $COREDIR
mv ${d2u a.core}_libretro${stdenv.hostPlatform.extensions.sharedLibrary} $COREDIR
makeWrapper ${retroarch}/bin/retroarch $out/bin/retroarch-${core} \
--add-flags "-L $COREDIR/${d2u core}_libretro${stdenv.hostPlatform.extensions.sharedLibrary} $@"
'';
passthru = {
inherit (a) core;
libretroCore = "/lib/retroarch/cores";
};
meta = with lib; {
inherit (a) description license;
broken = a.broken or false;
homepage = "https://www.libretro.com/";
maintainers = with maintainers; [ edwtjo hrdinka MP2E ];
platforms = platforms.unix;
};
}) // builtins.removeAttrs a ["core" "src" "description" "license" "makeFlags"]);
fetchRetro = { repo, rev, sha256 }:
fetchgit {
inherit rev sha256;
url = "https://github.com/libretro/${repo}.git";
fetchSubmodules = true;
};
in with lib.licenses;
{
atari800 = mkLibRetroCore rec {
core = "atari800";
src = fetchRetro {
repo = "libretro-" + core;
rev = "f9bf53b864344b8bbe8d425ed2f3c628eb10519c";
sha256 = "0sgk93zs423pwiqzvj0x1gfwcn9gacnlrrdq53ps395k64lig6lk";
};
description = "Port of Atari800 to libretro";
license = gpl2;
makefile = "Makefile";
makeFlags = [ "GIT_VERSION=" ];
};
beetle-snes = mkLibRetroCore {
core = "mednafen-snes";
src = fetchRetro {
repo = "beetle-bsnes-libretro";
rev = "de22d8420ea606f1b2f72afd4dda34619cf2cc20";
sha256 = "1nd4f8frmlhp1lyxz9zpxvwwz70x0i0rrp560cn9qlm1jzdv3xvf";
};
description = "Port of Mednafen's SNES core to libretro";
license = gpl2;
makefile = "Makefile";
};
beetle-gba = mkLibRetroCore {
core = "mednafen-gba";
src = fetchRetro {
repo = "beetle-gba-libretro";
rev = "135afdbb9591655a3e016b75abba07e481f6d406";
sha256 = "0fc0x24qn4y7pz3mp1mm1ain31aj9pznp1irr0k7hvazyklzy9g3";
};
description = "Port of Mednafen's GameBoy Advance core to libretro";
license = gpl2;
makefile = "Makefile";
};
beetle-lynx = mkLibRetroCore {
core = "mednafen-lynx";
src = fetchRetro {
repo = "beetle-lynx-libretro";
rev = "74dde204c0ec6c4bc4cd7821c14548387fbd9ce8";
sha256 = "05kwibjr30laalqzazswvmn9smm3mwqsz1i0z1s0pj7idfdhjfw0";
};
description = "Port of Mednafen's Lynx core to libretro";
license = gpl2;
makefile = "Makefile";
};
beetle-ngp = mkLibRetroCore {
core = "mednafen-ngp";
src = fetchRetro {
repo = "beetle-ngp-libretro";
rev = "6f15532b6ad17a2d5eb9dc8241d6af62416e796b";
sha256 = "05r8mk9rc19nzs3gpfsjr6i7pm6xx3gn3b4xs8ab7v4vcmfg4cn2";
};
description = "Port of Mednafen's NeoGeo Pocket core to libretro";
license = gpl2;
makefile = "Makefile"