memogram: init at 0.2.2 (#379792)
[NixPkgs.git] / pkgs / applications / emulators / zsnes / default.nix
blob718ce9e371280c1e655384db5994b14a09d2b87e
2   lib,
3   stdenv,
4   fetchFromGitHub,
5   nasm,
6   SDL,
7   zlib,
8   libpng,
9   ncurses,
10   libGLU,
11   libGL,
12   makeDesktopItem,
15 let
16   desktopItem = makeDesktopItem {
17     name = "zsnes";
18     exec = "zsnes";
19     icon = "zsnes";
20     comment = "A SNES emulator";
21     desktopName = "zsnes";
22     genericName = "zsnes";
23     categories = [ "Game" ];
24   };
27 stdenv.mkDerivation {
28   pname = "zsnes";
29   version = "1.51";
31   src = fetchFromGitHub {
32     owner = "emillon";
33     repo = "zsnes";
34     rev = "fc160b2538738995f600f8405d23a66b070dac02";
35     sha256 = "1gy79d5wdaacph0cc1amw7mqm7i0716n6mvav16p1svi26iz193v";
36   };
38   patches = [
39     ./zlib-1.3.patch
40     ./fortify3.patch
41   ];
43   buildInputs = [
44     nasm
45     SDL
46     zlib
47     libpng
48     ncurses
49     libGLU
50     libGL
51   ];
53   prePatch = ''
54     for i in $(cat debian/patches/series); do
55       echo "applying $i"
56       patch -p1 < "debian/patches/$i"
57     done
58   '';
60   # Workaround build failure on -fno-common toolchains:
61   #   ld: initc.o:(.bss+0x28): multiple definition of `HacksDisable'; cfg.o:(.bss+0x59e3): first defined here
62   # Use pre-c++17 standard (c++17 forbids throw annotations)
63   env.NIX_CFLAGS_COMPILE = "-fcommon -std=c++14";
65   preConfigure = ''
66     cd src
67     sed -i "/^STRIP/d" configure
68     sed -i "/\$STRIP/d" configure
69   '';
71   configureFlags = [ "--enable-release" ];
73   postInstall = ''
74     function installIcon () {
75         mkdir -p $out/share/icons/hicolor/$1/apps/
76         cp icons/$1x32.png $out/share/icons/hicolor/$1/apps/zsnes.png
77     }
78     installIcon "16x16"
79     installIcon "32x32"
80     installIcon "48x48"
81     installIcon "64x64"
83     mkdir -p $out/share/applications
84     ln -s ${desktopItem}/share/applications/* $out/share/applications/
85   '';
87   meta = {
88     description = "Super Nintendo Entertainment System Emulator";
89     license = lib.licenses.gpl2Plus;
90     maintainers = [ lib.maintainers.sander ];
91     homepage = "https://www.zsnes.com";
92     platforms = [
93       "i686-linux"
94       "x86_64-linux"
95     ];
96     mainProgram = "zsnes";
97   };