38 inherit (darwin.apple_sdk.frameworks) CoreAudioKit ForceFeedback;
40 stdenv.mkDerivation rec {
43 srcVersion = builtins.replaceStrings [ "." ] [ "" ] version;
45 src = fetchFromGitHub {
48 rev = "mame${srcVersion}";
49 hash = "sha256-qD9xWP4KtPJWqje9QVb5wozgLTc+hE84kkEFM6Re+Sk=";
58 "CC=${stdenv.cc.targetPrefix}cc"
59 "CXX=${stdenv.cc.targetPrefix}c++"
62 # "USE_SYSTEM_LIB_ASIO=1"
63 "USE_SYSTEM_LIB_EXPAT=1"
64 "USE_SYSTEM_LIB_FLAC=1"
65 "USE_SYSTEM_LIB_GLM=1"
66 "USE_SYSTEM_LIB_JPEG=1"
67 # https://www.mamedev.org/?p=523
68 # "USE_SYSTEM_LIB_LUA=1"
69 "USE_SYSTEM_LIB_PORTAUDIO=1"
70 "USE_SYSTEM_LIB_PORTMIDI=1"
71 "USE_SYSTEM_LIB_PUGIXML=1"
72 "USE_SYSTEM_LIB_RAPIDJSON=1"
73 "USE_SYSTEM_LIB_UTF8PROC=1"
74 "USE_SYSTEM_LIB_SQLITE3=1"
75 "USE_SYSTEM_LIB_ZLIB=1"
78 dontWrapQtApps = true;
80 # https://docs.mamedev.org/initialsetup/compilingmame.html
98 ++ lib.optionals stdenv.hostPlatform.isLinux [
105 ++ lib.optionals stdenv.hostPlatform.isDarwin [
111 nativeBuildInputs = [
121 # by default MAME assumes that paths with stock resources are relative and
122 # that you run MAME changing to install directory, so we add absolute paths
124 ./001-use-absolute-paths.diff
127 # Since the bug described in https://github.com/NixOS/nixpkgs/issues/135438,
128 # it is not possible to use substituteAll
130 substituteInPlace src/emu/emuopts.cpp \
131 --subst-var-by mamePath "$out/opt/mame"
137 desktopName = "MAME";
140 type = "Application";
141 genericName = "MAME is a multi-purpose emulation framework";
142 comment = "Play vintage games using the MAME emulator";
155 # TODO: copy shaders from src/osd/modules/opengl/shader/glsl*.*h
156 # to the final package after we figure out how they work
159 icon = "${papirus-icon-theme}/share/icons/Papirus/32x32/apps/mame.svg";
165 mkdir -p $out/opt/mame
167 install -Dm755 mame -t $out/bin
168 install -Dm644 ${icon} $out/share/icons/hicolor/scalable/apps/mame.svg
169 installManPage docs/man/*.1 docs/man/*.6
170 cp -ar {artwork,bgfx,plugins,language,ctrlr,keymaps,hash} $out/opt/mame
173 for _tool in castool chdman floptool imgtool jedutil ldresample ldverify \
174 nltool nlwav pngcmp regrep romcmp split srcclean testkeys \
176 install -Dm755 $_tool -t $tools/bin
178 mv $tools/bin/{,mame-}split
183 # man1 is the tools documentation, man6 is the emulator documentation
184 # Need to be done in postFixup otherwise multi-output hook will move it back to $out
186 moveToOutput share/man/man1 $tools
189 enableParallelBuilding = true;
191 passthru.updateScript = writeScript "mame-update-script" ''
192 #!/usr/bin/env nix-shell
193 #!nix-shell -i bash -p curl common-updater-scripts jq
197 latest_version=$(curl -s https://api.github.com/repos/mamedev/mame/releases/latest | jq --raw-output .tag_name)
198 update-source-version mame "''${latest_version/mame0/0.}"
202 homepage = "https://www.mamedev.org/";
203 description = "Multi-purpose emulation framework";
205 MAME's purpose is to preserve decades of software history. As electronic
206 technology continues to rush forward, MAME prevents this important
207 "vintage" software from being lost and forgotten. This is achieved by
208 documenting the hardware and how it functions. The source code to MAME
209 serves as this documentation. The fact that the software is usable serves
210 primarily to validate the accuracy of the documentation (how else can you
211 prove that you have recreated the hardware faithfully?). Over time, MAME
212 (originally stood for Multiple Arcade Machine Emulator) absorbed the
213 sister-project MESS (Multi Emulator Super System), so MAME now documents a
214 wide variety of (mostly vintage) computers, video game consoles and
215 calculators, in addition to the arcade video games that were its initial
218 changelog = "https://github.com/mamedev/mame/releases/download/mame${srcVersion}/whatsnew_${srcVersion}.txt";
219 license = with licenses; [
223 maintainers = with maintainers; [ thiagokokada ];
224 platforms = platforms.unix;
225 broken = stdenv.hostPlatform.isDarwin;
226 mainProgram = "mame";