2021-12-06 16:07:01 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, alsa-lib
|
2022-11-02 22:02:43 +00:00
|
|
|
, copyDesktopItems
|
2021-12-06 16:07:01 +00:00
|
|
|
, CoreAudioKit
|
2022-04-15 01:41:22 +00:00
|
|
|
, expat
|
2021-12-06 16:07:01 +00:00
|
|
|
, fetchFromGitHub
|
2022-11-02 22:02:43 +00:00
|
|
|
, fetchurl
|
2022-04-15 01:41:22 +00:00
|
|
|
, flac
|
2021-12-06 16:07:01 +00:00
|
|
|
, fontconfig
|
|
|
|
, ForceFeedback
|
2022-04-15 01:41:22 +00:00
|
|
|
, glm
|
2021-12-06 16:07:01 +00:00
|
|
|
, installShellFiles
|
2022-04-15 01:41:22 +00:00
|
|
|
, libjpeg
|
2021-12-06 16:07:01 +00:00
|
|
|
, libpcap
|
|
|
|
, libpulseaudio
|
|
|
|
, libXi
|
|
|
|
, libXinerama
|
2022-04-15 01:41:22 +00:00
|
|
|
, lua5_3
|
2021-12-06 16:07:01 +00:00
|
|
|
, makeDesktopItem
|
|
|
|
, makeWrapper
|
|
|
|
, pkg-config
|
2022-04-15 01:41:22 +00:00
|
|
|
, portaudio
|
|
|
|
, portmidi
|
|
|
|
, pugixml
|
2021-12-06 16:07:01 +00:00
|
|
|
, python3
|
|
|
|
, qtbase
|
2022-04-15 01:41:22 +00:00
|
|
|
, rapidjson
|
2021-12-06 16:07:01 +00:00
|
|
|
, SDL2
|
|
|
|
, SDL2_ttf
|
2022-04-15 01:41:22 +00:00
|
|
|
, utf8proc
|
2021-12-06 16:07:01 +00:00
|
|
|
, which
|
2022-04-15 01:41:22 +00:00
|
|
|
, writeScript
|
|
|
|
, zlib
|
2021-12-06 16:07:01 +00:00
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
let
|
2022-11-02 22:02:43 +00:00
|
|
|
# Get icon from Arch Linux package
|
|
|
|
icon = fetchurl {
|
|
|
|
url = "https://raw.githubusercontent.com/archlinux/svntogit-community/614b24ef3856cb52b5cafc386b0f77923cbc9156/trunk/mame.svg";
|
|
|
|
sha256 = "sha256-F8RCyTPXZBdeTOHeUKgMDC3dXXM8rwnDzV5rppesQ/Q=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
dest = "$out/opt/mame";
|
2021-12-06 16:07:01 +00:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "mame";
|
2022-10-30 15:09:59 +00:00
|
|
|
version = "0.249";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "mamedev";
|
|
|
|
repo = "mame";
|
2021-12-06 16:07:01 +00:00
|
|
|
rev = "mame${builtins.replaceStrings [ "." ] [ "" ] version}";
|
2022-10-30 15:09:59 +00:00
|
|
|
sha256 = "sha256-im6y/E0pQxruX2kNXZLE3fHq+zXfsstnOoC1QvH4fd4=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
makeFlags = [
|
2021-12-06 16:07:01 +00:00
|
|
|
"CC=${stdenv.cc.targetPrefix}cc"
|
|
|
|
"CXX=${stdenv.cc.targetPrefix}c++"
|
2022-04-15 01:41:22 +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"
|
|
|
|
"USE_SYSTEM_LIB_ZLIB=1"
|
2021-12-06 16:07:01 +00:00
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
dontWrapQtApps = true;
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
# https://docs.mamedev.org/initialsetup/compilingmame.html
|
2022-04-15 01:41:22 +00:00
|
|
|
buildInputs = [
|
|
|
|
expat
|
|
|
|
zlib
|
|
|
|
flac
|
|
|
|
lua5_3
|
|
|
|
portmidi
|
|
|
|
portaudio
|
|
|
|
utf8proc
|
|
|
|
libjpeg
|
|
|
|
rapidjson
|
|
|
|
pugixml
|
|
|
|
glm
|
|
|
|
SDL2
|
|
|
|
SDL2_ttf
|
|
|
|
qtbase
|
|
|
|
]
|
|
|
|
++ lib.optionals stdenv.isLinux [ alsa-lib libpulseaudio libXinerama libXi fontconfig ]
|
|
|
|
++ lib.optionals stdenv.isDarwin [ libpcap CoreAudioKit ForceFeedback ];
|
2021-12-06 16:07:01 +00:00
|
|
|
|
2022-11-02 22:02:43 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
copyDesktopItems
|
|
|
|
installShellFiles
|
|
|
|
makeWrapper
|
|
|
|
pkg-config
|
|
|
|
python3
|
|
|
|
which
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-09-25 04:45:31 +00:00
|
|
|
patches = [
|
2022-04-15 01:41:22 +00:00
|
|
|
# MAME is now generating the PDF documentation on its release script since commit:
|
|
|
|
# https://github.com/mamedev/mame/commit/c0e93076232e794c919231e4386445d78b2d80b1
|
|
|
|
# however this needs sphinx+latex to build, and it is available in the website
|
|
|
|
# anyway for those who need it
|
|
|
|
./0001-Revert-Added-PDF-documentation-to-dist.mak.patch
|
|
|
|
# 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-25 04:45:31 +00:00
|
|
|
./emuopts.patch
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace src/emu/emuopts.cpp \
|
|
|
|
--subst-var-by mame ${dest}
|
|
|
|
'';
|
|
|
|
|
2022-11-02 22:02:43 +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" ];
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
installPhase = ''
|
2022-11-02 22:02:43 +00:00
|
|
|
runHook preInstall
|
|
|
|
|
2021-01-17 00:15:33 +00:00
|
|
|
make -f dist.mak PTR64=${lib.optionalString stdenv.is64bit "1"}
|
2020-04-24 23:36:52 +00:00
|
|
|
mkdir -p ${dest}
|
|
|
|
mv build/release/*/Release/mame/* ${dest}
|
|
|
|
|
|
|
|
mkdir -p $out/bin
|
|
|
|
find ${dest} -maxdepth 1 -executable -type f -exec mv -t $out/bin {} \;
|
|
|
|
install -Dm755 src/osd/sdl/taputil.sh $out/bin/taputil.sh
|
|
|
|
|
|
|
|
installManPage ${dest}/docs/man/*.1 ${dest}/docs/man/*.6
|
2022-11-02 22:02:43 +00:00
|
|
|
install -Dm644 ${icon} $out/share/icons/hicolor/scalable/apps/mame.svg
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
mv artwork plugins samples ${dest}
|
2022-11-02 22:02:43 +00:00
|
|
|
|
|
|
|
runHook postInstall
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2022-04-15 01:41: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-04-24 23:36:52 +00:00
|
|
|
meta = with lib; {
|
2022-11-02 22:02:43 +00:00
|
|
|
broken = stdenv.isDarwin;
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Is a multi-purpose emulation framework";
|
|
|
|
homepage = "https://www.mamedev.org/";
|
|
|
|
license = with licenses; [ bsd3 gpl2Plus ];
|
|
|
|
platforms = platforms.unix;
|
2021-12-06 16:07:01 +00:00
|
|
|
maintainers = with maintainers; [ thiagokokada ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|