2021-11-21 01:33:28 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, alsa-lib
|
|
|
|
, CoreAudioKit
|
|
|
|
, fetchFromGitHub
|
|
|
|
, fontconfig
|
|
|
|
, ForceFeedback
|
|
|
|
, installShellFiles
|
|
|
|
, libpcap
|
|
|
|
, libpulseaudio
|
|
|
|
, libXi
|
|
|
|
, libXinerama
|
|
|
|
, makeDesktopItem
|
|
|
|
, makeWrapper
|
|
|
|
, pkg-config
|
|
|
|
, python3
|
|
|
|
, qtbase
|
|
|
|
, SDL2
|
|
|
|
, SDL2_ttf
|
|
|
|
, which
|
2022-04-09 11:31:22 +01:00
|
|
|
, writeScript
|
2021-11-21 01:33:28 +00:00
|
|
|
}:
|
2019-10-30 19:29:51 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
desktopItem = makeDesktopItem {
|
|
|
|
name = "MAME";
|
2020-03-27 06:17:27 +00:00
|
|
|
exec = "mame${lib.optionalString stdenv.is64bit "64"}";
|
2019-10-30 19:29:51 +00:00
|
|
|
desktopName = "MAME";
|
|
|
|
genericName = "MAME is a multi-purpose emulation framework";
|
2022-02-22 14:56:15 +00:00
|
|
|
categories = [ "System" "Emulator" ];
|
2019-10-30 19:29:51 +00:00
|
|
|
};
|
2019-12-06 20:43:40 +00:00
|
|
|
|
|
|
|
dest = "$out/opt/mame";
|
2021-11-21 01:33:28 +00:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
2019-10-30 19:29:51 +00:00
|
|
|
pname = "mame";
|
2022-04-09 11:31:38 +01:00
|
|
|
version = "0.242";
|
2019-10-30 19:29:51 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "mamedev";
|
|
|
|
repo = "mame";
|
2021-11-21 01:33:28 +00:00
|
|
|
rev = "mame${builtins.replaceStrings [ "." ] [ "" ] version}";
|
2022-04-09 11:31:38 +01:00
|
|
|
sha256 = "sha256-06iKM9cpjXuNvChQTPjhb9oQptC4KTZEoxzZk8+x3/k=";
|
2019-10-30 19:29:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
hardeningDisable = [ "fortify" ];
|
2020-03-27 06:17:27 +00:00
|
|
|
NIX_CFLAGS_COMPILE = [ "-Wno-error=maybe-uninitialized" "-Wno-error=missing-braces" ];
|
2019-10-30 19:29:51 +00:00
|
|
|
|
2020-03-27 06:17:27 +00:00
|
|
|
makeFlags = [
|
|
|
|
"TOOLS=1"
|
|
|
|
"USE_LIBSDL=1"
|
2021-11-21 01:33:28 +00:00
|
|
|
"CC=${stdenv.cc.targetPrefix}cc"
|
|
|
|
"CXX=${stdenv.cc.targetPrefix}c++"
|
|
|
|
];
|
2019-10-30 19:29:51 +00:00
|
|
|
|
2019-12-06 20:43:40 +00:00
|
|
|
dontWrapQtApps = true;
|
|
|
|
|
2021-11-21 01:33:28 +00:00
|
|
|
# https://docs.mamedev.org/initialsetup/compilingmame.html
|
2020-03-27 06:17:27 +00:00
|
|
|
buildInputs =
|
2021-11-21 01:33:28 +00:00
|
|
|
[ SDL2 SDL2_ttf qtbase ]
|
|
|
|
++ lib.optionals stdenv.isLinux [ alsa-lib libpulseaudio libXinerama libXi fontconfig ]
|
|
|
|
++ lib.optionals stdenv.isDarwin [ libpcap CoreAudioKit ForceFeedback ];
|
|
|
|
|
|
|
|
nativeBuildInputs = [ python3 pkg-config which makeWrapper installShellFiles ];
|
2019-10-30 19:29:51 +00:00
|
|
|
|
2019-12-06 20:43:40 +00:00
|
|
|
# by default MAME assumes that paths with stock resources
|
|
|
|
# are relative and that you run MAME changing to
|
|
|
|
# install directory, so we add absolute paths here
|
2020-09-23 03:45:15 +01:00
|
|
|
patches = [
|
|
|
|
./emuopts.patch
|
|
|
|
];
|
2019-10-30 19:29:51 +00:00
|
|
|
|
2019-12-06 20:43:40 +00:00
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace src/emu/emuopts.cpp \
|
|
|
|
--subst-var-by mame ${dest}
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
2021-01-15 13:21:58 +00:00
|
|
|
make -f dist.mak PTR64=${lib.optionalString stdenv.is64bit "1"}
|
2019-12-06 20:43:40 +00:00
|
|
|
mkdir -p ${dest}
|
|
|
|
mv build/release/*/Release/mame/* ${dest}
|
2019-10-30 19:29:51 +00:00
|
|
|
|
|
|
|
mkdir -p $out/bin
|
2019-12-06 20:43:40 +00:00
|
|
|
find ${dest} -maxdepth 1 -executable -type f -exec mv -t $out/bin {} \;
|
|
|
|
install -Dm755 src/osd/sdl/taputil.sh $out/bin/taputil.sh
|
2019-10-30 19:29:51 +00:00
|
|
|
|
2019-12-26 17:58:15 +00:00
|
|
|
installManPage ${dest}/docs/man/*.1 ${dest}/docs/man/*.6
|
2019-12-06 20:43:40 +00:00
|
|
|
|
|
|
|
mv artwork plugins samples ${dest}
|
2020-03-27 06:17:27 +00:00
|
|
|
'' + lib.optionalString stdenv.isLinux ''
|
2019-10-30 19:29:51 +00:00
|
|
|
mkdir -p $out/share
|
|
|
|
ln -s ${desktopItem}/share/applications $out/share
|
|
|
|
'';
|
|
|
|
|
2021-11-21 01:33:28 +00:00
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2022-04-09 11:31:22 +01:00
|
|
|
passthru.updateScript = writeScript "mame-update-script" ''
|
|
|
|
#!/usr/bin/env nix-shell
|
|
|
|
#!nix-shell -i bash -p curl common-updater-scripts jq
|
|
|
|
|
|
|
|
set -eu -o pipefail
|
|
|
|
|
|
|
|
latest_version=$(curl -s https://api.github.com/repos/mamedev/mame/releases/latest | jq --raw-output .tag_name)
|
|
|
|
update-source-version mame "''${latest_version/mame0/0.}"
|
|
|
|
'';
|
|
|
|
|
2020-03-27 06:17:27 +00:00
|
|
|
meta = with lib; {
|
2019-10-30 19:29:51 +00:00
|
|
|
description = "Is a multi-purpose emulation framework";
|
2020-04-01 02:11:51 +01:00
|
|
|
homepage = "https://www.mamedev.org/";
|
2019-10-30 19:29:51 +00:00
|
|
|
license = with licenses; [ bsd3 gpl2Plus ];
|
2020-03-27 06:17:27 +00:00
|
|
|
platforms = platforms.unix;
|
2021-11-21 01:33:28 +00:00
|
|
|
maintainers = with maintainers; [ thiagokokada ];
|
|
|
|
# macOS needs more time to build
|
|
|
|
timeout = 24 * 3600;
|
2019-10-30 19:29:51 +00:00
|
|
|
};
|
|
|
|
}
|