···1+{ lib, stdenv, fetchFromGitHub
2+, pkg-config
3+, libX11, libXv
4+, udev
5+, SDL2
6+, gtk2, gtksourceview
7+, alsa-lib, libao, openal, libpulseaudio
8+, libicns, Cocoa, OpenAL
9+}:
10+11+stdenv.mkDerivation {
12+ pname = "bsnes-hd";
13+ version = "10.6-beta";
14+15+ src = fetchFromGitHub {
16+ owner = "DerKoun";
17+ repo = "bsnes-hd";
18+ rev = "beta_10_6";
19+ sha256 = "0f3cd89fd0lqskzj98cc1pzmdbscq0psdjckp86w94rbchx7iw4h";
20+ };
21+22+ patches = [
23+ # Replace invocation of `sips` with an equivalent invocation of `png2icns`
24+ # while assembling the .app directory hierarchy in the macos build. The
25+ # `sips` executable isn't in our environment during the build, but
26+ # `png2icns` is available by way of the dependency on libicns.
27+ ./macos-replace-sips-with-png2icns.patch
28+29+ # During `make install` on macos the Makefile wants to move the .app into
30+ # the current user's home directory. This patches the Makefile such that
31+ # the .app ends up in $(prefix)/Applications. The $(prefix) variable will
32+ # be set to $out, so this will result in the .app ending up in the
33+ # Applications directory in the current nix profile.
34+ ./macos-copy-app-to-prefix.patch
35+ ];
36+37+ nativeBuildInputs = [ pkg-config ]
38+ ++ lib.optionals stdenv.isDarwin [ libicns ];
39+40+ buildInputs = [ SDL2 libao ]
41+ ++ lib.optionals stdenv.isLinux [ libX11 libXv udev gtk2 gtksourceview alsa-lib openal libpulseaudio ]
42+ ++ lib.optionals stdenv.isDarwin [ Cocoa OpenAL ];
43+44+ enableParallelBuilding = true;
45+46+ makeFlags = [ "-C" "bsnes" "prefix=$(out)" ];
47+48+ meta = with lib; {
49+ description = "A fork of bsnes that adds HD video features";
50+ homepage = "https://github.com/DerKoun/bsnes-hd";
51+ license = licenses.gpl3Only;
52+ maintainers = with maintainers; [ stevebob ];
53+ platforms = platforms.unix;
54+ };
55+}