Files
nixpkgs/pkgs/applications/emulators/libretro/mkLibretroCore.nix
Dark Steveneq 646b892680
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s
push sheeet
2025-10-09 14:15:47 +02:00

102 lines
2.6 KiB
Nix

{
# Deps
lib,
stdenv,
makeWrapper,
retroarch-bare,
unstableGitUpdater,
zlib,
}:
lib.extendMkDerivation {
constructDrv = stdenv.mkDerivation;
excludeDrvArgNames = [
"core"
"extraBuildInputs"
"extraNativeBuildInputs"
"libretroCore"
"normalizeCore"
];
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}";
buildInputs = [ zlib ] ++ extraBuildInputs;
nativeBuildInputs = [ makeWrapper ] ++ extraNativeBuildInputs;
inherit enableParallelBuilding makefile strictDeps;
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;
installPhase = ''
runHook preInstall
install -Dt ${coreDir} ${coreFilename}
makeWrapper ${retroarch-bare}/bin/retroarch $out/bin/${mainProgram} \
--add-flags "-L ${coreDir}/${coreFilename}"
runHook postInstall
'';
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;
teams = [ lib.teams.libretro ];
}
// meta;
};
}