Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pkgs/applications/emulators/libretro/cores/mupen64plus.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ mkLibretroCore {
})
];

extraNativeBuildInputs = [
nasm
];
extraBuildInputs = [
libGLU
libGL
libpng
nasm
xorg.libX11
];
makefile = "Makefile";
Expand Down
14 changes: 10 additions & 4 deletions pkgs/applications/emulators/libretro/cores/same_cdi.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
lib,
alsa-lib,
fetchFromGitHub,
gcc12Stdenv,
fetchpatch2,
libGL,
libGLU,
mkLibretroCore,
Expand All @@ -21,6 +21,15 @@ mkLibretroCore {
hash = "sha256-EGE3NuO0gpZ8MKPypH8rFwJiv4QsdKuIyLKVuKTcvws=";
};

patches = [
(fetchpatch2 {
# https://github.com/libretro/same_cdi/pull/19
name = "Fixes_compilation_errors_as_per_issue_9.patch";
url = "https://github.com/libretro/same_cdi/commit/bf3212315546cdd514118a4f3ea764fd9c401091.patch?full_index=1";
hash = "sha256-1vrMxnRtEWUt+6I/4PSfCPDIUAGKkXFd2UVr9473ngo=";
})
];

extraNativeBuildInputs = [ python3 ];
extraBuildInputs = [
alsa-lib
Expand All @@ -29,9 +38,6 @@ mkLibretroCore {
portaudio
xorg.libX11
];
# FIXME = build fail with GCC13:
# error = 'uint8_t' in namespace 'std' does not name a type; did you mean 'wint_t'?
stdenv = gcc12Stdenv;

meta = {
description = "SAME_CDI is a libretro core to play CD-i games";
Expand Down
2 changes: 1 addition & 1 deletion pkgs/applications/emulators/libretro/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
}:

lib.makeScope newScope (self: {
mkLibretroCore = self.callPackage ./mkLibretroCore.nix;
mkLibretroCore = self.callPackage ./mkLibretroCore.nix { };

atari800 = self.callPackage ./cores/atari800.nix { };

Expand Down
149 changes: 73 additions & 76 deletions pkgs/applications/emulators/libretro/mkLibretroCore.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,96 +6,93 @@
retroarch-bare,
unstableGitUpdater,
zlib,
# Params
core,
makefile ? "Makefile.libretro",
extraBuildInputs ? [ ],
extraNativeBuildInputs ? [ ],
## Location of resulting RetroArch core on $out
libretroCore ? "/lib/retroarch/cores",
## The core filename is derived from the core name
## Setting `normalizeCore` to `true` will convert `-` to `_` on the core filename
normalizeCore ? true,
...
}@args:
}:

let
d2u = if normalizeCore then (lib.replaceStrings [ "-" ] [ "_" ]) else (x: x);
coreDir = placeholder "out" + libretroCore;
coreFilename = "${d2u core}_libretro${stdenv.hostPlatform.extensions.sharedLibrary}";
mainProgram = "retroarch-${core}";
extraArgs = builtins.removeAttrs args [
"lib"
"stdenv"
"makeWrapper"
"retroarch-bare"
"unstableGitUpdater"
"zlib"
lib.extendMkDerivation {
constructDrv = stdenv.mkDerivation;

excludeDrvArgNames = [
"core"
"extraBuildInputs"
"extraNativeBuildInputs"
"libretroCore"
"makefile"
"normalizeCore"
"passthru"
"meta"
];
in
stdenv.mkDerivation (
{
pname = "libretro-${core}";

buildInputs = [ zlib ] ++ extraBuildInputs;
nativeBuildInputs = [ makeWrapper ] ++ extraNativeBuildInputs;
extendDrvArgs =
finalAttrs:
{
core,
enableParallelBuilding ? true,
extraBuildInputs ? [ ],
extraNativeBuildInputs ? [ ],
makeFlags ? [ ],
makefile ? "Makefile.libretro",
meta ? { },
passthru ? { },
strictDeps ? true,
## Location of resulting RetroArch core on $out
libretroCore ? "/lib/retroarch/cores",
## The core filename is derived from the core name
## Setting `normalizeCore` to `true` will convert `-` to `_` on the core filename
normalizeCore ? true,
...
}:
let
d2u = if normalizeCore then (lib.replaceStrings [ "-" ] [ "_" ]) else (x: x);
coreDir = placeholder "out" + libretroCore;
coreFilename = "${d2u core}_libretro${stdenv.hostPlatform.extensions.sharedLibrary}";
mainProgram = "retroarch-${core}";
in
{
pname = "libretro-${core}";

inherit makefile;
buildInputs = [ zlib ] ++ extraBuildInputs;
nativeBuildInputs = [ makeWrapper ] ++ extraNativeBuildInputs;

makeFlags = [
"platform=${
{
linux = "unix";
darwin = "osx";
windows = "win";
}
.${stdenv.hostPlatform.parsed.kernel.name} or stdenv.hostPlatform.parsed.kernel.name
}"
"ARCH=${
{
armv7l = "arm";
armv6l = "arm";
aarch64 = "arm64";
i686 = "x86";
}
.${stdenv.hostPlatform.parsed.cpu.name} or stdenv.hostPlatform.parsed.cpu.name
}"
] ++ (args.makeFlags or [ ]);
inherit enableParallelBuilding makefile strictDeps;

installPhase = ''
runHook preInstall
makeFlags = [
"platform=${
{
linux = "unix";
darwin = "osx";
windows = "win";
}
.${stdenv.hostPlatform.parsed.kernel.name} or stdenv.hostPlatform.parsed.kernel.name
}"
"ARCH=${
{
armv7l = "arm";
armv6l = "arm";
aarch64 = "arm64";
i686 = "x86";
}
.${stdenv.hostPlatform.parsed.cpu.name} or stdenv.hostPlatform.parsed.cpu.name
}"
] ++ makeFlags;

install -Dt ${coreDir} ${coreFilename}
makeWrapper ${retroarch-bare}/bin/retroarch $out/bin/${mainProgram} \
--add-flags "-L ${coreDir}/${coreFilename}"
installPhase = ''
runHook preInstall

runHook postInstall
'';
install -Dt ${coreDir} ${coreFilename}
makeWrapper ${retroarch-bare}/bin/retroarch $out/bin/${mainProgram} \
--add-flags "-L ${coreDir}/${coreFilename}"

enableParallelBuilding = true;
runHook postInstall
'';

passthru = {
inherit core libretroCore;
# libretro repos sometimes has a fake tag like "Current", ignore
# it by setting hardcodeZeroVersion
updateScript = unstableGitUpdater { hardcodeZeroVersion = true; };
} // (args.passthru or { });
passthru = {
inherit core libretroCore;
# libretro repos sometimes has a fake tag like "Current", ignore
# it by setting hardcodeZeroVersion
updateScript = unstableGitUpdater { hardcodeZeroVersion = true; };
} // passthru;

meta = {
inherit mainProgram;
inherit (retroarch-bare.meta) platforms;
homepage = "https://www.libretro.com/";
teams = [ lib.teams.libretro ];
} // (args.meta or { });
}
// extraArgs
)
meta = {
inherit mainProgram;
inherit (retroarch-bare.meta) platforms;
teams = [ lib.teams.libretro ];
} // meta;
};
}