From 62905f6706648e84c3af6570ba2f03cc41dfab07 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Tue, 19 Apr 2022 23:28:54 +0100 Subject: [PATCH] snes9x: init at 1.61 This is done by modifying the current `snes9x-gtk` derivation, including a new `withGtk` option that when enabled will build the `snes9x-gtk`, but when disabled will build `snes9x` instead. `snes9x` has less dependencies than `snes9x-gtk`, having only X11 as a major dependency and a minor one in ALSA. However, the only audio backend supported is ALSA, so audio is only available on Linux. Still, this has less dependencies than the GTK version, so it should be useful as a minimal version for cross-compilation cases or when porting to new devices. This also builds in macOS, however as I said before, shouldn't have any sound there. --- .../emulators/snes9x-gtk/default.nix | 37 ------ .../applications/emulators/snes9x/default.nix | 120 ++++++++++++++++++ pkgs/top-level/all-packages.nix | 6 +- 3 files changed, 125 insertions(+), 38 deletions(-) delete mode 100644 pkgs/applications/emulators/snes9x-gtk/default.nix create mode 100644 pkgs/applications/emulators/snes9x/default.nix diff --git a/pkgs/applications/emulators/snes9x-gtk/default.nix b/pkgs/applications/emulators/snes9x-gtk/default.nix deleted file mode 100644 index ff7df4b09440..000000000000 --- a/pkgs/applications/emulators/snes9x-gtk/default.nix +++ /dev/null @@ -1,37 +0,0 @@ -{ lib, stdenv, fetchFromGitHub, meson, ninja, pkg-config, wrapGAppsHook, alsa-lib -, SDL2, zlib, gtkmm3, libXv, libepoxy, minizip, pulseaudio, portaudio }: - -stdenv.mkDerivation rec { - pname = "snes9x-gtk"; - version = "1.61"; - - src = fetchFromGitHub { - owner = "snes9xgit"; - repo = "snes9x"; - rev = version; - fetchSubmodules = true; - sha256 = "1kay7aj30x0vn8rkylspdycydrzsc0aidjbs0dd238hr5hid723b"; - }; - - nativeBuildInputs = [ meson ninja pkg-config wrapGAppsHook ]; - buildInputs = [ alsa-lib SDL2 zlib gtkmm3 libXv libepoxy minizip pulseaudio portaudio ]; - - preConfigure = "cd gtk"; - - meta = with lib; { - homepage = "https://www.snes9x.com"; - description = "Super Nintendo Entertainment System (SNES) emulator"; - - longDescription = '' - Snes9x is a portable, freeware Super Nintendo Entertainment System (SNES) - emulator. It basically allows you to play most games designed for the SNES - and Super Famicom Nintendo game systems on your PC or Workstation; which - includes some real gems that were only ever released in Japan. - ''; - - # see https://github.com/snes9xgit/snes9x/blob/master/LICENSE for exact details - license = licenses.unfreeRedistributable; - maintainers = with maintainers; [ qknight xfix ]; - platforms = platforms.linux; - }; -} diff --git a/pkgs/applications/emulators/snes9x/default.nix b/pkgs/applications/emulators/snes9x/default.nix new file mode 100644 index 000000000000..f8a315b7753f --- /dev/null +++ b/pkgs/applications/emulators/snes9x/default.nix @@ -0,0 +1,120 @@ +{ lib +, stdenv +, alsa-lib +, fetchFromGitHub +, gtkmm3 +, libepoxy +, libpng +, libX11 +, libXv +, libXext +, libXinerama +, meson +, minizip +, ninja +, pkg-config +, portaudio +, pulseaudio +, SDL2 +, wrapGAppsHook +, zlib +, withGtk ? false +}: + +stdenv.mkDerivation rec { + pname = + if withGtk then + "snes9x-gtk" + else + "snes9x"; + version = "1.61"; + + src = fetchFromGitHub { + owner = "snes9xgit"; + repo = "snes9x"; + rev = version; + fetchSubmodules = true; + sha256 = "1kay7aj30x0vn8rkylspdycydrzsc0aidjbs0dd238hr5hid723b"; + }; + + nativeBuildInputs = [ + pkg-config + ] + ++ lib.optionals withGtk [ + meson + ninja + wrapGAppsHook + ]; + + buildInputs = [ + libX11 + libXext + libXv + minizip + zlib + ] + # on non-Linux platforms this will build without sound support on X11 build + ++ lib.optionals stdenv.isLinux [ + alsa-lib + pulseaudio + ] + ++ lib.optionals (!withGtk) [ + libpng + libXinerama + ] + ++ lib.optionals withGtk [ + gtkmm3 + libepoxy + portaudio + SDL2 + ]; + + configureFlags = + lib.optional stdenv.hostPlatform.sse4_1Support "--enable-sse41" + ++ lib.optional stdenv.hostPlatform.avx2Support "--enable-avx2" + ++ lib.optional stdenv.hostPlatform.isAarch64 "--enable-neon"; + + installPhase = lib.optionalString (!withGtk) '' + runHook preInstall + + install -Dm755 snes9x -t "$out/bin/" + install -Dm644 snes9x.conf.default -t "$out/share/doc/${pname}/" + install -Dm644 ../docs/{control-inputs,controls,snapshots}.txt -t \ + "$out/share/doc/${pname}/" + + runHook postInstall + ''; + + preConfigure = + if withGtk then + "cd gtk" + else + "cd unix"; + + enableParallelBuilding = true; + + meta = with lib; + let + interface = if withGtk then "GTK" else "X11"; + in + { + homepage = "https://www.snes9x.com"; + description = "Super Nintendo Entertainment System (SNES) emulator, ${interface} version"; + + longDescription = '' + Snes9x is a portable, freeware Super Nintendo Entertainment System (SNES) + emulator. It basically allows you to play most games designed for the SNES + and Super Famicom Nintendo game systems on your PC or Workstation; which + includes some real gems that were only ever released in Japan. + + Version build with ${interface} interface. + ''; + + license = licenses.unfreeRedistributable // { + url = "https://github.com/snes9xgit/snes9x/blob/${version}/LICENSE"; + }; + maintainers = with maintainers; [ qknight xfix thiagokokada ]; + platforms = platforms.unix; + broken = (withGtk && stdenv.isDarwin); + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 789360728dfd..12c158f1e350 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -1338,7 +1338,11 @@ with pkgs; simplenes = callPackage ../applications/emulators/simplenes { }; - snes9x-gtk = callPackage ../applications/emulators/snes9x-gtk { }; + snes9x = callPackage ../applications/emulators/snes9x { }; + + snes9x-gtk = callPackage ../applications/emulators/snes9x { + withGtk = true; + }; stella = callPackage ../applications/emulators/stella { };