mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-30 19:02:57 +00:00
retroarch: refactor (#358405)
This commit is contained in:
commit
6b83f7004c
@ -15,7 +15,7 @@ import ./make-test-python.nix (
|
||||
services.xserver.enable = true;
|
||||
services.xserver.desktopManager.retroarch = {
|
||||
enable = true;
|
||||
package = pkgs.retroarchBare;
|
||||
package = pkgs.retroarch-bare;
|
||||
};
|
||||
services.xserver.displayManager = {
|
||||
sddm.enable = true;
|
||||
|
@ -8,27 +8,25 @@ packages.
|
||||
The basic steps to add a new core are:
|
||||
|
||||
1. Add a new core using `mkLibretroCore` function (use one of the existing
|
||||
files as an example)
|
||||
cores as an example)
|
||||
2. Add your new core to [`default.nix`](./default.nix) file
|
||||
3. Try to build your core with `nix-build -A libretro.<core>`
|
||||
|
||||
## Using RetroArch with cores
|
||||
|
||||
To create a custom RetroArch derivation with the cores you want (instead of
|
||||
using `retroarchFull` that includes all cores), you can use `.override` like
|
||||
using `retroarch-full` that includes all cores), you can use `.withCores` like
|
||||
this:
|
||||
|
||||
```nix
|
||||
{ pkgs, ... }:
|
||||
|
||||
let
|
||||
retroarchWithCores = (pkgs.retroarch.override {
|
||||
cores = with pkgs.libretro; [
|
||||
bsnes
|
||||
mgba
|
||||
quicknes
|
||||
];
|
||||
});
|
||||
retroarchWithCores = (pkgs.retroarch.withCores (cores: with cores; [
|
||||
bsnes
|
||||
mgba
|
||||
quicknes
|
||||
]));
|
||||
in
|
||||
{
|
||||
environment.systemPackages = [
|
||||
@ -36,3 +34,5 @@ in
|
||||
];
|
||||
}
|
||||
```
|
||||
|
||||
For advanced customization, see `wrapRetroArch` wrapper.
|
@ -1,7 +1,6 @@
|
||||
{
|
||||
lib,
|
||||
newScope,
|
||||
fetchFromGitHub,
|
||||
}:
|
||||
|
||||
lib.makeScope newScope (self: {
|
@ -3,7 +3,7 @@
|
||||
lib,
|
||||
stdenv,
|
||||
makeWrapper,
|
||||
retroarchBare,
|
||||
retroarch-bare,
|
||||
unstableGitUpdater,
|
||||
zlib,
|
||||
# Params
|
||||
@ -28,7 +28,7 @@ let
|
||||
"lib"
|
||||
"stdenv"
|
||||
"makeWrapper"
|
||||
"retroarchBare"
|
||||
"retroarch-bare"
|
||||
"unstableGitUpdater"
|
||||
"zlib"
|
||||
|
||||
@ -73,7 +73,7 @@ stdenv.mkDerivation (
|
||||
runHook preInstall
|
||||
|
||||
install -Dt ${coreDir} ${coreFilename}
|
||||
makeWrapper ${retroarchBare}/bin/retroarch $out/bin/${mainProgram} \
|
||||
makeWrapper ${retroarch-bare}/bin/retroarch $out/bin/${mainProgram} \
|
||||
--add-flags "-L ${coreDir}/${coreFilename}"
|
||||
|
||||
runHook postInstall
|
||||
@ -90,7 +90,7 @@ stdenv.mkDerivation (
|
||||
with lib;
|
||||
{
|
||||
inherit mainProgram;
|
||||
inherit (retroarchBare.meta) platforms;
|
||||
inherit (retroarch-bare.meta) platforms;
|
||||
homepage = "https://www.libretro.com/";
|
||||
maintainers = with maintainers; teams.libretro.members;
|
||||
}
|
@ -1,148 +0,0 @@
|
||||
{ lib
|
||||
, stdenv
|
||||
, nixosTests
|
||||
, enableNvidiaCgToolkit ? false
|
||||
, withGamemode ? stdenv.hostPlatform.isLinux
|
||||
, withVulkan ? stdenv.hostPlatform.isLinux
|
||||
, withWayland ? stdenv.hostPlatform.isLinux
|
||||
, alsa-lib
|
||||
, dbus
|
||||
, fetchFromGitHub
|
||||
, ffmpeg
|
||||
, flac
|
||||
, freetype
|
||||
, gamemode
|
||||
, gitUpdater
|
||||
, libdrm
|
||||
, libGL
|
||||
, libGLU
|
||||
, libpulseaudio
|
||||
, libv4l
|
||||
, libX11
|
||||
, libXdmcp
|
||||
, libXext
|
||||
, libxkbcommon
|
||||
, libxml2
|
||||
, libXxf86vm
|
||||
, makeWrapper
|
||||
, mbedtls_2
|
||||
, mesa
|
||||
, nvidia_cg_toolkit
|
||||
, pkg-config
|
||||
, python3
|
||||
, qtbase
|
||||
, SDL2
|
||||
, spirv-tools
|
||||
, udev
|
||||
, vulkan-loader
|
||||
, wayland
|
||||
, wayland-scanner
|
||||
, wrapQtAppsHook
|
||||
, zlib
|
||||
}:
|
||||
|
||||
let
|
||||
runtimeLibs =
|
||||
lib.optional withVulkan vulkan-loader ++
|
||||
lib.optional withGamemode (lib.getLib gamemode);
|
||||
in
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "retroarch-bare";
|
||||
version = "1.19.1";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "libretro";
|
||||
repo = "RetroArch";
|
||||
hash = "sha256-NVe5dhH3w7RL1C7Z736L5fdi/+aO+Ah9Dpa4u4kn0JY=";
|
||||
rev = "v${version}";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ pkg-config wrapQtAppsHook ] ++
|
||||
lib.optional withWayland wayland ++
|
||||
lib.optional (runtimeLibs != [ ]) makeWrapper;
|
||||
|
||||
buildInputs = [
|
||||
ffmpeg
|
||||
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.optionals withWayland [wayland wayland-scanner] ++
|
||||
lib.optionals stdenv.hostPlatform.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.hostPlatform.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;
|
||||
updateScript = gitUpdater {
|
||||
rev-prefix = "v";
|
||||
};
|
||||
};
|
||||
|
||||
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.hostPlatform.isDarwin;
|
||||
};
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
{ lib
|
||||
, makeWrapper
|
||||
, retroarch
|
||||
, symlinkJoin
|
||||
, runCommand
|
||||
, cores ? [ ]
|
||||
, settings ? { }
|
||||
}:
|
||||
|
||||
let
|
||||
settingsPath = runCommand "declarative-retroarch.cfg"
|
||||
{
|
||||
value = lib.concatStringsSep "\n" (lib.mapAttrsToList (n: v: "${n} = \"${v}\"") settings);
|
||||
passAsFile = [ "value" ];
|
||||
}
|
||||
''
|
||||
cp "$valuePath" "$out"
|
||||
'';
|
||||
|
||||
# All cores should be located in the same path after symlinkJoin,
|
||||
# but let's be safe here
|
||||
coresPath = lib.lists.unique (map (c: c.libretroCore) cores);
|
||||
wrapperArgs = lib.strings.escapeShellArgs (
|
||||
(lib.lists.flatten (map (p: [ "--add-flags" "-L ${placeholder "out" + p}" ]) coresPath))
|
||||
++ [ "--add-flags" "--appendconfig=${settingsPath}" ]
|
||||
);
|
||||
in
|
||||
symlinkJoin {
|
||||
name = "retroarch-with-cores-${lib.getVersion retroarch}";
|
||||
|
||||
paths = [ retroarch ] ++ cores;
|
||||
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
|
||||
passthru = {
|
||||
inherit cores;
|
||||
unwrapped = retroarch;
|
||||
};
|
||||
|
||||
postBuild = ''
|
||||
# remove core specific binaries
|
||||
find $out/bin -name 'retroarch-*' -type l -delete
|
||||
|
||||
# wrap binary to load cores from the proper location(s)
|
||||
wrapProgram $out/bin/retroarch ${wrapperArgs}
|
||||
'';
|
||||
|
||||
meta = with retroarch.meta; {
|
||||
inherit changelog description homepage license maintainers platforms;
|
||||
longDescription = ''
|
||||
RetroArch is the reference frontend for the libretro API.
|
||||
''
|
||||
+ lib.optionalString (cores != [ ]) ''
|
||||
The following cores are included: ${lib.concatStringsSep ", " (map (c: c.core) cores)}
|
||||
'';
|
||||
mainProgram = "retroarch";
|
||||
};
|
||||
}
|
@ -1,16 +1,23 @@
|
||||
{ stdenv, pkgs, lib, runtimeShell, cores ? [ ] }:
|
||||
{
|
||||
stdenv,
|
||||
pkgs,
|
||||
lib,
|
||||
runtimeShell,
|
||||
cores ? [ ],
|
||||
}:
|
||||
|
||||
let
|
||||
|
||||
script = exec: ''
|
||||
#!${runtimeShell}
|
||||
nohup sh -c "pkill -SIGTSTP kodi" &
|
||||
# https://forum.kodi.tv/showthread.php?tid=185074&pid=1622750#pid1622750
|
||||
nohup sh -c "sleep 10 && ${exec} '$@' -f;pkill -SIGCONT kodi"
|
||||
'';
|
||||
scriptSh = exec: pkgs.writeScript ("kodi-"+exec.name) (script exec.path);
|
||||
execs = map (core: rec { name = core.core; path = core+"/bin/retroarch-"+name;}) cores;
|
||||
|
||||
scriptSh = exec: pkgs.writeScript ("kodi-" + exec.name) (script exec.path);
|
||||
execs = map (core: rec {
|
||||
name = core.core;
|
||||
path = core + "/bin/retroarch-" + name;
|
||||
}) cores;
|
||||
in
|
||||
|
||||
stdenv.mkDerivation {
|
@ -1,7 +1,8 @@
|
||||
{ lib
|
||||
, stdenvNoCC
|
||||
, fetchFromGitHub
|
||||
, gitUpdater
|
||||
{
|
||||
lib,
|
||||
stdenvNoCC,
|
||||
fetchFromGitHub,
|
||||
gitUpdater,
|
||||
}:
|
||||
|
||||
stdenvNoCC.mkDerivation rec {
|
@ -1,7 +1,8 @@
|
||||
{ lib
|
||||
, stdenvNoCC
|
||||
, fetchFromGitHub
|
||||
, unstableGitUpdater
|
||||
{
|
||||
lib,
|
||||
stdenvNoCC,
|
||||
fetchFromGitHub,
|
||||
unstableGitUpdater,
|
||||
}:
|
||||
|
||||
stdenvNoCC.mkDerivation {
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user