···11+{ lib, stdenv, fetchFromGitHub
22+, pkg-config
33+, libX11, libXv
44+, udev
55+, SDL2
66+, gtk2, gtksourceview
77+, alsa-lib, libao, openal, libpulseaudio
88+, libicns, Cocoa, OpenAL
99+}:
1010+1111+stdenv.mkDerivation {
1212+ pname = "bsnes-hd";
1313+ version = "10.6-beta";
1414+1515+ src = fetchFromGitHub {
1616+ owner = "DerKoun";
1717+ repo = "bsnes-hd";
1818+ rev = "beta_10_6";
1919+ sha256 = "0f3cd89fd0lqskzj98cc1pzmdbscq0psdjckp86w94rbchx7iw4h";
2020+ };
2121+2222+ patches = [
2323+ # Replace invocation of `sips` with an equivalent invocation of `png2icns`
2424+ # while assembling the .app directory hierarchy in the macos build. The
2525+ # `sips` executable isn't in our environment during the build, but
2626+ # `png2icns` is available by way of the dependency on libicns.
2727+ ./macos-replace-sips-with-png2icns.patch
2828+2929+ # During `make install` on macos the Makefile wants to move the .app into
3030+ # the current user's home directory. This patches the Makefile such that
3131+ # the .app ends up in $(prefix)/Applications. The $(prefix) variable will
3232+ # be set to $out, so this will result in the .app ending up in the
3333+ # Applications directory in the current nix profile.
3434+ ./macos-copy-app-to-prefix.patch
3535+ ];
3636+3737+ nativeBuildInputs = [ pkg-config ]
3838+ ++ lib.optionals stdenv.isDarwin [ libicns ];
3939+4040+ buildInputs = [ SDL2 libao ]
4141+ ++ lib.optionals stdenv.isLinux [ libX11 libXv udev gtk2 gtksourceview alsa-lib openal libpulseaudio ]
4242+ ++ lib.optionals stdenv.isDarwin [ Cocoa OpenAL ];
4343+4444+ enableParallelBuilding = true;
4545+4646+ makeFlags = [ "-C" "bsnes" "prefix=$(out)" ];
4747+4848+ meta = with lib; {
4949+ description = "A fork of bsnes that adds HD video features";
5050+ homepage = "https://github.com/DerKoun/bsnes-hd";
5151+ license = licenses.gpl3Only;
5252+ maintainers = with maintainers; [ stevebob ];
5353+ platforms = platforms.unix;
5454+ };
5555+}