37 inherit (darwin.apple_sdk.frameworks) CoreAudioKit ForceFeedback;
39 stdenv.mkDerivation rec {
42 srcVersion = builtins.replaceStrings [ "." ] [ "" ] version;
44 src = fetchFromGitHub {
47 rev = "mame${srcVersion}";
48 hash = "sha256-l1mgkPhYO/U/77veC0Mpyzr6hzz/FSkn+4GMAdLSfOk=";
51 outputs = [ "out" "tools" ];
54 "CC=${stdenv.cc.targetPrefix}cc"
55 "CXX=${stdenv.cc.targetPrefix}c++"
58 # "USE_SYSTEM_LIB_ASIO=1"
59 "USE_SYSTEM_LIB_EXPAT=1"
60 "USE_SYSTEM_LIB_FLAC=1"
61 "USE_SYSTEM_LIB_GLM=1"
62 "USE_SYSTEM_LIB_JPEG=1"
63 # https://www.mamedev.org/?p=523
64 # "USE_SYSTEM_LIB_LUA=1"
65 "USE_SYSTEM_LIB_PORTAUDIO=1"
66 "USE_SYSTEM_LIB_PORTMIDI=1"
67 "USE_SYSTEM_LIB_PUGIXML=1"
68 "USE_SYSTEM_LIB_RAPIDJSON=1"
69 "USE_SYSTEM_LIB_UTF8PROC=1"
70 "USE_SYSTEM_LIB_SQLITE3=1"
71 "USE_SYSTEM_LIB_ZLIB=1"
74 dontWrapQtApps = true;
76 # https://docs.mamedev.org/initialsetup/compilingmame.html
93 ++ lib.optionals stdenv.hostPlatform.isLinux [ alsa-lib libpulseaudio libXinerama libXi fontconfig ]
94 ++ lib.optionals stdenv.hostPlatform.isDarwin [ libpcap CoreAudioKit ForceFeedback ];
106 # by default MAME assumes that paths with stock resources are relative and
107 # that you run MAME changing to install directory, so we add absolute paths
109 ./001-use-absolute-paths.diff
112 # Since the bug described in https://github.com/NixOS/nixpkgs/issues/135438,
113 # it is not possible to use substituteAll
115 substituteInPlace src/emu/emuopts.cpp \
116 --subst-var-by mamePath "$out/opt/mame"
122 desktopName = "MAME";
125 type = "Application";
126 genericName = "MAME is a multi-purpose emulation framework";
127 comment = "Play vintage games using the MAME emulator";
128 categories = [ "Game" "Emulator" ];
129 keywords = [ "Game" "Emulator" "Arcade" ];
133 # TODO: copy shaders from src/osd/modules/opengl/shader/glsl*.*h
134 # to the final package after we figure out how they work
136 icon = "${papirus-icon-theme}/share/icons/Papirus/32x32/apps/mame.svg";
141 mkdir -p $out/opt/mame
143 install -Dm755 mame -t $out/bin
144 install -Dm644 ${icon} $out/share/icons/hicolor/scalable/apps/mame.svg
145 installManPage docs/man/*.1 docs/man/*.6
146 cp -ar {artwork,bgfx,plugins,language,ctrlr,keymaps,hash} $out/opt/mame
149 for _tool in castool chdman floptool imgtool jedutil ldresample ldverify \
150 nltool nlwav pngcmp regrep romcmp split srcclean testkeys \
152 install -Dm755 $_tool -t $tools/bin
154 mv $tools/bin/{,mame-}split
159 # man1 is the tools documentation, man6 is the emulator documentation
160 # Need to be done in postFixup otherwise multi-output hook will move it back to $out
162 moveToOutput share/man/man1 $tools
165 enableParallelBuilding = true;
167 passthru.updateScript = writeScript "mame-update-script" ''
168 #!/usr/bin/env nix-shell
169 #!nix-shell -i bash -p curl common-updater-scripts jq
173 latest_version=$(curl -s https://api.github.com/repos/mamedev/mame/releases/latest | jq --raw-output .tag_name)
174 update-source-version mame "''${latest_version/mame0/0.}"
178 homepage = "https://www.mamedev.org/";
179 description = "Multi-purpose emulation framework";
181 MAME's purpose is to preserve decades of software history. As electronic
182 technology continues to rush forward, MAME prevents this important
183 "vintage" software from being lost and forgotten. This is achieved by
184 documenting the hardware and how it functions. The source code to MAME
185 serves as this documentation. The fact that the software is usable serves
186 primarily to validate the accuracy of the documentation (how else can you
187 prove that you have recreated the hardware faithfully?). Over time, MAME
188 (originally stood for Multiple Arcade Machine Emulator) absorbed the
189 sister-project MESS (Multi Emulator Super System), so MAME now documents a
190 wide variety of (mostly vintage) computers, video game consoles and
191 calculators, in addition to the arcade video games that were its initial
194 changelog = "https://github.com/mamedev/mame/releases/download/mame${srcVersion}/whatsnew_${srcVersion}.txt";
195 license = with licenses; [ bsd3 gpl2Plus ];
196 maintainers = with maintainers; [ thiagokokada ];
197 platforms = platforms.unix;
198 broken = stdenv.hostPlatform.isDarwin;
199 mainProgram = "mame";