blob: 7523288bd28d09379d317ed35340a3ba0c8efaa9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
{ lib
, stdenv
, core
, makeWrapper
, retroarch
, zlib
, makefile ? "Makefile.libretro"
, extraBuildInputs ? [ ]
, extraNativeBuildInputs ? [ ]
# Location of resulting RetroArch core on $out
, libretroCore ? "/lib/retroarch/cores"
# The core filename is derivated 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"
"core"
"makeWrapper"
"retroarch"
"zlib"
"makefile"
"extraBuildInputs"
"extraNativeBuildInputs"
"libretroCore"
"normalizeCore"
"makeFlags"
"meta"
];
in
stdenv.mkDerivation ({
pname = "libretro-${core}";
buildInputs = [ zlib ] ++ extraBuildInputs;
nativeBuildInputs = [ makeWrapper ] ++ extraNativeBuildInputs;
inherit makefile;
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 [ ]);
installPhase = ''
runHook preInstall
install -Dt ${coreDir} ${coreFilename}
makeWrapper ${retroarch}/bin/retroarch $out/bin/${mainProgram} \
--add-flags "-L ${coreDir}/${coreFilename}"
runHook postInstall
'';
enableParallelBuilding = true;
passthru = { inherit core libretroCore; };
meta = with lib; {
inherit mainProgram;
inherit (retroarch.meta) platforms;
homepage = "https://www.libretro.com/";
maintainers = with maintainers; teams.libretro.members ++ [ hrdinka ];
} // (args.meta or { });
} // extraArgs)
|