2021-11-21 01:33:28 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
2022-12-03 23:36:03 +00:00
|
|
|
, fetchFromGitHub
|
2021-11-21 01:33:28 +00:00
|
|
|
, alsa-lib
|
2022-12-03 23:36:03 +00:00
|
|
|
, SDL2
|
|
|
|
, SDL2_ttf
|
2022-10-29 17:35:51 +00:00
|
|
|
, copyDesktopItems
|
2022-04-09 11:30:20 +00:00
|
|
|
, expat
|
|
|
|
, flac
|
2021-11-21 01:33:28 +00:00
|
|
|
, fontconfig
|
2022-04-09 11:30:20 +00:00
|
|
|
, glm
|
2021-11-21 01:33:28 +00:00
|
|
|
, installShellFiles
|
2022-12-03 23:36:03 +00:00
|
|
|
, libXi
|
|
|
|
, libXinerama
|
2022-04-09 11:30:20 +00:00
|
|
|
, libjpeg
|
2021-11-21 01:33:28 +00:00
|
|
|
, libpcap
|
|
|
|
, libpulseaudio
|
2022-04-09 17:53:08 +00:00
|
|
|
, lua5_3
|
2021-11-21 01:33:28 +00:00
|
|
|
, makeDesktopItem
|
|
|
|
, makeWrapper
|
2022-12-03 23:36:03 +00:00
|
|
|
, papirus-icon-theme
|
2021-11-21 01:33:28 +00:00
|
|
|
, pkg-config
|
2022-04-09 11:30:20 +00:00
|
|
|
, portaudio
|
|
|
|
, portmidi
|
|
|
|
, pugixml
|
2021-11-21 01:33:28 +00:00
|
|
|
, python3
|
|
|
|
, qtbase
|
2022-04-09 11:30:20 +00:00
|
|
|
, rapidjson
|
2022-11-10 12:30:43 +00:00
|
|
|
, sqlite
|
2022-04-09 11:30:20 +00:00
|
|
|
, utf8proc
|
2021-11-21 01:33:28 +00:00
|
|
|
, which
|
2022-04-09 10:31:22 +00:00
|
|
|
, writeScript
|
2022-04-09 11:30:20 +00:00
|
|
|
, zlib
|
2022-12-03 23:36:03 +00:00
|
|
|
, darwin
|
2021-11-21 01:33:28 +00:00
|
|
|
}:
|
2019-10-30 19:29:51 +00:00
|
|
|
|
|
|
|
let
|
2022-12-03 23:36:03 +00:00
|
|
|
inherit (darwin.apple_sdk.frameworks) CoreAudioKit ForceFeedback;
|
2021-11-21 01:33:28 +00:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
2019-10-30 19:29:51 +00:00
|
|
|
pname = "mame";
|
2023-01-07 14:01:54 +00:00
|
|
|
version = "0.251";
|
2022-12-03 23:36:03 +00:00
|
|
|
srcVersion = builtins.replaceStrings [ "." ] [ "" ] version;
|
2019-10-30 19:29:51 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "mamedev";
|
|
|
|
repo = "mame";
|
2022-12-03 23:36:03 +00:00
|
|
|
rev = "mame${srcVersion}";
|
2023-01-07 14:01:54 +00:00
|
|
|
hash = "sha256-x+QV4gunnERBHyYB2fXJ2LvMv437Z2omvk+fYkmZfqA=";
|
2019-10-30 19:29:51 +00:00
|
|
|
};
|
|
|
|
|
2022-11-08 23:46:02 +00:00
|
|
|
outputs = [ "out" "tools" ];
|
|
|
|
|
2020-03-27 06:17:27 +00:00
|
|
|
makeFlags = [
|
2021-11-21 01:33:28 +00:00
|
|
|
"CC=${stdenv.cc.targetPrefix}cc"
|
|
|
|
"CXX=${stdenv.cc.targetPrefix}c++"
|
2022-04-09 11:30:20 +00:00
|
|
|
"TOOLS=1"
|
|
|
|
"USE_LIBSDL=1"
|
|
|
|
# "USE_SYSTEM_LIB_ASIO=1"
|
|
|
|
"USE_SYSTEM_LIB_EXPAT=1"
|
|
|
|
"USE_SYSTEM_LIB_FLAC=1"
|
|
|
|
"USE_SYSTEM_LIB_GLM=1"
|
|
|
|
"USE_SYSTEM_LIB_JPEG=1"
|
|
|
|
"USE_SYSTEM_LIB_LUA=1"
|
|
|
|
"USE_SYSTEM_LIB_PORTAUDIO=1"
|
|
|
|
"USE_SYSTEM_LIB_PORTMIDI=1"
|
|
|
|
"USE_SYSTEM_LIB_PUGIXML=1"
|
|
|
|
"USE_SYSTEM_LIB_RAPIDJSON=1"
|
|
|
|
"USE_SYSTEM_LIB_UTF8PROC=1"
|
2022-11-10 12:30:43 +00:00
|
|
|
"USE_SYSTEM_LIB_SQLITE3=1"
|
2022-04-09 11:30:20 +00:00
|
|
|
"USE_SYSTEM_LIB_ZLIB=1"
|
2021-11-21 01:33:28 +00:00
|
|
|
];
|
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
|
2022-04-09 11:30:20 +00:00
|
|
|
buildInputs = [
|
|
|
|
expat
|
|
|
|
zlib
|
|
|
|
flac
|
2022-04-09 17:53:08 +00:00
|
|
|
lua5_3
|
2022-04-09 11:30:20 +00:00
|
|
|
portmidi
|
|
|
|
portaudio
|
|
|
|
utf8proc
|
|
|
|
libjpeg
|
|
|
|
rapidjson
|
|
|
|
pugixml
|
|
|
|
glm
|
|
|
|
SDL2
|
|
|
|
SDL2_ttf
|
2022-11-10 12:30:43 +00:00
|
|
|
sqlite
|
2022-04-09 11:30:20 +00:00
|
|
|
qtbase
|
|
|
|
]
|
|
|
|
++ lib.optionals stdenv.isLinux [ alsa-lib libpulseaudio libXinerama libXi fontconfig ]
|
|
|
|
++ lib.optionals stdenv.isDarwin [ libpcap CoreAudioKit ForceFeedback ];
|
2021-11-21 01:33:28 +00:00
|
|
|
|
2022-10-29 17:35:51 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
copyDesktopItems
|
|
|
|
installShellFiles
|
|
|
|
makeWrapper
|
|
|
|
pkg-config
|
|
|
|
python3
|
|
|
|
which
|
|
|
|
];
|
2019-10-30 19:29:51 +00:00
|
|
|
|
2020-09-23 02:45:15 +00:00
|
|
|
patches = [
|
2022-12-03 23:36:03 +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
|
2022-12-06 22:18:35 +00:00
|
|
|
./001-use-absolute-paths.diff
|
2020-09-23 02:45:15 +00:00
|
|
|
];
|
2019-10-30 19:29:51 +00:00
|
|
|
|
2022-12-06 22:18:35 +00:00
|
|
|
# Since the bug described in https://github.com/NixOS/nixpkgs/issues/135438,
|
|
|
|
# it is not possible to use substituteAll
|
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace src/emu/emuopts.cpp \
|
|
|
|
--subst-var-by mamePath "$out/opt/mame"
|
|
|
|
'';
|
|
|
|
|
2022-10-29 17:35:51 +00:00
|
|
|
desktopItems = [
|
|
|
|
(makeDesktopItem {
|
|
|
|
name = "MAME";
|
|
|
|
desktopName = "MAME";
|
|
|
|
exec = "mame";
|
|
|
|
icon = "mame";
|
|
|
|
type = "Application";
|
|
|
|
genericName = "MAME is a multi-purpose emulation framework";
|
|
|
|
comment = "Play vintage games using the MAME emulator";
|
|
|
|
categories = [ "Game" "Emulator" ];
|
|
|
|
keywords = [ "Game" "Emulator" "Arcade" ];
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2022-12-03 23:36:03 +00:00
|
|
|
# TODO: copy shaders from src/osd/modules/opengl/shader/glsl*.*h
|
|
|
|
# to the final package after we figure out how they work
|
|
|
|
installPhase = let
|
|
|
|
icon = "${papirus-icon-theme}/share/icons/Papirus/32x32/apps/mame.svg";
|
|
|
|
in ''
|
2022-10-29 17:35:51 +00:00
|
|
|
runHook preInstall
|
|
|
|
|
2022-11-08 23:46:02 +00:00
|
|
|
# mame
|
2022-12-03 23:36:03 +00:00
|
|
|
mkdir -p $out/opt/mame
|
2019-10-30 19:29:51 +00:00
|
|
|
|
2022-11-08 23:46:02 +00:00
|
|
|
install -Dm755 mame -t $out/bin
|
2022-10-29 17:35:51 +00:00
|
|
|
install -Dm644 ${icon} $out/share/icons/hicolor/scalable/apps/mame.svg
|
2022-11-10 12:30:43 +00:00
|
|
|
installManPage docs/man/*.1 docs/man/*.6
|
2022-12-03 23:36:03 +00:00
|
|
|
cp -ar {artwork,bgfx,plugins,language,ctrlr,keymaps,hash} $out/opt/mame
|
2022-10-29 17:35:51 +00:00
|
|
|
|
2022-11-08 23:46:02 +00:00
|
|
|
# mame-tools
|
2022-12-03 23:36:03 +00:00
|
|
|
for _tool in castool chdman floptool imgtool jedutil ldresample ldverify \
|
|
|
|
nltool nlwav pngcmp regrep romcmp split srcclean testkeys \
|
|
|
|
unidasm; do
|
|
|
|
install -Dm755 $_tool -t $tools/bin
|
2022-11-08 23:46:02 +00:00
|
|
|
done
|
|
|
|
mv $tools/bin/{,mame-}split
|
|
|
|
|
2022-10-29 17:35:51 +00:00
|
|
|
runHook postInstall
|
2019-10-30 19:29:51 +00:00
|
|
|
'';
|
|
|
|
|
2022-11-10 12:30:43 +00:00
|
|
|
# man1 is the tools documentation, man6 is the emulator documentation
|
|
|
|
# Need to be done in postFixup otherwise multi-output hook will move it back to $out
|
2022-11-08 23:46:02 +00:00
|
|
|
postFixup = ''
|
2022-11-10 12:30:43 +00:00
|
|
|
moveToOutput share/man/man1 $tools
|
2022-11-08 23:46:02 +00:00
|
|
|
'';
|
|
|
|
|
2021-11-21 01:33:28 +00:00
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2022-04-09 10:31:22 +00: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; {
|
2020-04-01 01:11:51 +00:00
|
|
|
homepage = "https://www.mamedev.org/";
|
2022-12-03 23:36:03 +00:00
|
|
|
description = "A multi-purpose emulation framework";
|
|
|
|
longDescription = ''
|
|
|
|
MAME's purpose is to preserve decades of software history. As electronic
|
|
|
|
technology continues to rush forward, MAME prevents this important
|
|
|
|
"vintage" software from being lost and forgotten. This is achieved by
|
|
|
|
documenting the hardware and how it functions. The source code to MAME
|
|
|
|
serves as this documentation. The fact that the software is usable serves
|
|
|
|
primarily to validate the accuracy of the documentation (how else can you
|
|
|
|
prove that you have recreated the hardware faithfully?). Over time, MAME
|
|
|
|
(originally stood for Multiple Arcade Machine Emulator) absorbed the
|
|
|
|
sister-project MESS (Multi Emulator Super System), so MAME now documents a
|
|
|
|
wide variety of (mostly vintage) computers, video game consoles and
|
|
|
|
calculators, in addition to the arcade video games that were its initial
|
|
|
|
focus.
|
|
|
|
'';
|
|
|
|
changelog = "https://github.com/mamedev/mame/releases/download/mame${srcVersion}/whatsnew_${srcVersion}.txt";
|
2019-10-30 19:29:51 +00:00
|
|
|
license = with licenses; [ bsd3 gpl2Plus ];
|
2021-11-21 01:33:28 +00:00
|
|
|
maintainers = with maintainers; [ thiagokokada ];
|
2022-12-03 23:36:03 +00:00
|
|
|
platforms = platforms.unix;
|
|
|
|
broken = stdenv.isDarwin;
|
2019-10-30 19:29:51 +00:00
|
|
|
};
|
|
|
|
}
|