summary refs log tree commit diff
path: root/pkgs/applications/emulators/mame/default.nix
diff options
context:
space:
mode:
authorAndersonTorres <torres.anderson.85@protonmail.com>2022-02-15 23:28:16 -0300
committerAndersonTorres <torres.anderson.85@protonmail.com>2022-02-16 01:38:20 -0300
commit8d65e832f0a18f60e2040940c80d96373ac8b88c (patch)
tree3d6ade66b2a81403e3852b80b9e7c660699b6ed6 /pkgs/applications/emulators/mame/default.nix
parent19574af0af3ffaf7c9e359744ed32556f34536bd (diff)
downloadnixpkgs-8d65e832f0a18f60e2040940c80d96373ac8b88c.tar
nixpkgs-8d65e832f0a18f60e2040940c80d96373ac8b88c.tar.gz
nixpkgs-8d65e832f0a18f60e2040940c80d96373ac8b88c.tar.bz2
nixpkgs-8d65e832f0a18f60e2040940c80d96373ac8b88c.tar.lz
nixpkgs-8d65e832f0a18f60e2040940c80d96373ac8b88c.tar.xz
nixpkgs-8d65e832f0a18f60e2040940c80d96373ac8b88c.tar.zst
nixpkgs-8d65e832f0a18f60e2040940c80d96373ac8b88c.zip
Move misc/emulators to applications/emulators - part 1
Emulators form a class by themselves. So, they should be moved to applications/.
Diffstat (limited to 'pkgs/applications/emulators/mame/default.nix')
-rw-r--r--pkgs/applications/emulators/mame/default.nix105
1 files changed, 105 insertions, 0 deletions
diff --git a/pkgs/applications/emulators/mame/default.nix b/pkgs/applications/emulators/mame/default.nix
new file mode 100644
index 00000000000..e0915703003
--- /dev/null
+++ b/pkgs/applications/emulators/mame/default.nix
@@ -0,0 +1,105 @@
+{ lib
+, stdenv
+, alsa-lib
+, CoreAudioKit
+, fetchFromGitHub
+, fontconfig
+, ForceFeedback
+, installShellFiles
+, libpcap
+, libpulseaudio
+, libXi
+, libXinerama
+, makeDesktopItem
+, makeWrapper
+, pkg-config
+, python3
+, qtbase
+, SDL2
+, SDL2_ttf
+, which
+}:
+
+let
+  desktopItem = makeDesktopItem {
+    name = "MAME";
+    exec = "mame${lib.optionalString stdenv.is64bit "64"}";
+    desktopName = "MAME";
+    genericName = "MAME is a multi-purpose emulation framework";
+    categories = "System;Emulator;";
+  };
+
+  dest = "$out/opt/mame";
+in
+stdenv.mkDerivation rec {
+  pname = "mame";
+  version = "0.239";
+
+  src = fetchFromGitHub {
+    owner = "mamedev";
+    repo = "mame";
+    rev = "mame${builtins.replaceStrings [ "." ] [ "" ] version}";
+    sha256 = "sha256-svclBaFkp4d6db+zWZNvZP8vWIFz/7M5N1M6WseOFEk=";
+  };
+
+  hardeningDisable = [ "fortify" ];
+  NIX_CFLAGS_COMPILE = [ "-Wno-error=maybe-uninitialized" "-Wno-error=missing-braces" ];
+
+  makeFlags = [
+    "TOOLS=1"
+    "USE_LIBSDL=1"
+    "CC=${stdenv.cc.targetPrefix}cc"
+    "CXX=${stdenv.cc.targetPrefix}c++"
+  ];
+
+  dontWrapQtApps = true;
+
+  # https://docs.mamedev.org/initialsetup/compilingmame.html
+  buildInputs =
+    [ 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 ];
+
+  # 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
+  patches = [
+    ./emuopts.patch
+  ];
+
+  postPatch = ''
+    substituteInPlace src/emu/emuopts.cpp \
+      --subst-var-by mame ${dest}
+  '';
+
+  installPhase = ''
+    make -f dist.mak PTR64=${lib.optionalString stdenv.is64bit "1"}
+    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
+
+    mv artwork plugins samples ${dest}
+  '' + lib.optionalString stdenv.isLinux ''
+    mkdir -p $out/share
+    ln -s ${desktopItem}/share/applications $out/share
+  '';
+
+  enableParallelBuilding = true;
+
+  meta = with lib; {
+    description = "Is a multi-purpose emulation framework";
+    homepage = "https://www.mamedev.org/";
+    license = with licenses; [ bsd3 gpl2Plus ];
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ thiagokokada ];
+    # macOS needs more time to build
+    timeout = 24 * 3600;
+  };
+}