From 306c53df2ee02531f13804a65195eecc9c60f7ff Mon Sep 17 00:00:00 2001 From: Anderson Torres Date: Wed, 24 Apr 2024 20:11:32 -0300 Subject: [PATCH] snes9x: 1.62.3 -> 1.62.3-unstable-2024-04-22 - finalAttrs design pattern - split outputs - reorder buildInputs - libselinux and util-linuxMinimal are obviously Linux-only - get rid of nested with - Add AndersonTorres as maintainer --- .../applications/emulators/snes9x/default.nix | 123 +++++++++--------- 1 file changed, 63 insertions(+), 60 deletions(-) diff --git a/pkgs/applications/emulators/snes9x/default.nix b/pkgs/applications/emulators/snes9x/default.nix index 8f374b7e1818..c3d19bac383b 100644 --- a/pkgs/applications/emulators/snes9x/default.nix +++ b/pkgs/applications/emulators/snes9x/default.nix @@ -1,46 +1,44 @@ -{ lib -, stdenv -, alsa-lib -, cmake -, fetchFromGitHub -, gtkmm3 -, libepoxy -, libpng -, libselinux -, libX11 -, libXdmcp -, libXext -, libXinerama -, libXrandr -, libXv -, minizip -, ninja -, pcre2 -, pkg-config -, portaudio -, pulseaudio -, python3 -, SDL2 -, util-linuxMinimal -, wrapGAppsHook -, zlib -, withGtk ? false +{ + lib, + SDL2, + alsa-lib, + cmake, + fetchFromGitHub, + gtkmm3, + libX11, + libXdmcp, + libXext, + libXinerama, + libXrandr, + libXv, + libepoxy, + libpng, + libselinux, + minizip, + ninja, + pcre2, + pkg-config, + portaudio, + pulseaudio, + python3, + stdenv, + util-linuxMinimal, + wrapGAppsHook, + zlib, + # Boolean flags + withGtk ? false, }: -stdenv.mkDerivation rec { - pname = - if withGtk then - "snes9x-gtk" - else - "snes9x"; - version = "1.62.3"; +stdenv.mkDerivation (finalAttrs: { + pname = "snes9x" + lib.optionalString withGtk "-gtk"; + version = "1.62.3-unstable-2024-04-22"; src = fetchFromGitHub { owner = "snes9xgit"; repo = "snes9x"; - rev = version; + rev = "582128bce7ccf4e3cf7848ae9f6a729a1ebad4c4"; fetchSubmodules = true; - hash = "sha256-+KHpvz7nfwGXjzDAK/V+2JDRT1sa0kXDkg7XcRyvSP8="; + hash = "sha256-fJ1g/L7oA9bhEawTsWjfLl1dDIKEGI+pcpWQCTutyR8="; }; nativeBuildInputs = [ @@ -59,10 +57,11 @@ stdenv.mkDerivation rec { minizip zlib ] - # on non-Linux platforms this will build without sound support on X11 build ++ lib.optionals stdenv.isLinux [ alsa-lib pulseaudio + libselinux + util-linuxMinimal # provides libmount ] ++ lib.optionals (!withGtk) [ libpng @@ -72,42 +71,43 @@ stdenv.mkDerivation rec { ++ lib.optionals withGtk [ gtkmm3 libepoxy - libselinux libXdmcp libXrandr pcre2 portaudio SDL2 - util-linuxMinimal # provides libmount ]; - configureFlags = - lib.optional stdenv.hostPlatform.sse4_1Support "--enable-sse41" - ++ lib.optional stdenv.hostPlatform.avx2Support "--enable-avx2"; + hardeningDisable = [ "format" ]; + + configureFlags = lib.optionals stdenv.hostPlatform.sse4_1Support [ + "--enable-sse41" + ] + ++ lib.optionals stdenv.hostPlatform.avx2Support [ + "--enable-avx2" + ]; + + preConfigure = '' + cd ${if withGtk then "gtk" else "unix"} + ''; installPhase = lib.optionalString (!withGtk) '' runHook preInstall install -Dm755 snes9x -t "$out/bin/" - install -Dm644 snes9x.conf.default -t "$out/share/doc/${pname}/" + install -Dm644 snes9x.conf.default -t "$out/share/doc/${finalAttrs.pname}/" install -Dm644 ../docs/{control-inputs,controls,snapshots}.txt -t \ - "$out/share/doc/${pname}/" + "$out/share/doc/${finalAttrs.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 + meta = 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 @@ -116,13 +116,16 @@ stdenv.mkDerivation rec { Version build with ${interface} interface. ''; - - license = licenses.unfreeRedistributable // { - url = "https://github.com/snes9xgit/snes9x/blob/${version}/LICENSE"; + license = lib.licenses.unfreeRedistributable // { + url = "https://github.com/snes9xgit/snes9x/blob/${finalAttrs.src.rev}/LICENSE"; }; - maintainers = with maintainers; [ qknight thiagokokada ]; - platforms = platforms.unix; - broken = (withGtk && stdenv.isDarwin); mainProgram = "snes9x"; + maintainers = with lib.maintainers; [ + AndersonTorres + qknight + thiagokokada + ]; + platforms = lib.platforms.unix; + broken = (withGtk && stdenv.isDarwin); }; -} +})