retroarch: format with nixfmt-rfc-style

This commit is contained in:
Thiago Kenji Okada
2024-11-24 21:58:01 +00:00
parent b65ca14ede
commit 7ae7e0df86
2 changed files with 156 additions and 124 deletions
+114 -100
View File
@@ -1,50 +1,51 @@
{ 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
{
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);
lib.optional withVulkan vulkan-loader
++ lib.optional withGamemode (lib.getLib gamemode);
in
stdenv.mkDerivation rec {
pname = "retroarch-bare";
@@ -57,67 +58,74 @@ stdenv.mkDerivation rec {
rev = "v${version}";
};
nativeBuildInputs = [ pkg-config wrapQtAppsHook ] ++
lib.optional withWayland wayland ++
lib.optional (runtimeLibs != [ ]) makeWrapper;
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
];
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"
];
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 ]}
'';
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
@@ -137,7 +145,13 @@ stdenv.mkDerivation rec {
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 ];
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/
@@ -1,28 +1,38 @@
{ lib
, makeWrapper
, retroarch
, symlinkJoin
, runCommand
, cores ? [ ]
, settings ? { }
{
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"
'';
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}" ]
(lib.lists.flatten (
map (p: [
"--add-flags"
"-L ${placeholder "out" + p}"
]) coresPath
))
++ [
"--add-flags"
"--appendconfig=${settingsPath}"
]
);
in
symlinkJoin {
@@ -46,13 +56,21 @@ symlinkJoin {
'';
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)}
'';
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";
};
}