about summary refs log tree commit diff
path: root/nixpkgs/pkgs/misc/emulators
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/misc/emulators')
-rw-r--r--nixpkgs/pkgs/misc/emulators/atari++/default.nix32
-rw-r--r--nixpkgs/pkgs/misc/emulators/atari800/default.nix43
-rw-r--r--nixpkgs/pkgs/misc/emulators/attract-mode/default.nix33
-rw-r--r--nixpkgs/pkgs/misc/emulators/blastem/default.nix50
-rw-r--r--nixpkgs/pkgs/misc/emulators/bsod/default.nix31
-rw-r--r--nixpkgs/pkgs/misc/emulators/caprice32/default.nix47
-rw-r--r--nixpkgs/pkgs/misc/emulators/ccemux/default.nix67
-rw-r--r--nixpkgs/pkgs/misc/emulators/cdemu/analyzer.nix21
-rw-r--r--nixpkgs/pkgs/misc/emulators/cdemu/base.nix37
-rw-r--r--nixpkgs/pkgs/misc/emulators/cdemu/client.nix16
-rw-r--r--nixpkgs/pkgs/misc/emulators/cdemu/daemon.nix9
-rw-r--r--nixpkgs/pkgs/misc/emulators/cdemu/gui.nix23
-rw-r--r--nixpkgs/pkgs/misc/emulators/cdemu/libmirage.nix18
-rw-r--r--nixpkgs/pkgs/misc/emulators/cdemu/vhba.nix24
-rw-r--r--nixpkgs/pkgs/misc/emulators/citra/default.nix31
-rw-r--r--nixpkgs/pkgs/misc/emulators/craftos-pc/default.nix43
-rw-r--r--nixpkgs/pkgs/misc/emulators/darcnes/default.nix24
-rw-r--r--nixpkgs/pkgs/misc/emulators/darcnes/label.patch13
-rw-r--r--nixpkgs/pkgs/misc/emulators/desmume/01_use_system_tinyxml.patch231
-rw-r--r--nixpkgs/pkgs/misc/emulators/desmume/default.nix57
-rw-r--r--nixpkgs/pkgs/misc/emulators/desmume/gcc6_fixes.patch59
-rw-r--r--nixpkgs/pkgs/misc/emulators/desmume/gcc7_fixes.patch18
-rw-r--r--nixpkgs/pkgs/misc/emulators/dgen-sdl/default.nix70
-rw-r--r--nixpkgs/pkgs/misc/emulators/dlx/default.nix31
-rw-r--r--nixpkgs/pkgs/misc/emulators/dolphin-emu/default.nix122
-rw-r--r--nixpkgs/pkgs/misc/emulators/dolphin-emu/master.nix88
-rw-r--r--nixpkgs/pkgs/misc/emulators/dosbox/default.nix46
-rw-r--r--nixpkgs/pkgs/misc/emulators/duckstation/default.nix34
-rw-r--r--nixpkgs/pkgs/misc/emulators/emu2/default.nix23
-rw-r--r--nixpkgs/pkgs/misc/emulators/emulationstation/default.nix37
-rw-r--r--nixpkgs/pkgs/misc/emulators/epsxe/default.nix52
-rw-r--r--nixpkgs/pkgs/misc/emulators/fakenes/build.patch84
-rw-r--r--nixpkgs/pkgs/misc/emulators/fakenes/default.nix32
-rw-r--r--nixpkgs/pkgs/misc/emulators/fceux/default.nix40
-rw-r--r--nixpkgs/pkgs/misc/emulators/firebird-emu/default.nix38
-rw-r--r--nixpkgs/pkgs/misc/emulators/fs-uae/default.nix32
-rw-r--r--nixpkgs/pkgs/misc/emulators/fuse-emulator/default.nix29
-rw-r--r--nixpkgs/pkgs/misc/emulators/gens-gs/default.nix25
-rw-r--r--nixpkgs/pkgs/misc/emulators/gxemul/default.nix35
-rw-r--r--nixpkgs/pkgs/misc/emulators/hatari/default.nix25
-rw-r--r--nixpkgs/pkgs/misc/emulators/higan/0001-change-flags.diff25
-rw-r--r--nixpkgs/pkgs/misc/emulators/higan/default.nix135
-rw-r--r--nixpkgs/pkgs/misc/emulators/kega-fusion/default.nix78
-rw-r--r--nixpkgs/pkgs/misc/emulators/lambda-delta/default.nix26
-rw-r--r--nixpkgs/pkgs/misc/emulators/libdsk/default.nix19
-rw-r--r--nixpkgs/pkgs/misc/emulators/mame/default.nix89
-rw-r--r--nixpkgs/pkgs/misc/emulators/mame/emuopts.patch29
-rw-r--r--nixpkgs/pkgs/misc/emulators/mednafen/default.nix74
-rw-r--r--nixpkgs/pkgs/misc/emulators/mednafen/server.nix21
-rw-r--r--nixpkgs/pkgs/misc/emulators/mednaffe/default.nix43
-rw-r--r--nixpkgs/pkgs/misc/emulators/melonDS/default.nix41
-rw-r--r--nixpkgs/pkgs/misc/emulators/mgba/default.nix62
-rw-r--r--nixpkgs/pkgs/misc/emulators/mupen64plus/default.nix29
-rw-r--r--nixpkgs/pkgs/misc/emulators/nestopia/build-fix.patch18
-rw-r--r--nixpkgs/pkgs/misc/emulators/nestopia/default.nix72
-rw-r--r--nixpkgs/pkgs/misc/emulators/nestopia/gcc6.patch92
-rw-r--r--nixpkgs/pkgs/misc/emulators/np2kai/default.nix196
-rw-r--r--nixpkgs/pkgs/misc/emulators/oberon-risc-emu/default.nix27
-rw-r--r--nixpkgs/pkgs/misc/emulators/openmsx/custom-nix.mk9
-rw-r--r--nixpkgs/pkgs/misc/emulators/openmsx/default.nix48
-rw-r--r--nixpkgs/pkgs/misc/emulators/pcem/default.nix29
-rw-r--r--nixpkgs/pkgs/misc/emulators/pcsx2/default.nix113
-rw-r--r--nixpkgs/pkgs/misc/emulators/pcsxr/default.nix87
-rw-r--r--nixpkgs/pkgs/misc/emulators/pcsxr/uncompress2.patch20
-rw-r--r--nixpkgs/pkgs/misc/emulators/ppsspp/default.nix70
-rw-r--r--nixpkgs/pkgs/misc/emulators/qmc2/default.nix41
-rw-r--r--nixpkgs/pkgs/misc/emulators/reicast/default.nix52
-rw-r--r--nixpkgs/pkgs/misc/emulators/resim/default.nix20
-rw-r--r--nixpkgs/pkgs/misc/emulators/retroarch/cores.nix1098
-rw-r--r--nixpkgs/pkgs/misc/emulators/retroarch/default.nix63
-rw-r--r--nixpkgs/pkgs/misc/emulators/retroarch/kodi-advanced-launchers.nix40
-rw-r--r--nixpkgs/pkgs/misc/emulators/retroarch/wrapper.nix37
-rw-r--r--nixpkgs/pkgs/misc/emulators/retrofe/default.nix78
-rw-r--r--nixpkgs/pkgs/misc/emulators/retrofe/include-paths.patch11
-rw-r--r--nixpkgs/pkgs/misc/emulators/rpcs3/default.nix54
-rw-r--r--nixpkgs/pkgs/misc/emulators/ruffle/default.nix57
-rw-r--r--nixpkgs/pkgs/misc/emulators/ryujinx/default.nix106
-rw-r--r--nixpkgs/pkgs/misc/emulators/ryujinx/deps.nix1072
-rwxr-xr-xnixpkgs/pkgs/misc/emulators/ryujinx/fetch-deps.sh41
-rw-r--r--nixpkgs/pkgs/misc/emulators/ryujinx/log.patch13
-rw-r--r--nixpkgs/pkgs/misc/emulators/sameboy/default.nix53
-rw-r--r--nixpkgs/pkgs/misc/emulators/simh/default.nix62
-rw-r--r--nixpkgs/pkgs/misc/emulators/simplenes/default.nix33
-rw-r--r--nixpkgs/pkgs/misc/emulators/snes9x-gtk/default.nix36
-rw-r--r--nixpkgs/pkgs/misc/emulators/stella/default.nix33
-rw-r--r--nixpkgs/pkgs/misc/emulators/termtekst/default.nix36
-rw-r--r--nixpkgs/pkgs/misc/emulators/tilem/default.nix30
-rw-r--r--nixpkgs/pkgs/misc/emulators/uae/default.nix26
-rw-r--r--nixpkgs/pkgs/misc/emulators/vbam/default.nix57
-rw-r--r--nixpkgs/pkgs/misc/emulators/vice/default.nix53
-rw-r--r--nixpkgs/pkgs/misc/emulators/wine/base.nix155
-rw-r--r--nixpkgs/pkgs/misc/emulators/wine/builder-wow.sh30
-rw-r--r--nixpkgs/pkgs/misc/emulators/wine/cert-path-stable.patch24
-rw-r--r--nixpkgs/pkgs/misc/emulators/wine/cert-path.patch23
-rw-r--r--nixpkgs/pkgs/misc/emulators/wine/default.nix69
-rw-r--r--nixpkgs/pkgs/misc/emulators/wine/fonts.nix22
-rw-r--r--nixpkgs/pkgs/misc/emulators/wine/packages.nix38
-rw-r--r--nixpkgs/pkgs/misc/emulators/wine/sources.nix78
-rw-r--r--nixpkgs/pkgs/misc/emulators/wine/staging.nix28
-rw-r--r--nixpkgs/pkgs/misc/emulators/wine/util.nix9
-rw-r--r--nixpkgs/pkgs/misc/emulators/wine/vkd3d.nix26
-rw-r--r--nixpkgs/pkgs/misc/emulators/wine/winetricks.nix32
-rw-r--r--nixpkgs/pkgs/misc/emulators/wxmupen64plus/default.nix30
-rw-r--r--nixpkgs/pkgs/misc/emulators/xcpc/default.nix29
-rw-r--r--nixpkgs/pkgs/misc/emulators/yabause/0001-Fixes-for-Qt-5.11-upgrade.patch67
-rw-r--r--nixpkgs/pkgs/misc/emulators/yabause/default.nix36
-rw-r--r--nixpkgs/pkgs/misc/emulators/yabause/linkage-rwx-linux-elf.patch20
-rw-r--r--nixpkgs/pkgs/misc/emulators/yuzu/default.nix47
-rw-r--r--nixpkgs/pkgs/misc/emulators/zsnes/default.nix63
109 files changed, 7250 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/misc/emulators/atari++/default.nix b/nixpkgs/pkgs/misc/emulators/atari++/default.nix
new file mode 100644
index 000000000000..2019820510ef
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/atari++/default.nix
@@ -0,0 +1,32 @@
+{ lib, stdenv, fetchurl, libSM, libX11, libICE, SDL, alsaLib, gcc-unwrapped, libXext }:
+
+stdenv.mkDerivation rec {
+  pname = "atari++";
+  version = "1.83";
+
+  src = fetchurl {
+    url = "http://www.xl-project.com/download/${pname}_${version}.tar.gz";
+    sha256 = "04fm2ic2qi4a52mi72wcaxyrpll4k8vvchx3qrik8rhg3jrxgm47";
+  };
+
+  buildInputs = [ libSM libX11 SDL libICE alsaLib gcc-unwrapped libXext ];
+
+  postFixup = ''
+    patchelf --set-rpath ${lib.makeLibraryPath buildInputs} "$out/bin/atari++"
+  '';
+
+  meta = with lib; {
+    homepage = "http://www.xl-project.com/";
+    description = "An enhanced, cycle-accurated Atari emulator";
+    longDescription = ''
+      The Atari++ Emulator is a Unix based emulator of the Atari eight
+      bit computers, namely the Atari 400 and 800, the Atari 400XL,
+      800XL and 130XE, and the Atari 5200 game console. The emulator
+      is auto-configurable and will compile on a variety of systems
+      (Linux, Solaris, Irix).
+    '';
+    maintainers = [ maintainers.AndersonTorres ];
+    license = licenses.gpl2Plus;
+    platforms = lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/atari800/default.nix b/nixpkgs/pkgs/misc/emulators/atari800/default.nix
new file mode 100644
index 000000000000..163b81922c2b
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/atari800/default.nix
@@ -0,0 +1,43 @@
+{ lib, stdenv, fetchFromGitHub, autoreconfHook
+, unzip, zlib, SDL, readline, libGLU, libGL, libX11 }:
+
+with lib;
+stdenv.mkDerivation rec {
+  pname = "atari800";
+  version = "4.2.0";
+
+  src = fetchFromGitHub {
+    owner = "atari800";
+    repo = "atari800";
+    rev = "ATARI800_${replaceChars ["."] ["_"] version}";
+    sha256 = "15l08clqqayi9izrgsz9achan6gl4x57wqsc8mad3yn0xayzz3qy";
+  };
+
+  nativeBuildInputs = [ autoreconfHook ];
+
+  buildInputs = [ unzip zlib SDL readline libGLU libGL libX11 ];
+
+  configureFlags = [
+    "--target=default"
+    "--with-video=sdl"
+    "--with-sound=sdl"
+    "--with-readline"
+    "--with-opengl"
+    "--with-x"
+    "--enable-riodevice"
+  ];
+
+  meta = {
+    homepage = "https://atari800.github.io/";
+    description = "An Atari 8-bit emulator";
+    longDescription = ''
+      Atari800 is the emulator of Atari 8-bit computer systems and
+      5200 game console for Unix, Linux, Amiga, MS-DOS, Atari
+      TT/Falcon, MS-Windows, MS WinCE, Sega Dreamcast, Android and
+      other systems supported by the SDL library.
+    '';
+    maintainers = [ maintainers.AndersonTorres ];
+    license = licenses.gpl2Plus;
+    platforms = lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/attract-mode/default.nix b/nixpkgs/pkgs/misc/emulators/attract-mode/default.nix
new file mode 100644
index 000000000000..92c42a1d3943
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/attract-mode/default.nix
@@ -0,0 +1,33 @@
+{ expat, fetchFromGitHub, ffmpeg_3, fontconfig, freetype, libarchive, libjpeg
+, libGLU, libGL, openal, pkg-config, sfml, lib, stdenv, zlib
+}:
+
+stdenv.mkDerivation rec {
+  pname = "attract-mode";
+  version = "2.6.1";
+
+  src = fetchFromGitHub {
+    owner = "mickelson";
+    repo = "attract";
+    rev = "v${version}";
+    sha256 = "16p369j0hanm0l2fiy6h9d9pn0f3qblcy9l39all6h7rfxnhp9ii";
+  };
+
+  nativeBuildInputs = [ pkg-config ];
+
+  patchPhase = ''
+    sed -i "s|prefix=/usr/local|prefix=$out|" Makefile
+  '';
+
+  buildInputs = [
+    expat ffmpeg_3 fontconfig freetype libarchive libjpeg libGLU libGL openal sfml zlib
+  ];
+
+  meta = with lib; {
+    description = "A frontend for arcade cabinets and media PCs";
+    homepage = "http://attractmode.org";
+    license = licenses.gpl3Plus;
+    maintainers = with maintainers; [ hrdinka ];
+    platforms = with platforms; linux;
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/blastem/default.nix b/nixpkgs/pkgs/misc/emulators/blastem/default.nix
new file mode 100644
index 000000000000..eba646e2f20f
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/blastem/default.nix
@@ -0,0 +1,50 @@
+{ lib, stdenv, fetchurl, fetchFromGitHub, pkg-config, SDL2, glew, xcftools, python, pillow, makeWrapper }:
+
+let
+  vasm =
+    stdenv.mkDerivation {
+      pname = "vasm";
+      version = "1.8c";
+      src = fetchFromGitHub {
+        owner = "mbitsnbites";
+        repo = "vasm";
+        rev = "244f8bbbdf64ae603f9f6c09a3067943837459ec";
+        sha256 = "0x4y5q7ygxfjfy2wxijkps9khsjjfb169sbda410vaw0m88wqj5p";
+      };
+      makeFlags = [ "CPU=m68k" "SYNTAX=mot" ];
+      installPhase = ''
+        mkdir -p $out/bin
+        cp vasmm68k_mot $out/bin
+      '';
+    };
+in
+stdenv.mkDerivation {
+  pname = "blastem";
+  version = "0.5.1";
+  src = fetchurl {
+    url = "https://www.retrodev.com/repos/blastem/archive/3d48cb0c28be.tar.gz";
+    sha256 = "07wzbmzp0y8mh59jxg81q17gqagz3psxigxh8dmzsipgg68y6a8r";
+  };
+  buildInputs = [ pkg-config SDL2 glew xcftools python pillow vasm makeWrapper ];
+  preBuild = ''
+    patchShebangs img2tiles.py
+  '';
+  postBuild = ''
+    make menu.bin
+  '';
+  installPhase = ''
+    mkdir -p $out/bin $out/share/blastem
+    cp -r {blastem,menu.bin,default.cfg,rom.db,shaders} $out/share/blastem/
+    makeWrapper $out/share/blastem/blastem $out/bin/blastem
+  '';
+
+  meta = {
+    homepage = "https://www.retrodev.com/blastem/";
+    description = "The fast and accurate Genesis emulator";
+    maintainers = with lib.maintainers; [ puffnfresh ];
+    license = lib.licenses.gpl3;
+    platforms = lib.platforms.linux;
+    # Makefile:140: *** aarch64 is not a supported architecture.  Stop.
+    badPlatforms = [ "aarch64-linux" ];
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/bsod/default.nix b/nixpkgs/pkgs/misc/emulators/bsod/default.nix
new file mode 100644
index 000000000000..872ee8571f30
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/bsod/default.nix
@@ -0,0 +1,31 @@
+{lib, stdenv, fetchurl, ncurses}:
+
+stdenv.mkDerivation {
+  name = "bsod-0.1";
+
+  src = fetchurl {
+    url = "https://www.vanheusden.com/bsod/bsod-0.1.tgz";
+    sha256 = "0hqwacazyq5rhc04j8w8w0j0dgb6ca8k66c9lxf6bsyi6wvbhvmd";
+  };
+
+  buildInputs = [ ncurses ];
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp bsod $out/bin
+  '';
+
+  meta = {
+    description = "Blue Screen Of Death emulator for Unix";
+    longDescription = "
+      This program will let you UNIX user experience the authentic
+      microsoft windows experience.  Bsod displays the famous windows xp
+      blue screen of death on the console.  Errors and drivers causing the
+      error are selected randomly from a large set of examples.";
+    homepage = "http://www.vanheusden.com/bsod/";
+    license = lib.licenses.gpl2;
+    platforms = lib.platforms.unix;
+    maintainers = [ lib.maintainers.antono ];
+  };
+
+}
diff --git a/nixpkgs/pkgs/misc/emulators/caprice32/default.nix b/nixpkgs/pkgs/misc/emulators/caprice32/default.nix
new file mode 100644
index 000000000000..3e20ba616423
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/caprice32/default.nix
@@ -0,0 +1,47 @@
+{ lib, stdenv, fetchFromGitHub, desktop-file-utils, libpng
+, pkg-config, SDL, freetype, zlib }:
+
+stdenv.mkDerivation rec {
+
+  pname = "caprice32";
+  version = "4.6.0";
+
+  src = fetchFromGitHub {
+    repo = "caprice32";
+    rev = "v${version}";
+    owner = "ColinPitrat";
+    sha256 = "0hng5krwgc1h9bz1xlkp2hwnvas965nd7sb3z9mb2m6x9ghxlacz";
+  };
+
+  nativeBuildInputs = [ desktop-file-utils pkg-config ];
+  buildInputs = [ libpng SDL freetype zlib ];
+
+  makeFlags = [
+    "APP_PATH=${placeholder "out"}/share/caprice32"
+    "RELEASE=1"
+    "DESTDIR=${placeholder "out"}"
+    "prefix=/"
+  ];
+
+  postInstall = ''
+    mkdir -p $out/share/icons/
+    mv $out/share/caprice32/resources/freedesktop/caprice32.png $out/share/icons/
+    mv $out/share/caprice32/resources/freedesktop/emulators.png $out/share/icons/
+
+    desktop-file-install --dir $out/share/applications \
+      $out/share/caprice32/resources/freedesktop/caprice32.desktop
+
+    desktop-file-install --dir $out/share/desktop-directories \
+      $out/share/caprice32/resources/freedesktop/Emulators.directory
+
+    install -Dm644 $out/share/caprice32/resources/freedesktop/caprice32.menu -t $out/etc/xdg/menus/applications-merged/
+  '';
+
+  meta = with lib; {
+    description = "A complete emulation of CPC464, CPC664 and CPC6128";
+    homepage = "https://github.com/ColinPitrat/caprice32";
+    license = licenses.gpl2;
+    maintainers = [ ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/ccemux/default.nix b/nixpkgs/pkgs/misc/emulators/ccemux/default.nix
new file mode 100644
index 000000000000..11f24d59e5c3
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/ccemux/default.nix
@@ -0,0 +1,67 @@
+{ lib, stdenv, fetchurl, makeDesktopItem, makeWrapper, jre
+, useCCTweaked ? true
+}:
+
+let
+  version = "1.1.1";
+  rev = "af12e2e4da586275ba931eae8f40a2201251bf59";
+
+  baseUrl = "https://emux.cc/versions/${lib.substring 0 8 rev}/CCEmuX";
+  jar =
+    if useCCTweaked
+    then fetchurl {
+      url = "${baseUrl}-cct.jar";
+      sha256 = "0d9gzi1h5vz32fp4lfn7dam189jcm7bwbqwmlpj0c47p8l0d4lsv";
+    }
+    else fetchurl {
+      url = "${baseUrl}-cc.jar";
+      sha256 = "0ky5vxh8m1v98zllifxif8xxd25j2xdp19hjnj4xlkck71lbnb34";
+    };
+
+  desktopIcon = fetchurl {
+    url = "https://github.com/CCEmuX/CCEmuX/raw/${rev}/src/main/resources/img/icon.png";
+    sha256 = "1vmb6rg9k2y99j8xqfgbsvfgfi3g985rmqwrd7w3y54ffr2r99c2";
+  };
+  desktopItem =  makeDesktopItem {
+    name = "CCEmuX";
+    exec = "ccemux";
+    icon = desktopIcon;
+    comment = "A modular ComputerCraft emulator";
+    desktopName = "CCEmuX";
+    genericName = "ComputerCraft Emulator";
+    categories = "Emulator;";
+  };
+in
+
+stdenv.mkDerivation rec {
+  pname = "ccemux";
+  inherit version;
+
+  src = jar;
+  dontUnpack = true;
+
+  nativeBuildInputs = [ makeWrapper ];
+  buildInputs = [ jre ];
+
+  installPhase = ''
+    runHook preInstall
+
+    mkdir -p $out/{bin,share/ccemux}
+    cp -r ${desktopItem}/share/applications $out/share/applications
+
+    install -D ${src} $out/share/ccemux/ccemux.jar
+    install -D ${desktopIcon} $out/share/pixmaps/ccemux.png
+
+    makeWrapper ${jre}/bin/java $out/bin/ccemux \
+      --add-flags "-jar $out/share/ccemux/ccemux.jar"
+
+    runHook postInstall
+  '';
+
+  meta = with lib; {
+    description = "A modular ComputerCraft emulator";
+    homepage = "https://github.com/CCEmuX/CCEmuX";
+    license = licenses.mit;
+    maintainers = with maintainers; [ CrazedProgrammer ];
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/cdemu/analyzer.nix b/nixpkgs/pkgs/misc/emulators/cdemu/analyzer.nix
new file mode 100644
index 000000000000..246dbb7dd350
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/cdemu/analyzer.nix
@@ -0,0 +1,21 @@
+{ callPackage, makeWrapper, gobject-introspection, cmake
+, python3Packages, gtk3, glib, libxml2, gnuplot, gnome3, gdk-pixbuf, librsvg, intltool, libmirage }:
+let pkg = import ./base.nix {
+  version = "3.2.3";
+  pkgName = "image-analyzer";
+  pkgSha256 = "17yfjmf65s77214qassz6l01cjcni4cv06nzfsm7qrzw172fmci4";
+};
+in callPackage pkg {
+  buildInputs = [ glib gtk3 libxml2 gnuplot libmirage makeWrapper
+                  gnome3.adwaita-icon-theme gdk-pixbuf librsvg intltool
+                  python3Packages.python python3Packages.pygobject3 python3Packages.matplotlib ];
+  drvParams = {
+    nativeBuildInputs = [ gobject-introspection cmake ];
+    postFixup = ''
+      wrapProgram $out/bin/image-analyzer \
+        --set PYTHONPATH "$PYTHONPATH" \
+        --set GI_TYPELIB_PATH "$GI_TYPELIB_PATH" \
+        --prefix XDG_DATA_DIRS : "$out/share:$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH"
+    '';
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/cdemu/base.nix b/nixpkgs/pkgs/misc/emulators/cdemu/base.nix
new file mode 100644
index 000000000000..6db1089a37f5
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/cdemu/base.nix
@@ -0,0 +1,37 @@
+{ pkgName, version, pkgSha256 }:
+{ lib, stdenv, fetchurl, cmake, pkg-config, buildInputs, drvParams ? {} }:
+let name = "${pkgName}-${version}";
+in stdenv.mkDerivation ({
+  inherit name buildInputs;
+  src = fetchurl {
+    url = "mirror://sourceforge/cdemu/${name}.tar.bz2";
+    sha256 = pkgSha256;
+  };
+  nativeBuildInputs = [ pkg-config cmake ];
+  setSourceRoot = ''
+    mkdir build
+    cd build
+    sourceRoot="`pwd`"
+  '';
+  configurePhase = ''
+    cmake ../${name} -DCMAKE_INSTALL_PREFIX=$out -DCMAKE_BUILD_TYPE=Release -DCMAKE_SKIP_RPATH=ON
+  '';
+  meta = with lib; {
+    description = "A suite of tools for emulating optical drives and discs";
+    longDescription = ''
+      CDEmu consists of:
+
+      - a kernel module implementing a virtual drive-controller
+      - libmirage which is a software library for interpreting optical disc images
+      - a daemon which emulates the functionality of an optical drive+disc
+      - textmode and GTK clients for controlling the emulator
+      - an image analyzer to view the structure of image files
+
+      Optical media emulated by CDemu can be mounted within Linux. Automounting is also allowed.
+    '';
+    homepage = "http://cdemu.sourceforge.net/";
+    license = licenses.gpl2Plus;
+    platforms = platforms.linux;
+    maintainers = with lib.maintainers; [ bendlas ];
+  };
+} // drvParams)
diff --git a/nixpkgs/pkgs/misc/emulators/cdemu/client.nix b/nixpkgs/pkgs/misc/emulators/cdemu/client.nix
new file mode 100644
index 000000000000..087b15cecd16
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/cdemu/client.nix
@@ -0,0 +1,16 @@
+{ callPackage, python3Packages, intltool, makeWrapper }:
+let pkg = import ./base.nix {
+  version = "3.2.3";
+  pkgName = "cdemu-client";
+  pkgSha256 = "1bvc2m63fx03rbp3ihgl2n7k24lwg5ydwkmr84gsjfcxp46q10zq";
+};
+in callPackage pkg {
+  buildInputs = [ python3Packages.python python3Packages.dbus-python python3Packages.pygobject3
+                  intltool makeWrapper ];
+  drvParams = {
+    postFixup = ''
+      wrapProgram $out/bin/cdemu \
+        --set PYTHONPATH "$PYTHONPATH"
+    '';
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/cdemu/daemon.nix b/nixpkgs/pkgs/misc/emulators/cdemu/daemon.nix
new file mode 100644
index 000000000000..db6ed7ddb47a
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/cdemu/daemon.nix
@@ -0,0 +1,9 @@
+{ callPackage, glib, libao, intltool, libmirage }:
+let pkg = import ./base.nix {
+  version = "3.2.3";
+  pkgName = "cdemu-daemon";
+  pkgSha256 = "022xzgwmncswb9md71w3ly3mjkdfc93lbij2llp2jamq8grxjjxr";
+};
+in callPackage pkg {
+  buildInputs = [ glib libao libmirage intltool ];
+}
diff --git a/nixpkgs/pkgs/misc/emulators/cdemu/gui.nix b/nixpkgs/pkgs/misc/emulators/cdemu/gui.nix
new file mode 100644
index 000000000000..599531950a21
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/cdemu/gui.nix
@@ -0,0 +1,23 @@
+{ callPackage, makeWrapper, gobject-introspection, cmake
+, python3Packages, gtk3, glib, libnotify, intltool, gnome3, gdk-pixbuf, librsvg }:
+let
+  pkg = import ./base.nix {
+    version = "3.2.3";
+    pkgName = "gcdemu";
+    pkgSha256 = "19vy1awha8s7cfja3a6npaf3rfy3pl3cbsh4vd609q9jz4v4lyg4";
+  };
+  inherit (python3Packages) python pygobject3;
+in callPackage pkg {
+  buildInputs = [ python pygobject3 gtk3 glib libnotify intltool makeWrapper
+                  gnome3.adwaita-icon-theme gdk-pixbuf librsvg ];
+  drvParams = {
+    nativeBuildInputs = [ gobject-introspection cmake ];
+    postFixup = ''
+      wrapProgram $out/bin/gcdemu \
+        --set PYTHONPATH "$PYTHONPATH" \
+        --set GI_TYPELIB_PATH "$GI_TYPELIB_PATH" \
+        --prefix XDG_DATA_DIRS : "$out/share:$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH"
+    '';
+    # TODO AppIndicator
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/cdemu/libmirage.nix b/nixpkgs/pkgs/misc/emulators/cdemu/libmirage.nix
new file mode 100644
index 000000000000..0b8090ce41d2
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/cdemu/libmirage.nix
@@ -0,0 +1,18 @@
+{ callPackage, gobject-introspection, cmake, pkg-config
+, glib, libsndfile, zlib, bzip2, lzma, libsamplerate, intltool
+, pcre, util-linux, libselinux, libsepol }:
+
+let pkg = import ./base.nix {
+  version = "3.2.3";
+  pkgName = "libmirage";
+  pkgSha256 = "08mfvqyk3833ksfd47i4j3ppmrw5ry219km6h7lywdh9hm9x14yf";
+};
+in callPackage pkg {
+  buildInputs = [ glib libsndfile zlib bzip2 lzma libsamplerate intltool ];
+  drvParams = {
+    PKG_CONFIG_GOBJECT_INTROSPECTION_1_0_GIRDIR = "${placeholder "out"}/share/gir-1.0";
+    PKG_CONFIG_GOBJECT_INTROSPECTION_1_0_TYPELIBDIR = "${placeholder "out"}/lib/girepository-1.0";
+    nativeBuildInputs = [ cmake gobject-introspection pkg-config ];
+    propagatedBuildInputs = [ pcre util-linux libselinux libsepol ];
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/cdemu/vhba.nix b/nixpkgs/pkgs/misc/emulators/cdemu/vhba.nix
new file mode 100644
index 000000000000..182469310c41
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/cdemu/vhba.nix
@@ -0,0 +1,24 @@
+{ lib, stdenv, fetchurl, kernel }:
+
+stdenv.mkDerivation rec {
+  pname = "vhba";
+  version = "20190831";
+
+  src  = fetchurl {
+    url = "mirror://sourceforge/cdemu/vhba-module-${version}.tar.bz2";
+    sha256 = "1ybbk6l06n0y11n5wnfmvdz0baizmq55l458ywimghdyz0n7g0ws";
+  };
+
+  makeFlags = [ "KDIR=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build" "INSTALL_MOD_PATH=$(out)" ];
+  nativeBuildInputs = kernel.moduleBuildDependencies;
+
+  hardeningDisable = [ "pic" ];
+
+  meta = with lib; {
+    description = "Provides a Virtual (SCSI) HBA";
+    homepage = "http://cdemu.sourceforge.net/about/vhba/";
+    platforms = platforms.linux;
+    license = licenses.gpl2Plus;
+    maintainers = with lib.maintainers; [ bendlas ];
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/citra/default.nix b/nixpkgs/pkgs/misc/emulators/citra/default.nix
new file mode 100644
index 000000000000..d092a8786838
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/citra/default.nix
@@ -0,0 +1,31 @@
+{ stdenv, mkDerivation, lib, fetchgit, cmake, SDL2, qtbase, qtmultimedia, boost }:
+
+mkDerivation {
+  pname = "citra";
+  version = "2020-12-07";
+
+  # Submodules
+  src = fetchgit {
+    url = "https://github.com/citra-emu/citra";
+    rev = "3f13e1cc2419fac837952c44d7be9db78b054a2f";
+    sha256 = "1bbg8cwrgncmcavqpj3yp4dbfkip1i491krp6dcpgvsd5yfr7f0v";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ SDL2 qtbase qtmultimedia boost ];
+
+  preConfigure = ''
+    # Trick configure system.
+    sed -n 's,^ *path = \(.*\),\1,p' .gitmodules | while read path; do
+      mkdir "$path/.git"
+    done
+  '';
+
+  meta = with lib; {
+    homepage = "https://citra-emu.org";
+    description = "An open-source emulator for the Nintendo 3DS";
+    license = licenses.gpl2;
+    maintainers = with maintainers; [ abbradar ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/craftos-pc/default.nix b/nixpkgs/pkgs/misc/emulators/craftos-pc/default.nix
new file mode 100644
index 000000000000..3bc9e0b81cc0
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/craftos-pc/default.nix
@@ -0,0 +1,43 @@
+{ lib, stdenv, fetchFromGitHub, poco, openssl, SDL2, SDL2_mixer }:
+
+let
+  craftos2-lua = fetchFromGitHub {
+    owner = "MCJack123";
+    repo = "craftos2-lua";
+    rev = "v2.4.4";
+    sha256 = "1q63ki4sxx8bxaa6ag3xj153p7a8a12ivm0k33k935p41k6y2k64";
+  };
+in
+
+stdenv.mkDerivation rec {
+  pname = "craftos-pc";
+  version = "2.4.5";
+
+  src = fetchFromGitHub {
+    owner = "MCJack123";
+    repo = "craftos2";
+    rev = "v${version}";
+    sha256 = "00a4p365krbdprlv4979d13mm3alhxgzzj3vqz2g67795plf64j4";
+  };
+
+  buildInputs = [ poco openssl SDL2 SDL2_mixer ];
+
+  preBuild = ''
+    cp -R ${craftos2-lua}/* ./craftos2-lua/
+    chmod -R u+w ./craftos2-lua
+    make -C craftos2-lua linux
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin
+    DESTDIR=$out/bin make install
+  '';
+
+  meta = with lib; {
+    description = "An implementation of the CraftOS-PC API written in C++ using SDL";
+    homepage = "https://www.craftos-pc.cc";
+    license = licenses.mit;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.siraben ];
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/darcnes/default.nix b/nixpkgs/pkgs/misc/emulators/darcnes/default.nix
new file mode 100644
index 000000000000..7919e0a9009c
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/darcnes/default.nix
@@ -0,0 +1,24 @@
+{ lib, stdenv, fetchurl, libX11, libXt, libXext, libXaw }:
+
+stdenv.mkDerivation rec {
+  pname = "darcnes";
+  version = "9b0401";
+
+  src = fetchurl {
+    url = "https://web.archive.org/web/20130511081532/http://www.dridus.com/~nyef/darcnes/download/dn${version}.tgz";
+    sha256 = "05a7mh51rg7ydb414m3p5mm05p4nz2bgvspqzwm3bhbj7zz543k3";
+  };
+
+  patches = [ ./label.patch ];
+
+  buildInputs = [ libX11 libXt libXext libXaw ];
+  installPhase = "install -Dt $out/bin darcnes";
+
+  meta = {
+    homepage = "https://web.archive.org/web/20130502171725/http://www.dridus.com/~nyef/darcnes/";
+    description = "Sega Master System, Game Gear, SG-1000, NES, ColecoVision and Apple II emulator";
+    # Prohibited commercial use, credit required.
+    license = lib.licenses.free;
+    platforms = [ "i686-linux" ];
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/darcnes/label.patch b/nixpkgs/pkgs/misc/emulators/darcnes/label.patch
new file mode 100644
index 000000000000..612aa1e3911e
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/darcnes/label.patch
@@ -0,0 +1,13 @@
+http://gentoo-overlays.zugaina.org/funtoo/portage/games-emulation/darcnes/files/darcnes-0401-exec-stack.patch
+
+diff -Naur old/video_x.c new/video_x.c
+--- old/video_x.c	2004-09-04 01:26:41.102187277 +0200
++++ new/video_x.c	2004-09-04 01:27:51.586427427 +0200
+@@ -366,6 +366,7 @@
+ 	}
+ 	
+     default:
++    	break;
+     }
+ }
+ 
diff --git a/nixpkgs/pkgs/misc/emulators/desmume/01_use_system_tinyxml.patch b/nixpkgs/pkgs/misc/emulators/desmume/01_use_system_tinyxml.patch
new file mode 100644
index 000000000000..8cec26026e7f
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/desmume/01_use_system_tinyxml.patch
@@ -0,0 +1,231 @@
+From: Evgeni Golov <evgeni@debian.org>
+Subject: use the system tinyxml instead of the embedded copy
+Last-Update: 2015-08-09
+
+diff --git a/src/Makefile.am b/src/Makefile.am
+index 7b9e263..bc7ba8c 100644
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -81,12 +81,6 @@ libdesmume_a_SOURCES = \
+ 	utils/libfat/mem_allocate.h \
+ 	utils/libfat/partition.cpp \
+ 	utils/libfat/partition.h \
+-	utils/tinyxml/tinystr.cpp \
+-	utils/tinyxml/tinystr.h \
+-	utils/tinyxml/tinyxml.cpp \
+-	utils/tinyxml/tinyxml.h \
+-	utils/tinyxml/tinyxmlerror.cpp \
+-	utils/tinyxml/tinyxmlparser.cpp \
+ 	utils/glcorearb.h \
+ 	addons/slot2_auto.cpp addons/slot2_mpcf.cpp addons/slot2_paddle.cpp addons/slot2_gbagame.cpp addons/slot2_none.cpp addons/slot2_rumblepak.cpp addons/slot2_guitarGrip.cpp addons/slot2_expMemory.cpp addons/slot2_piano.cpp addons/slot2_passme.cpp addons/slot1_none.cpp addons/slot1_r4.cpp addons/slot1_retail_nand.cpp addons/slot1_retail_auto.cpp addons/slot1_retail_mcrom.cpp addons/slot1_retail_mcrom_debug.cpp addons/slot1comp_mc.cpp addons/slot1comp_mc.h addons/slot1comp_rom.h addons/slot1comp_rom.cpp addons/slot1comp_protocol.h addons/slot1comp_protocol.cpp \
+ 	cheatSystem.cpp cheatSystem.h \
+@@ -204,3 +198,4 @@ if HAVE_GDB_STUB
+ libdesmume_a_SOURCES += gdbstub.h
+ endif
+ libdesmume_a_LIBADD = fs-$(desmume_arch).$(OBJEXT)
++LIBS += -ltinyxml
+diff --git a/src/Makefile.in b/src/Makefile.in
+index 9cf26a3..d9ff7b2 100644
+--- a/src/Makefile.in
++++ b/src/Makefile.in
+@@ -184,9 +184,6 @@ am__libdesmume_a_SOURCES_DIST = armcpu.cpp armcpu.h \
+ 	utils/libfat/libfat_public_api.h utils/libfat/lock.cpp \
+ 	utils/libfat/lock.h utils/libfat/mem_allocate.h \
+ 	utils/libfat/partition.cpp utils/libfat/partition.h \
+-	utils/tinyxml/tinystr.cpp utils/tinyxml/tinystr.h \
+-	utils/tinyxml/tinyxml.cpp utils/tinyxml/tinyxml.h \
+-	utils/tinyxml/tinyxmlerror.cpp utils/tinyxml/tinyxmlparser.cpp \
+ 	utils/glcorearb.h addons/slot2_auto.cpp addons/slot2_mpcf.cpp \
+ 	addons/slot2_paddle.cpp addons/slot2_gbagame.cpp \
+ 	addons/slot2_none.cpp addons/slot2_rumblepak.cpp \
+@@ -324,10 +321,6 @@ am_libdesmume_a_OBJECTS = armcpu.$(OBJEXT) arm_instructions.$(OBJEXT) \
+ 	utils/libfat/libfat.$(OBJEXT) \
+ 	utils/libfat/libfat_public_api.$(OBJEXT) \
+ 	utils/libfat/lock.$(OBJEXT) utils/libfat/partition.$(OBJEXT) \
+-	utils/tinyxml/tinystr.$(OBJEXT) \
+-	utils/tinyxml/tinyxml.$(OBJEXT) \
+-	utils/tinyxml/tinyxmlerror.$(OBJEXT) \
+-	utils/tinyxml/tinyxmlparser.$(OBJEXT) \
+ 	addons/slot2_auto.$(OBJEXT) addons/slot2_mpcf.$(OBJEXT) \
+ 	addons/slot2_paddle.$(OBJEXT) addons/slot2_gbagame.$(OBJEXT) \
+ 	addons/slot2_none.$(OBJEXT) addons/slot2_rumblepak.$(OBJEXT) \
+@@ -475,7 +468,7 @@ LIBAGG_LIBS = @LIBAGG_LIBS@
+ LIBGLADE_CFLAGS = @LIBGLADE_CFLAGS@
+ LIBGLADE_LIBS = @LIBGLADE_LIBS@
+ LIBOBJS = @LIBOBJS@
+-LIBS = @LIBS@
++LIBS = @LIBS@ -ltinyxml
+ LIBSOUNDTOUCH_CFLAGS = @LIBSOUNDTOUCH_CFLAGS@
+ LIBSOUNDTOUCH_LIBS = @LIBSOUNDTOUCH_LIBS@
+ LTLIBOBJS = @LTLIBOBJS@
+@@ -625,9 +618,6 @@ libdesmume_a_SOURCES = armcpu.cpp armcpu.h arm_instructions.cpp \
+ 	utils/libfat/libfat_public_api.h utils/libfat/lock.cpp \
+ 	utils/libfat/lock.h utils/libfat/mem_allocate.h \
+ 	utils/libfat/partition.cpp utils/libfat/partition.h \
+-	utils/tinyxml/tinystr.cpp utils/tinyxml/tinystr.h \
+-	utils/tinyxml/tinyxml.cpp utils/tinyxml/tinyxml.h \
+-	utils/tinyxml/tinyxmlerror.cpp utils/tinyxml/tinyxmlparser.cpp \
+ 	utils/glcorearb.h addons/slot2_auto.cpp addons/slot2_mpcf.cpp \
+ 	addons/slot2_paddle.cpp addons/slot2_gbagame.cpp \
+ 	addons/slot2_none.cpp addons/slot2_rumblepak.cpp \
+@@ -760,20 +750,6 @@ utils/libfat/lock.$(OBJEXT): utils/libfat/$(am__dirstamp) \
+ 	utils/libfat/$(DEPDIR)/$(am__dirstamp)
+ utils/libfat/partition.$(OBJEXT): utils/libfat/$(am__dirstamp) \
+ 	utils/libfat/$(DEPDIR)/$(am__dirstamp)
+-utils/tinyxml/$(am__dirstamp):
+-	@$(MKDIR_P) utils/tinyxml
+-	@: > utils/tinyxml/$(am__dirstamp)
+-utils/tinyxml/$(DEPDIR)/$(am__dirstamp):
+-	@$(MKDIR_P) utils/tinyxml/$(DEPDIR)
+-	@: > utils/tinyxml/$(DEPDIR)/$(am__dirstamp)
+-utils/tinyxml/tinystr.$(OBJEXT): utils/tinyxml/$(am__dirstamp) \
+-	utils/tinyxml/$(DEPDIR)/$(am__dirstamp)
+-utils/tinyxml/tinyxml.$(OBJEXT): utils/tinyxml/$(am__dirstamp) \
+-	utils/tinyxml/$(DEPDIR)/$(am__dirstamp)
+-utils/tinyxml/tinyxmlerror.$(OBJEXT): utils/tinyxml/$(am__dirstamp) \
+-	utils/tinyxml/$(DEPDIR)/$(am__dirstamp)
+-utils/tinyxml/tinyxmlparser.$(OBJEXT): utils/tinyxml/$(am__dirstamp) \
+-	utils/tinyxml/$(DEPDIR)/$(am__dirstamp)
+ addons/$(am__dirstamp):
+ 	@$(MKDIR_P) addons
+ 	@: > addons/$(am__dirstamp)
+@@ -1035,10 +1011,6 @@ mostlyclean-compile:
+ 	-rm -f utils/libfat/partition.$(OBJEXT)
+ 	-rm -f utils/md5.$(OBJEXT)
+ 	-rm -f utils/task.$(OBJEXT)
+-	-rm -f utils/tinyxml/tinystr.$(OBJEXT)
+-	-rm -f utils/tinyxml/tinyxml.$(OBJEXT)
+-	-rm -f utils/tinyxml/tinyxmlerror.$(OBJEXT)
+-	-rm -f utils/tinyxml/tinyxmlparser.$(OBJEXT)
+ 	-rm -f utils/vfat.$(OBJEXT)
+ 	-rm -f utils/xstring.$(OBJEXT)
+ 
+@@ -1175,10 +1147,6 @@ distclean-compile:
+ @AMDEP_TRUE@@am__include@ @am__quote@utils/libfat/$(DEPDIR)/libfat_public_api.Po@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@utils/libfat/$(DEPDIR)/lock.Po@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@utils/libfat/$(DEPDIR)/partition.Po@am__quote@
+-@AMDEP_TRUE@@am__include@ @am__quote@utils/tinyxml/$(DEPDIR)/tinystr.Po@am__quote@
+-@AMDEP_TRUE@@am__include@ @am__quote@utils/tinyxml/$(DEPDIR)/tinyxml.Po@am__quote@
+-@AMDEP_TRUE@@am__include@ @am__quote@utils/tinyxml/$(DEPDIR)/tinyxmlerror.Po@am__quote@
+-@AMDEP_TRUE@@am__include@ @am__quote@utils/tinyxml/$(DEPDIR)/tinyxmlparser.Po@am__quote@
+ 
+ .c.o:
+ @am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
+@@ -1449,8 +1417,6 @@ distclean-generic:
+ 	-rm -f utils/decrypt/$(am__dirstamp)
+ 	-rm -f utils/libfat/$(DEPDIR)/$(am__dirstamp)
+ 	-rm -f utils/libfat/$(am__dirstamp)
+-	-rm -f utils/tinyxml/$(DEPDIR)/$(am__dirstamp)
+-	-rm -f utils/tinyxml/$(am__dirstamp)
+ 
+ maintainer-clean-generic:
+ 	@echo "This command is intended for maintainers to use"
+@@ -1460,7 +1426,7 @@ clean: clean-recursive
+ clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am
+ 
+ distclean: distclean-recursive
+-	-rm -rf ./$(DEPDIR) addons/$(DEPDIR) filter/$(DEPDIR) metaspu/$(DEPDIR) utils/$(DEPDIR) utils/AsmJit/core/$(DEPDIR) utils/AsmJit/x86/$(DEPDIR) utils/decrypt/$(DEPDIR) utils/libfat/$(DEPDIR) utils/tinyxml/$(DEPDIR)
++	-rm -rf ./$(DEPDIR) addons/$(DEPDIR) filter/$(DEPDIR) metaspu/$(DEPDIR) utils/$(DEPDIR) utils/AsmJit/core/$(DEPDIR) utils/AsmJit/x86/$(DEPDIR) utils/decrypt/$(DEPDIR) utils/libfat/$(DEPDIR)
+ 	-rm -f Makefile
+ distclean-am: clean-am distclean-compile distclean-generic \
+ 	distclean-tags
+@@ -1506,7 +1472,7 @@ install-ps-am:
+ installcheck-am:
+ 
+ maintainer-clean: maintainer-clean-recursive
+-	-rm -rf ./$(DEPDIR) addons/$(DEPDIR) filter/$(DEPDIR) metaspu/$(DEPDIR) utils/$(DEPDIR) utils/AsmJit/core/$(DEPDIR) utils/AsmJit/x86/$(DEPDIR) utils/decrypt/$(DEPDIR) utils/libfat/$(DEPDIR) utils/tinyxml/$(DEPDIR)
++	-rm -rf ./$(DEPDIR) addons/$(DEPDIR) filter/$(DEPDIR) metaspu/$(DEPDIR) utils/$(DEPDIR) utils/AsmJit/core/$(DEPDIR) utils/AsmJit/x86/$(DEPDIR) utils/decrypt/$(DEPDIR) utils/libfat/$(DEPDIR)
+ 	-rm -f Makefile
+ maintainer-clean-am: distclean-am maintainer-clean-generic
+ 
+diff --git a/src/cli/Makefile.am b/src/cli/Makefile.am
+index 1985209..d958323 100755
+--- a/src/cli/Makefile.am
++++ b/src/cli/Makefile.am
+@@ -5,7 +5,7 @@ AM_CPPFLAGS += $(SDL_CFLAGS) $(ALSA_CFLAGS) $(LIBAGG_CFLAGS) $(GLIB_CFLAGS) $(GT
+ 
+ bin_PROGRAMS = desmume-cli
+ desmume_cli_SOURCES = main.cpp ../sndsdl.cpp ../ctrlssdl.h ../ctrlssdl.cpp ../driver.h ../driver.cpp
+-desmume_cli_LDADD = ../libdesmume.a $(SDL_LIBS) $(ALSA_LIBS) $(LIBAGG_LIBS) $(GLIB_LIBS) $(GTHREAD_LIBS) $(LIBSOUNDTOUCH_LIBS)
++desmume_cli_LDADD = ../libdesmume.a $(SDL_LIBS) $(ALSA_LIBS) $(LIBAGG_LIBS) $(GLIB_LIBS) $(GTHREAD_LIBS) $(LIBSOUNDTOUCH_LIBS) -ltinyxml
+ if HAVE_GDB_STUB
+ desmume_cli_LDADD += ../gdbstub/libgdbstub.a
+ endif
+diff --git a/src/cli/Makefile.in b/src/cli/Makefile.in
+index 14efd77..f04ab7d 100644
+--- a/src/cli/Makefile.in
++++ b/src/cli/Makefile.in
+@@ -311,7 +311,7 @@ AM_LDFLAGS =
+ desmume_cli_SOURCES = main.cpp ../sndsdl.cpp ../ctrlssdl.h ../ctrlssdl.cpp ../driver.h ../driver.cpp
+ desmume_cli_LDADD = ../libdesmume.a $(SDL_LIBS) $(ALSA_LIBS) \
+ 	$(LIBAGG_LIBS) $(GLIB_LIBS) $(GTHREAD_LIBS) \
+-	$(LIBSOUNDTOUCH_LIBS) $(am__append_1)
++	$(LIBSOUNDTOUCH_LIBS) -ltinyxml $(am__append_1)
+ all: all-recursive
+ 
+ .SUFFIXES:
+diff --git a/src/gtk-glade/Makefile.am b/src/gtk-glade/Makefile.am
+index b667fca..c79fdac 100755
+--- a/src/gtk-glade/Makefile.am
++++ b/src/gtk-glade/Makefile.am
+@@ -33,7 +33,7 @@ desmume_glade_SOURCES =  \
+ desmume_glade_LDADD = ../libdesmume.a \
+ 			$(SDL_LIBS) $(GTKGLEXT_LIBS) $(LIBGLADE_LIBS) \
+ 			$(GTHREAD_LIBS) $(ALSA_LIBS) $(LIBAGG_LIBS) \
+-			$(LIBSOUNDTOUCH_LIBS)
++			$(LIBSOUNDTOUCH_LIBS) -ltinyxml
+ if HAVE_GDB_STUB
+ desmume_glade_LDADD += ../gdbstub/libgdbstub.a
+ endif
+diff --git a/src/gtk-glade/Makefile.in b/src/gtk-glade/Makefile.in
+index 5f77ec5..012aa72 100644
+--- a/src/gtk-glade/Makefile.in
++++ b/src/gtk-glade/Makefile.in
+@@ -367,7 +367,7 @@ desmume_glade_SOURCES = \
+ 
+ desmume_glade_LDADD = ../libdesmume.a $(SDL_LIBS) $(GTKGLEXT_LIBS) \
+ 	$(LIBGLADE_LIBS) $(GTHREAD_LIBS) $(ALSA_LIBS) $(LIBAGG_LIBS) \
+-	$(LIBSOUNDTOUCH_LIBS) $(am__append_1)
++	$(LIBSOUNDTOUCH_LIBS) -ltinyxml $(am__append_1)
+ all: all-recursive
+ 
+ .SUFFIXES:
+diff --git a/src/gtk/Makefile.am b/src/gtk/Makefile.am
+index 59cb1f2..e451102 100755
+--- a/src/gtk/Makefile.am
++++ b/src/gtk/Makefile.am
+@@ -32,7 +32,7 @@ desmume_SOURCES = \
+ 	../filter/videofilter.cpp ../filter/videofilter.h \
+ 	main.cpp main.h
+ desmume_LDADD = ../libdesmume.a \
+-	$(SDL_LIBS) $(GTK_LIBS) $(GTHREAD_LIBS) $(ALSA_LIBS) $(LIBAGG_LIBS) $(LIBSOUNDTOUCH_LIBS)
++	$(SDL_LIBS) $(GTK_LIBS) $(GTHREAD_LIBS) $(ALSA_LIBS) $(LIBAGG_LIBS) $(LIBSOUNDTOUCH_LIBS) -ltinyxml
+ if HAVE_GDB_STUB
+ desmume_LDADD += ../gdbstub/libgdbstub.a
+ endif
+diff --git a/src/gtk/Makefile.in b/src/gtk/Makefile.in
+index e1a2c37..75f392f 100644
+--- a/src/gtk/Makefile.in
++++ b/src/gtk/Makefile.in
+@@ -382,7 +382,7 @@ desmume_SOURCES = \
+ 
+ desmume_LDADD = ../libdesmume.a $(SDL_LIBS) $(GTK_LIBS) \
+ 	$(GTHREAD_LIBS) $(ALSA_LIBS) $(LIBAGG_LIBS) \
+-	$(LIBSOUNDTOUCH_LIBS) $(am__append_1) $(am__append_2) \
++	$(LIBSOUNDTOUCH_LIBS) -ltinyxml $(am__append_1) $(am__append_2) \
+ 	$(am__append_3)
+ UPDATE_DESKTOP = \
+   appsdir=$(DESTDIR)$(datadir)/applications ; \
+diff --git a/src/utils/advanscene.cpp b/src/utils/advanscene.cpp
+index 8d8f370..09c35bb 100755
+--- a/src/utils/advanscene.cpp
++++ b/src/utils/advanscene.cpp
+@@ -19,7 +19,7 @@
+ #include <time.h>

+ 

+ #define TIXML_USE_STL

+-#include "tinyxml/tinyxml.h"

++#include <tinyxml.h>

+ 

+ #include "advanscene.h"

+ #include "../common.h"

diff --git a/nixpkgs/pkgs/misc/emulators/desmume/default.nix b/nixpkgs/pkgs/misc/emulators/desmume/default.nix
new file mode 100644
index 000000000000..ff17833f690b
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/desmume/default.nix
@@ -0,0 +1,57 @@
+{ lib, stdenv, fetchurl, fetchpatch
+, pkg-config, libtool, intltool
+, libXmu
+, lua
+, tinyxml
+, agg, alsaLib, soundtouch, openal
+, desktop-file-utils
+, gtk2, gtkglext, libglade
+, libGLU, libpcap, SDL, zziplib }:
+
+with lib;
+stdenv.mkDerivation rec {
+
+  pname = "desmume";
+  version = "0.9.11";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/project/desmume/desmume/${version}/${pname}-${version}.tar.gz";
+    sha256 = "15l8wdw3q61fniy3h93d84dnm6s4pyadvh95a0j6d580rjk4pcrs";
+  };
+
+  patches = [
+    ./gcc6_fixes.patch
+    ./gcc7_fixes.patch
+    ./01_use_system_tinyxml.patch
+  ];
+
+  CXXFLAGS = "-fpermissive";
+
+  buildInputs =
+  [ pkg-config libtool intltool libXmu lua agg alsaLib soundtouch
+    openal desktop-file-utils gtk2 gtkglext libglade
+    libGLU libpcap SDL zziplib tinyxml ];
+
+  configureFlags = [
+    "--disable-glade"  # Failing on compile step
+    "--enable-openal"
+    "--enable-glx"
+    "--enable-hud"
+    "--enable-wifi" ];
+
+  meta = {
+    description = "An open-source Nintendo DS emulator";
+    longDescription = ''
+      DeSmuME is a freeware emulator for the NDS roms & Nintendo DS
+      Lite games created by YopYop156. It supports many homebrew nds
+      rom demoes as well as a handful of Wireless Multiboot demo nds
+      roms. DeSmuME is also able to emulate nearly all of the
+      commercial nds rom titles which other DS Emulators aren't.
+    '';
+    homepage = "http://www.desmume.com";
+    license = licenses.gpl1Plus;
+    maintainers = [ maintainers.AndersonTorres ];
+    platforms = platforms.linux;
+  };
+}
+# TODO: investigate glade
diff --git a/nixpkgs/pkgs/misc/emulators/desmume/gcc6_fixes.patch b/nixpkgs/pkgs/misc/emulators/desmume/gcc6_fixes.patch
new file mode 100644
index 000000000000..6eb9576f649b
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/desmume/gcc6_fixes.patch
@@ -0,0 +1,59 @@
+From: zeromus
+Origin: upstream, https://sourceforge.net/p/desmume/code/5514, https://sourceforge.net/p/desmume/code/5517, https://sourceforge.net/p/desmume/code/5430
+Subject: fix GCC6 issues
+Bug: https://sourceforge.net/p/desmume/bugs/1570/
+Bug-Debian: http://bugs.debian.org/811691
+
+Index: desmume/src/MMU_timing.h
+===================================================================
+--- desmume/src/MMU_timing.h	(revision 5513)
++++ desmume/src/MMU_timing.h	(revision 5517)
+@@ -155,8 +155,8 @@
+ 	enum { ASSOCIATIVITY = 1 << ASSOCIATIVESHIFT };

+ 	enum { BLOCKSIZE = 1 << BLOCKSIZESHIFT };

+ 	enum { TAGSHIFT = SIZESHIFT - ASSOCIATIVESHIFT };

+-	enum { TAGMASK = (u32)(~0 << TAGSHIFT) };

+-	enum { BLOCKMASK = ((u32)~0 >> (32 - TAGSHIFT)) & (u32)(~0 << BLOCKSIZESHIFT) };

++	enum { TAGMASK = (u32)(~0U << TAGSHIFT) };

++	enum { BLOCKMASK = ((u32)~0U >> (32 - TAGSHIFT)) & (u32)(~0U << BLOCKSIZESHIFT) };

+ 	enum { WORDSIZE = sizeof(u32) };

+ 	enum { WORDSPERBLOCK = (1 << BLOCKSIZESHIFT) / WORDSIZE };

+ 	enum { DATAPERWORD = WORDSIZE * ASSOCIATIVITY };

+Index: desmume/src/ctrlssdl.cpp
+===================================================================
+--- desmume/src/ctrlssdl.cpp	(revision 5513)
++++ desmume/src/ctrlssdl.cpp	(revision 5517)
+@@ -200,7 +200,7 @@
+           break;
+         case SDL_JOYAXISMOTION:
+           /* Dead zone of 50% */
+-          if( (abs(event.jaxis.value) >> 14) != 0 )
++          if( ((u32)abs(event.jaxis.value) >> 14) != 0 )
+             {
+               key = ((event.jaxis.which & 15) << 12) | JOY_AXIS << 8 | ((event.jaxis.axis & 127) << 1);
+               if (event.jaxis.value > 0) {
+@@ -370,7 +370,7 @@
+          Note: button constants have a 1bit offset. */
+     case SDL_JOYAXISMOTION:
+       key_code = ((event->jaxis.which & 15) << 12) | JOY_AXIS << 8 | ((event->jaxis.axis & 127) << 1);
+-      if( (abs(event->jaxis.value) >> 14) != 0 )
++      if( ((u32)abs(event->jaxis.value) >> 14) != 0 )
+         {
+           if (event->jaxis.value > 0)
+             key_code |= 1;
+Index: desmume/src/wifi.cpp
+===================================================================
+--- desmume/src/wifi.cpp	(revision 5429)
++++ desmume/src/wifi.cpp	(revision 5430)
+@@ -320,9 +320,9 @@
+ 
+ #if (WIFI_LOGGING_LEVEL >= 1)
+ 	#if WIFI_LOG_USE_LOGC
+-		#define WIFI_LOG(level, ...) if(level <= WIFI_LOGGING_LEVEL) LOGC(8, "WIFI: "__VA_ARGS__);
++		#define WIFI_LOG(level, ...) if(level <= WIFI_LOGGING_LEVEL) LOGC(8, "WIFI: " __VA_ARGS__);
+ 	#else
+-		#define WIFI_LOG(level, ...) if(level <= WIFI_LOGGING_LEVEL) printf("WIFI: "__VA_ARGS__);
++		#define WIFI_LOG(level, ...) if(level <= WIFI_LOGGING_LEVEL) printf("WIFI: " __VA_ARGS__);
+ 	#endif
+ #else
+ #define WIFI_LOG(level, ...) {}
diff --git a/nixpkgs/pkgs/misc/emulators/desmume/gcc7_fixes.patch b/nixpkgs/pkgs/misc/emulators/desmume/gcc7_fixes.patch
new file mode 100644
index 000000000000..a4934ff6e611
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/desmume/gcc7_fixes.patch
@@ -0,0 +1,18 @@
+From e1f7039f1b06add4fb75b2f8774000b8f05574af Mon Sep 17 00:00:00 2001
+From: rogerman <rogerman@users.sf.net>
+Date: Mon, 17 Aug 2015 21:15:04 +0000
+Subject: Fix bug with libfat string handling.
+
+diff --git a/src/utils/libfat/directory.cpp b/src/utils/libfat/directory.cpp
+index 765d7ae5..b6d7f01f 100644
+--- a/src/utils/libfat/directory.cpp
++++ b/src/utils/libfat/directory.cpp
+@@ -139,7 +139,7 @@ static size_t _FAT_directory_mbstoucs2 (ucs2_t* dst, const char* src, size_t len
+ 	int bytes;
+ 	size_t count = 0;
+ 
+-	while (count < len-1 && src != '\0') {
++	while (count < len-1 && *src != '\0') {
+ 		bytes = mbrtowc (&tempChar, src, MB_CUR_MAX, &ps);
+ 		if (bytes > 0) {
+ 			*dst = (ucs2_t)tempChar;
diff --git a/nixpkgs/pkgs/misc/emulators/dgen-sdl/default.nix b/nixpkgs/pkgs/misc/emulators/dgen-sdl/default.nix
new file mode 100644
index 000000000000..4a76ee0df026
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/dgen-sdl/default.nix
@@ -0,0 +1,70 @@
+{ lib, stdenv
+, fetchurl
+, libarchive
+, doxygen
+, SDL
+}:
+
+let
+  pname = "dgen-sdl";
+  version = "1.33";
+in stdenv.mkDerivation {
+  inherit pname version;
+
+  src = fetchurl {
+    url = "https://sourceforge.net/projects/dgen/files/dgen/${version}/${pname}-${version}.tar.gz";
+    hash = "sha256-meLAYBfCKHPHf4gYbrzAmGckTrbgQsdjuwlLArje9h4=";
+  };
+
+  buildInputs = [ SDL libarchive ];
+
+  configureFlags = [
+    "--enable-joystick"
+    "--enable-debugger"
+    "--enable-debug-vdp"
+    "--enable-pico" # experimental
+    "--enable-vgmdump"
+    "--with-star=no" # Needs ASM support
+    "--with-musa"
+    "--with-cyclone=no" # Needs ASM support
+    "--with-mz80"
+    "--with-cz80"
+    "--with-drz80=no" # Needs ASM support
+    "--with-dz80"
+  ];
+
+  meta = with lib; {
+    homepage = "https://dgen.sourceforge.net/";
+    description = "Sega Genesis/Mega Drive emulator";
+    longDescription = ''
+      DGen/SDL is a free, open source emulator for Sega Genesis/Mega Drive
+      systems. DGen was originally written by Dave, then ported to SDL by Joe
+      Groff and Phil K. Hornung in 1998.
+
+      It features:
+
+      - Game Genie/Hex codes support
+      - PAL/NTSC, fullscreen modes
+      - Joypad/joystick support
+      - Mouse support
+      - Highly configurable controls
+      - OpenGL textured video output
+      - Portable (64‐bit, endian safe), runs in Windows using MinGW
+      - Screenshots, demos recording and playback
+      - Musashi (generic) and StarScream (x86‐only) CPU cores
+      - Cyclone 68000 and DrZ80 (both ARM‐only) CPU cores
+      - CZ80 (generic) and MZ80 (generic and x86‐only versions)
+      - 16‐bit, 8000 to 48000Hz sound output
+      - Support for 8, 15, 16, 24 and 32 bpp modes
+      - Archived/compressed ROMs support
+      - M68K debugger (contributed by Edd Barrett)
+      - Z80 debugger
+      - hqx and scale2x upscaling filters
+      - VGM dumping
+    '';
+    license = licenses.mit;
+    maintainers = with maintainers; [ AndersonTorres ];
+    platforms = with platforms; unix;
+  };
+}
+# TODO: implement configure options
diff --git a/nixpkgs/pkgs/misc/emulators/dlx/default.nix b/nixpkgs/pkgs/misc/emulators/dlx/default.nix
new file mode 100644
index 000000000000..3360d45ccc83
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/dlx/default.nix
@@ -0,0 +1,31 @@
+{ lib, stdenv, fetchurl, unzip }:
+
+stdenv.mkDerivation {
+  name = "dlx-2012.07.08";
+
+  src = fetchurl {
+    url = "https://www.davidviner.com/zip/dlx/dlx.zip";
+    sha256 = "0q5hildq2xcig7yrqi26n7fqlanyssjirm7swy2a9icfxpppfpkn";
+  };
+
+  buildInputs = [ unzip ];
+
+  makeFlags = [ "LINK=gcc" "CFLAGS=-O2" ];
+
+  hardeningDisable = [ "format" ];
+
+  installPhase = ''
+    mkdir -p $out/include/dlx $out/share/dlx/{examples,doc} $out/bin
+    mv -v masm mon dasm $out/bin/
+    mv -v *.i auto.a $out/include/dlx/
+    mv -v *.a *.m $out/share/dlx/examples/
+    mv -v README.txt MANUAL.TXT $out/share/dlx/doc/
+  '';
+
+  meta = {
+    homepage = "http://www.davidviner.com/dlx.php";
+    description = "DLX Simulator";
+    license = lib.licenses.gpl2;
+    platforms = lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/dolphin-emu/default.nix b/nixpkgs/pkgs/misc/emulators/dolphin-emu/default.nix
new file mode 100644
index 000000000000..9112293db58a
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/dolphin-emu/default.nix
@@ -0,0 +1,122 @@
+{ stdenv
+, lib
+, fetchpatch
+, pkg-config
+, cmake
+, bluez
+, ffmpeg_3
+, libao
+, gtk2
+, glib
+, libGLU
+, libGL
+, gettext
+, libpthreadstubs
+, libXrandr
+, libXext
+, readline
+, openal
+, libXdmcp
+, portaudio
+, fetchFromGitHub
+, libusb1
+, libevdev
+, wxGTK30
+, soundtouch
+, miniupnpc
+, mbedtls
+, curl
+, lzo
+, sfml
+, libpulseaudio ? null
+}:
+
+stdenv.mkDerivation rec {
+  pname = "dolphin-emu";
+  version = "5.0";
+
+  src = fetchFromGitHub {
+    owner = "dolphin-emu";
+    repo = "dolphin";
+    rev = version;
+    sha256 = "07mlfnh0hwvk6xarcg315x7z2j0qbg9g7cm040df9c8psiahc3g6";
+  };
+
+  patches = [
+    # Fix build with soundtouch 2.1.2
+    (fetchpatch {
+      url = "https://src.fedoraproject.org/rpms/dolphin-emu/raw/a1b91fdf94981e12c8889a02cba0ec2267d0f303/f/dolphin-emu-5.0-soundtouch-exception-fix.patch";
+      name = "dolphin-emu-5.0-soundtouch-exception-fix.patch";
+      sha256 = "0yd3l46nja5qiknnl30ryad98f3v8911jwnr67hn61dzx2kwbbaw";
+    })
+    # Fix build with gcc 8
+    (fetchpatch {
+      url = "https://salsa.debian.org/games-team/dolphin-emu/raw/9b7b4aeac1b60dcf28bdcafbed6bc498b2aeb0ad/debian/patches/03_gcc8.patch";
+      name = "03_gcc8.patch";
+      sha256 = "1da95gb8c95kd5cjhdvg19cv2z863lj3va5gx3bqc7g8r36glqxr";
+    })
+  ];
+
+  postPatch = ''
+    substituteInPlace Source/Core/VideoBackends/OGL/RasterFont.cpp \
+      --replace " CHAR_WIDTH " " CHARWIDTH "
+  '';
+
+  cmakeFlags = [
+    "-DGTK2_GLIBCONFIG_INCLUDE_DIR=${glib.out}/lib/glib-2.0/include"
+    "-DGTK2_GDKCONFIG_INCLUDE_DIR=${gtk2.out}/lib/gtk-2.0/include"
+    "-DGTK2_INCLUDE_DIRS=${gtk2.dev}/include/gtk-2.0"
+    "-DENABLE_LTO=True"
+  ];
+
+  nativeBuildInputs = [
+    pkg-config
+    cmake
+  ];
+
+  buildInputs = [
+    bluez
+    ffmpeg_3
+    libao
+    libGLU
+    libGL
+    gtk2
+    glib
+    gettext
+    libpthreadstubs
+    libXrandr
+    libXext
+    readline
+    openal
+    libevdev
+    libXdmcp
+    portaudio
+    libpulseaudio
+    libevdev
+    libXdmcp
+    portaudio
+    libusb1
+    libpulseaudio
+    wxGTK30
+    soundtouch
+    miniupnpc
+    mbedtls
+    curl
+    lzo
+    sfml
+  ];
+
+  postInstall = lib.optionalString stdenv.hostPlatform.isLinux ''
+    install -D $src/Data/51-usb-device.rules $out/etc/udev/rules.d/51-usb-device.rules
+  '';
+
+  meta = with lib; {
+    homepage = "https://dolphin-emu.org/";
+    description = "Gamecube/Wii/Triforce emulator for x86_64 and ARMv8";
+    license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ MP2E ashkitten ];
+    # x86_32 is an unsupported platform.
+    # Enable generic build if you really want a JIT-less binary.
+    platforms = [ "x86_64-linux" ];
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/dolphin-emu/master.nix b/nixpkgs/pkgs/misc/emulators/dolphin-emu/master.nix
new file mode 100644
index 000000000000..4a1fca0e7c5c
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/dolphin-emu/master.nix
@@ -0,0 +1,88 @@
+{ lib, stdenv, fetchFromGitHub, makeDesktopItem, pkg-config, cmake
+, wrapQtAppsHook, qtbase, bluez, ffmpeg_3, libao, libGLU, libGL, pcre, gettext
+, libXrandr, libusb1, lzo, libpthreadstubs, libXext, libXxf86vm, libXinerama
+, libSM, libXdmcp, readline, openal, udev, libevdev, portaudio, curl, alsaLib
+, miniupnpc, enet, mbedtls, soundtouch, sfml
+, vulkan-loader ? null, libpulseaudio ? null
+
+# - Inputs used for Darwin
+, CoreBluetooth, ForceFeedback, IOKit, OpenGL, libpng, hidapi }:
+
+let
+  desktopItem = makeDesktopItem {
+    name = "dolphin-emu-master";
+    exec = "dolphin-emu-master";
+    icon = "dolphin-emu";
+    comment = "A Wii/GameCube Emulator";
+    desktopName = "Dolphin Emulator (master)";
+    genericName = "Wii/GameCube Emulator";
+    categories = "Game;Emulator;";
+    startupNotify = "false";
+  };
+in stdenv.mkDerivation rec {
+  pname = "dolphin-emu";
+  version = "5.0-13178";
+
+  src = fetchFromGitHub {
+    owner = "dolphin-emu";
+    repo = "dolphin";
+    rev = "a34823df61df65168aa40ef5e82e44defd4a0138";
+    sha256 = "0j6hnj60iai366kl0kdbn1jkwc183l02g65mp2vq4qb2yd4399l1";
+  };
+
+  nativeBuildInputs = [ cmake pkg-config ]
+  ++ lib.optional stdenv.isLinux wrapQtAppsHook;
+
+  buildInputs = [
+    curl ffmpeg_3 libao libGLU libGL pcre gettext libpthreadstubs libpulseaudio
+    libXrandr libXext libXxf86vm libXinerama libSM readline openal libXdmcp lzo
+    portaudio libusb1 libpng hidapi miniupnpc enet mbedtls soundtouch sfml
+    qtbase
+  ] ++ lib.optionals stdenv.isLinux [
+    bluez udev libevdev alsaLib vulkan-loader
+  ] ++ lib.optionals stdenv.isDarwin [
+    CoreBluetooth OpenGL ForceFeedback IOKit
+  ];
+
+  cmakeFlags = [
+    "-DUSE_SHARED_ENET=ON"
+    "-DENABLE_LTO=ON"
+    "-DDOLPHIN_WC_REVISION=${src.rev}"
+    "-DDOLPHIN_WC_DESCRIBE=${version}"
+    "-DDOLPHIN_WC_BRANCH=master"
+  ] ++ lib.optionals stdenv.isDarwin [
+    "-DOSX_USE_DEFAULT_SEARCH_PATH=True"
+  ];
+
+  qtWrapperArgs = lib.optionals stdenv.isLinux [
+    "--prefix LD_LIBRARY_PATH : ${vulkan-loader}/lib"
+  ];
+
+  # - Allow Dolphin to use nix-provided libraries instead of building them
+  postPatch = ''
+    sed -i -e 's,DISTRIBUTOR "None",DISTRIBUTOR "NixOS",g' CMakeLists.txt
+  '' + lib.optionalString stdenv.isDarwin ''
+    sed -i -e 's,if(NOT APPLE),if(true),g' CMakeLists.txt
+    sed -i -e 's,if(LIBUSB_FOUND AND NOT APPLE),if(LIBUSB_FOUND),g' \
+      CMakeLists.txt
+  '';
+
+  postInstall = ''
+    cp -r ${desktopItem}/share/applications $out/share
+    ln -sf $out/bin/dolphin-emu $out/bin/dolphin-emu-master
+  '' + lib.optionalString stdenv.hostPlatform.isLinux ''
+    install -D $src/Data/51-usb-device.rules $out/etc/udev/rules.d/51-usb-device.rules
+  '';
+
+  meta = with lib; {
+    homepage = "https://dolphin-emu.org";
+    description = "Gamecube/Wii/Triforce emulator for x86_64 and ARMv8";
+    license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ MP2E ashkitten ];
+    branch = "master";
+    # x86_32 is an unsupported platform.
+    # Enable generic build if you really want a JIT-less binary.
+    broken = stdenv.isDarwin;
+    platforms = [ "x86_64-linux" "x86_64-darwin" ];
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/dosbox/default.nix b/nixpkgs/pkgs/misc/emulators/dosbox/default.nix
new file mode 100644
index 000000000000..160c8733ff5c
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/dosbox/default.nix
@@ -0,0 +1,46 @@
+{ stdenv, lib, fetchurl, makeDesktopItem, SDL, SDL_net, SDL_sound, libGLU, libGL, libpng, graphicsmagick }:
+
+stdenv.mkDerivation rec {
+  name = "dosbox-0.74-3";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/dosbox/${name}.tar.gz";
+    sha256 = "02i648i50dwicv1vaql15rccv4g8h5blf5g6inv67lrfxpbkvlf0";
+  };
+
+  hardeningDisable = [ "format" ];
+
+  buildInputs = [ SDL SDL_net SDL_sound libGLU libGL libpng ];
+
+  nativeBuildInputs = [ graphicsmagick ];
+
+  configureFlags = lib.optional stdenv.isDarwin "--disable-sdltest";
+
+  desktopItem = makeDesktopItem {
+    name = "dosbox";
+    exec = "dosbox";
+    icon = "dosbox";
+    comment = "x86 emulator with internal DOS";
+    desktopName = "DOSBox";
+    genericName = "DOS emulator";
+    categories = "Emulator;";
+  };
+
+  postInstall = ''
+     mkdir -p $out/share/applications
+     cp ${desktopItem}/share/applications/* $out/share/applications
+
+     mkdir -p $out/share/icons/hicolor/256x256/apps
+     gm convert src/dosbox.ico $out/share/icons/hicolor/256x256/apps/dosbox.png
+  '';
+
+  enableParallelBuilding = true;
+
+  meta = with lib; {
+    homepage = "http://www.dosbox.com/";
+    description = "A DOS emulator";
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ matthewbauer ];
+    license = licenses.gpl2;
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/duckstation/default.nix b/nixpkgs/pkgs/misc/emulators/duckstation/default.nix
new file mode 100644
index 000000000000..29b867f0e9e3
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/duckstation/default.nix
@@ -0,0 +1,34 @@
+{ lib, mkDerivation, fetchFromGitHub, cmake, pkg-config, SDL2, qtbase
+, wrapQtAppsHook, qttools, ninja, gtk3 }:
+mkDerivation rec {
+  pname = "duckstation";
+  version = "unstable-2020-12-29";
+
+  src = fetchFromGitHub {
+    owner = "stenzek";
+    repo = pname;
+    rev = "f8dcfabc44ff8391b2d41eab2e883dc8f21a88b7";
+    sha256 = "0v6w4di4yj1hbxpqqrcw8rbfjg18g9kla8mnb3b5zgv7i4dyzykw";
+  };
+
+  nativeBuildInputs = [ cmake wrapQtAppsHook qttools ];
+
+  buildInputs = [ SDL2 qtbase gtk3 pkg-config ];
+
+  installPhase = ''
+    mkdir -p $out/
+    mv bin $out/
+  '';
+
+  # TODO:
+  # - vulkan graphics backend (OpenGL works).
+  # - default sound backend (cubeb) does not work, but SDL does.
+  meta = with lib; {
+    description =
+      "PlayStation 1 emulator focusing on playability, speed and long-term maintainability";
+    homepage = "https://github.com/stenzek/duckstation";
+    license = licenses.gpl3;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.guibou ];
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/emu2/default.nix b/nixpkgs/pkgs/misc/emulators/emu2/default.nix
new file mode 100644
index 000000000000..eef361ecd037
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/emu2/default.nix
@@ -0,0 +1,23 @@
+{ lib, stdenv, fetchFromGitHub }:
+
+stdenv.mkDerivation rec {
+  pname = "emu2";
+  version = "unstable-2020-06-04";
+
+  src = fetchFromGitHub {
+    owner  = "dmsc";
+    repo   = "emu2";
+    rev    = "f9599d347aab07d9281400ec8b214aabd187fbcd";
+    sha256 = "0d8fb3wp477kfi0p4mmr69lxsbgb4gl9pqmm68g9ixzrfch837v4";
+  };
+
+  makeFlags = [ "PREFIX=$(out)" ];
+
+  meta = with lib; {
+    homepage = "https://github.com/dmsc/emu2/";
+    description = "A simple text-mode x86 + DOS emulator";
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ dramaturg ];
+    license = licenses.gpl2;
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/emulationstation/default.nix b/nixpkgs/pkgs/misc/emulators/emulationstation/default.nix
new file mode 100644
index 000000000000..458b27d33044
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/emulationstation/default.nix
@@ -0,0 +1,37 @@
+{ lib, stdenv, fetchFromGitHub, pkg-config, cmake, curl, boost, eigen
+, freeimage, freetype, libGLU, libGL, SDL2, alsaLib, libarchive
+, fetchpatch }:
+
+stdenv.mkDerivation {
+  pname = "emulationstation";
+  version = "2.0.1a";
+
+  src = fetchFromGitHub {
+    owner = "Aloshi";
+    repo = "EmulationStation";
+    rev = "646bede3d9ec0acf0ae378415edac136774a66c5";
+    sha256 = "0cm0sq2wri2l9cvab1l0g02za59q7klj0h3p028vr96n6njj4w9v";
+  };
+
+  patches = [
+    (fetchpatch {
+      url = "https://github.com/Aloshi/EmulationStation/commit/49ccd8fc7a7b1dfd974fc57eb13317c42842f22c.patch";
+      sha256 = "1v5d81l7bav0k5z4vybrc3rjcysph6lkm5pcfr6m42wlz7jmjw0p";
+    })
+  ];
+
+  nativeBuildInputs = [ pkg-config cmake ];
+  buildInputs = [ alsaLib boost curl eigen freeimage freetype libarchive libGLU libGL SDL2 ];
+
+  installPhase = ''
+    install -D ../emulationstation $out/bin/emulationstation
+  '';
+
+  meta = {
+    description = "A flexible emulator front-end supporting keyboardless navigation and custom system themes";
+    homepage = "https://emulationstation.org";
+    maintainers = [ lib.maintainers.edwtjo ];
+    license = lib.licenses.mit;
+    platforms = lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/epsxe/default.nix b/nixpkgs/pkgs/misc/emulators/epsxe/default.nix
new file mode 100644
index 000000000000..7cdd88d0b941
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/epsxe/default.nix
@@ -0,0 +1,52 @@
+{ lib, stdenv, fetchurl, alsaLib, curl, gdk-pixbuf, glib, gtk3, libGLU, libGL,
+  libX11, openssl_1_0_2, ncurses5, SDL, SDL_ttf, unzip, zlib, wrapGAppsHook, autoPatchelfHook }:
+
+with lib;
+
+stdenv.mkDerivation rec {
+  pname = "epsxe";
+  version = "2.0.5";
+
+  src = let
+    version2 = replaceStrings ["."] [""] version;
+    platform = "linux" + (optionalString stdenv.is64bit "_x64");
+  in fetchurl {
+    url = "https://www.epsxe.com/files/ePSXe${version2}${platform}.zip";
+    sha256 = if stdenv.is64bit
+             then "16fa9qc2xhaz1f6294m0b56s5l86cbmclwm9w3mqnch0yjsrvab0"
+             else "1677lclam557kp8jwvchdrk27zfj50fqx2q9i3bcx26d9k61q3kl";
+  };
+
+  nativeBuildInputs = [ unzip wrapGAppsHook autoPatchelfHook ];
+  sourceRoot = ".";
+
+  buildInputs = [
+    alsaLib
+    curl
+    gdk-pixbuf
+    glib
+    gtk3
+    libX11
+    libGLU libGL
+    openssl_1_0_2
+    ncurses5
+    SDL
+    SDL_ttf
+    stdenv.cc.cc.lib
+    zlib
+  ];
+
+  dontStrip = true;
+
+  installPhase = ''
+    install -D ${if stdenv.is64bit then "epsxe_x64" else "ePSXe"} $out/bin/epsxe
+  '';
+
+  meta = {
+    homepage = "http://epsxe.com/";
+    description = "Enhanced PSX (PlayStation 1) emulator";
+    license = licenses.unfree;
+    maintainers = with maintainers; [ yegortimoshenko ];
+    platforms = [ "i686-linux" "x86_64-linux" ];
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/fakenes/build.patch b/nixpkgs/pkgs/misc/emulators/fakenes/build.patch
new file mode 100644
index 000000000000..90799d977a14
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/fakenes/build.patch
@@ -0,0 +1,84 @@
+diff --git a/build/openal.cbd b/build/openal.cbd
+index d18e62d..74af061 100644
+--- a/build/openal.cbd
++++ b/build/openal.cbd
+@@ -23,7 +23,7 @@ CFLAGS += ' -DUSE_OPENAL'
+ # --
+ 
+ do ifplat unix
+-   LDFLAGS += ' `openal-config --libs`'
++   LDFLAGS += ' -lopenal'
+ else
+    LDFLAGS += ' -lOpenAL32'
+ done
+diff --git a/build/alleggl.cbd b/build/alleggl.cbd
+index e2708ff..e826371 100644
+--- a/build/alleggl.cbd
++++ b/build/alleggl.cbd
+@@ -22,7 +22,7 @@ CFLAGS += ' -DUSE_ALLEGROGL'
+ 
+ # --
+ 
+-LIBAGL = agl
++LIBAGL = alleggl
+ 
+ ifopt debug LIBAGL = 'agld'
+
+diff --git a/src/apu.cpp b/src/apu.cpp
+index af59f1c..893a798 100644
+--- a/src/apu.cpp
++++ b/src/apu.cpp
+@@ -1930,7 +1930,7 @@ static void amplify(real& sample)
+          gain -= releaseRate;
+       }
+ 
+-      real output = (1.0 / max(gain, EPSILON));
++      real output = (1.0 / MAX(gain, EPSILON));
+       output = fixf(output, apu_agc_gain_floor, apu_agc_gain_ceiling);
+       sample *= output;
+    }
+diff --git a/src/audio.cpp b/src/audio.cpp
+index b9650dc..c21c05e 100644
+--- a/src/audio.cpp
++++ b/src/audio.cpp
+@@ -7,6 +7,7 @@
+    You must read and accept the license prior to use. */
+ 
+ #include <allegro.h>
++#include <cstdio>
+ #include <cstdlib>
+ #include <cstring>
+ #include <vector>
+@@ -234,7 +235,7 @@ void audio_update(void)
+          const unsigned queuedFrames = (audioQueue.size() / audio_channels);
+          if(queuedFrames > 0) {
+             // Determine how many frames we want to make room for.
+-            const unsigned framesToAdd = min(queuedFrames, audio_buffer_size_frames);
++            const unsigned framesToAdd = MIN(queuedFrames, audio_buffer_size_frames);
+             // Make room for the frames in the buffer.
+             const unsigned framesToMove = (audioBufferedFrames - framesToAdd);
+             if(framesToMove > 0) {
+@@ -258,7 +259,7 @@ void audio_update(void)
+          // Determine how many frames are available in the buffer.
+          const unsigned bufferableFrames = (audio_buffer_size_frames - audioBufferedFrames);
+          // Determine the number of frames to copy to the buffer.
+-         const unsigned framesToCopy = min(queuedFrames, bufferableFrames);
++         const unsigned framesToCopy = MIN(queuedFrames, bufferableFrames);
+ 
+          // Copy frames to the buffer.
+          for(unsigned frame = 0; frame < framesToCopy; frame++) {
+diff --git a/src/include/common.h b/src/include/common.h
+index be28795..e2d21d1 100644
+--- a/src/include/common.h
++++ b/src/include/common.h
+@@ -41,8 +41,10 @@ extern "C" {
+ #define true   TRUE
+ #define false  FALSE
+ 
++/*
+ #define min(x,y)   MIN((x),(y))
+ #define max(x,y)   MAX((x),(y))
++*/
+ 
+ #define true_or_false(x)   ((x) ? true : false)
+ 
diff --git a/nixpkgs/pkgs/misc/emulators/fakenes/default.nix b/nixpkgs/pkgs/misc/emulators/fakenes/default.nix
new file mode 100644
index 000000000000..2011d8ce0375
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/fakenes/default.nix
@@ -0,0 +1,32 @@
+{lib, stdenv, fetchurl, allegro, openal, libGLU, libGL, zlib, hawknl, freeglut, libX11,
+  libXxf86vm, libXcursor, libXpm }:
+
+stdenv.mkDerivation {
+  name = "fakenes-0.5.9b3";
+  src = fetchurl {
+    url = "mirror://sourceforge/fakenes/fakenes-0.5.9-beta3.tar.gz";
+    sha256 = "026h67s4pzc1vma59pmzk02iy379255qbai2q74wln9bxqcpniy4";
+  };
+
+  buildInputs = [ allegro openal libGLU libGL zlib hawknl freeglut libX11
+    libXxf86vm libXcursor libXpm ];
+
+  hardeningDisable = [ "format" ];
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp fakenes $out/bin
+  '';
+
+  NIX_LDFLAGS = "-lX11 -lXxf86vm -lXcursor -lXpm";
+
+  patches = [ ./build.patch ];
+
+  meta = {
+    homepage = "http://fakenes.sourceforge.net/";
+    license = lib.licenses.gpl2Plus;
+    description = "Portable Open Source NES Emulator";
+    platforms = lib.platforms.linux;
+    broken = true;
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/fceux/default.nix b/nixpkgs/pkgs/misc/emulators/fceux/default.nix
new file mode 100644
index 000000000000..f76fc761abbc
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/fceux/default.nix
@@ -0,0 +1,40 @@
+{lib, stdenv, fetchFromGitHub, scons, zlib, SDL, lua5_1, pkg-config}:
+
+stdenv.mkDerivation {
+  pname = "fceux-unstable";
+  version = "2020-01-29";
+
+  src = fetchFromGitHub {
+    owner = "TASVideos";
+    repo = "fceux";
+    rev = "fb8d46d9697cb24b0ebe79d84eedf282f69ab337";
+    sha256 = "0gpz411dzfwx9mr34yi4zb1hphd5hha1nvwgzxki0sviwafca992";
+  };
+
+  nativeBuildInputs = [ pkg-config scons ];
+  buildInputs = [
+    zlib SDL lua5_1
+  ];
+
+  sconsFlags = "OPENGL=false GTK=false CREATE_AVI=false LOGO=false";
+  prefixKey = "--prefix=";
+
+  # sed allows scons to find libraries in nix.
+  # mkdir is a hack to make scons succeed.  It still doesn't
+  # actually put the files in there due to a bug in the SConstruct file.
+  # OPENGL doesn't work because fceux dlopens the library.
+  preBuild = ''
+    sed -e 's/env *= *Environment *.*/&; env['"'"'ENV'"'"']=os.environ;/' -i SConstruct
+    export CC="gcc"
+    export CXX="g++"
+    mkdir -p "$out" "$out/share/applications" "$out/share/pixmaps"
+  '';
+
+  meta = {
+    description = "A Nintendo Entertainment System (NES) Emulator";
+    license = lib.licenses.gpl2;
+    maintainers = [ lib.maintainers.scubed2 ];
+    homepage = "http://www.fceux.com/";
+    platforms = lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/firebird-emu/default.nix b/nixpkgs/pkgs/misc/emulators/firebird-emu/default.nix
new file mode 100644
index 000000000000..236eff8610cc
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/firebird-emu/default.nix
@@ -0,0 +1,38 @@
+{ mkDerivation, lib, stdenv, fetchFromGitHub, qmake, qtbase, qtdeclarative }:
+
+mkDerivation rec {
+  pname = "firebird-emu";
+  version = "1.4";
+
+  src = fetchFromGitHub {
+    owner = "nspire-emus";
+    repo = "firebird";
+    rev = "v${version}";
+    sha256 = "0pdca6bgnmzfgf5kp83as99y348gn4plzbxnqxjs61vp489baahq";
+    fetchSubmodules = true;
+  };
+
+  enableParallelBuilding = true;
+
+  nativeBuildInputs = [ qmake ];
+
+  buildInputs = [ qtbase qtdeclarative ];
+
+  makeFlags = [ "INSTALL_ROOT=$(out)" ];
+
+  # Attempts to install to /usr/bin and /usr/share/applications, which Nix does
+  # not use.
+  prePatch = ''
+    substituteInPlace firebird.pro \
+      --replace '/usr/' '/'
+  '';
+
+  meta = {
+    homepage = "https://github.com/nspire-emus/firebird";
+    description = "Third-party multi-platform emulator of the ARM-based TI-Nspire™ calculators";
+    license = lib.licenses.gpl3;
+    maintainers = with lib.maintainers; [ pneumaticat ];
+    # Only tested on Linux, but likely possible to build on, e.g. macOS
+    platforms = lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/fs-uae/default.nix b/nixpkgs/pkgs/misc/emulators/fs-uae/default.nix
new file mode 100644
index 000000000000..eef8c2c32533
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/fs-uae/default.nix
@@ -0,0 +1,32 @@
+{ lib, stdenv, fetchurl, pkg-config
+, gettext, gtk2, SDL2, zlib, glib, openal, libGLU, libGL, lua, freetype, libmpeg2, zip }:
+
+with lib;
+stdenv.mkDerivation rec {
+
+  pname = "fs-uae";
+  version = "3.0.5";
+
+  src = fetchurl {
+    url = "https://fs-uae.net/stable/${version}/${pname}-${version}.tar.gz";
+    sha256 = "1qwzhp34wy7bnd3c0plv11rg9fs5m92rh3ffnr9pn6ng0cpc8vpj";
+  };
+
+  nativeBuildInputs = [ pkg-config ];
+  buildInputs = [ gettext gtk2 SDL2 zlib glib openal libGLU libGL lua freetype libmpeg2 zip ];
+
+  meta = {
+    description = "An accurate, customizable Amiga Emulator";
+    longDescription = ''
+      FS-UAE integrates the most accurate Amiga emulation code available
+      from WinUAE. FS-UAE emulates A500, A500+, A600, A1200, A1000, A3000
+      and A4000 models, but you can tweak the hardware configuration and
+      create customized Amigas.
+    '';
+    license = licenses.gpl2Plus;
+    homepage = "https://fs-uae.net";
+    maintainers = with lib; [ maintainers.AndersonTorres ];
+    platforms = [ "i686-linux" "x86_64-linux" ];
+  };
+}
+# TODO: testing and Python GUI support
diff --git a/nixpkgs/pkgs/misc/emulators/fuse-emulator/default.nix b/nixpkgs/pkgs/misc/emulators/fuse-emulator/default.nix
new file mode 100644
index 000000000000..3426b47daeac
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/fuse-emulator/default.nix
@@ -0,0 +1,29 @@
+{ lib, stdenv, fetchurl, perl, pkg-config, wrapGAppsHook
+, SDL, bzip2, glib, gtk3, libgcrypt, libpng, libspectrum, libxml2, zlib
+}:
+
+stdenv.mkDerivation rec {
+  pname = "fuse-emulator";
+  version = "1.5.7";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/${pname}/fuse-${version}.tar.gz";
+    sha256 = "0kaynjr28w42n3iha60mgr7nxm49w8j0v49plyrc7ka24qzmiqph";
+  };
+
+  nativeBuildInputs = [ perl pkg-config wrapGAppsHook ];
+
+  buildInputs = [ SDL bzip2 glib gtk3 libgcrypt libpng libspectrum libxml2 zlib ];
+
+  configureFlags = [ "--enable-desktop-integration" ];
+
+  enableParallelBuilding = true;
+
+  meta = with lib; {
+    homepage = "http://fuse-emulator.sourceforge.net/";
+    description = "ZX Spectrum emulator";
+    license = licenses.gpl2Plus;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ orivej ];
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/gens-gs/default.nix b/nixpkgs/pkgs/misc/emulators/gens-gs/default.nix
new file mode 100644
index 000000000000..abc676ffa632
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/gens-gs/default.nix
@@ -0,0 +1,25 @@
+{ lib, stdenv, fetchurl, pkg-config, gtk2, SDL, nasm, zlib, libpng, libGLU, libGL }:
+
+stdenv.mkDerivation {
+  name = "gens-gs-7";
+
+  src = fetchurl {
+    url = "http://retrocdn.net/images/6/6d/Gens-gs-r7.tar.gz";
+    sha256 = "1ha5s6d3y7s9aq9f4zmn9p88109c3mrj36z2w68jhiw5xrxws833";
+  };
+
+  nativeBuildInputs = [ pkg-config ];
+  buildInputs = [ gtk2 SDL nasm zlib libpng libGLU libGL ];
+
+  # Work around build failures on recent GTK.
+  # See http://ubuntuforums.org/showthread.php?p=10535837
+  NIX_CFLAGS_COMPILE = "-UGTK_DISABLE_DEPRECATED -UGSEAL_ENABLE";
+
+  meta = with lib; {
+    homepage = "https://segaretro.org/Gens/GS";
+    description = "A Genesis/Mega Drive emulator";
+    platforms = [ "i686-linux" ];
+    license = licenses.gpl2Plus;
+    maintainers = [ maintainers.eelco ];
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/gxemul/default.nix b/nixpkgs/pkgs/misc/emulators/gxemul/default.nix
new file mode 100644
index 000000000000..3149ccaaaac0
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/gxemul/default.nix
@@ -0,0 +1,35 @@
+{ lib, stdenv, fetchurl }:
+
+stdenv.mkDerivation rec {
+  pname = "gxemul";
+  version = "0.6.2";
+
+  src = fetchurl {
+    url = "http://gavare.se/gxemul/src/gxemul-${version}.tar.gz";
+    sha256 = "0iqmazfn7ss5n27m1a9n9nps3vzhag1phzb7qw0wgczycmwsq0x7";
+  };
+
+  configurePhase = "./configure";
+
+  installPhase = ''
+    mkdir -p {$out/bin,$out/share/${pname}-${version}}
+    cp -r {doc,demos} $out/share/${pname}-${version}
+    cp gxemul $out/bin
+    cp -r ./man $out
+  '';
+
+  meta = with lib; {
+    homepage = "http://gavare.se/gxemul/";
+    description = "Gavare's experimental emulator";
+    longDescription = ''
+      GXemul is a framework for full-system computer architecture
+      emulation. Several real machines have been implemented within the
+      framework, consisting of processors (ARM, MIPS, Motorola 88K,
+      PowerPC, and SuperH) and surrounding hardware components such as
+      framebuffers, interrupt controllers, busses, disk controllers,
+      and serial controllers. The emulation is working well enough to
+      allow several unmodified "guest" operating systems to run.
+    '';
+    license = licenses.bsd3;
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/hatari/default.nix b/nixpkgs/pkgs/misc/emulators/hatari/default.nix
new file mode 100644
index 000000000000..be80b9bc351a
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/hatari/default.nix
@@ -0,0 +1,25 @@
+{ lib, stdenv, fetchurl, zlib, SDL, cmake }:
+
+stdenv.mkDerivation rec {
+  pname = "hatari";
+  version = "2.3.0";
+
+  src = fetchurl {
+    url = "https://download.tuxfamily.org/hatari/${version}/${pname}-${version}.tar.bz2";
+    sha256 = "19dqadi32hgi78hyxxcm8v2vh28vyn9w5nd1xiq683wk0ccicj5z";
+  };
+
+  # For pthread_cancel
+  cmakeFlags = [ "-DCMAKE_EXE_LINKER_FLAGS=-lgcc_s" ];
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ zlib SDL ];
+
+  meta = {
+    homepage = "http://hatari.tuxfamily.org/";
+    description = "Atari ST/STE/TT/Falcon emulator";
+    license = lib.licenses.gpl2Plus;
+    platforms = lib.platforms.linux;
+    maintainers = with lib.maintainers; [ ];
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/higan/0001-change-flags.diff b/nixpkgs/pkgs/misc/emulators/higan/0001-change-flags.diff
new file mode 100644
index 000000000000..745bba5d518d
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/higan/0001-change-flags.diff
@@ -0,0 +1,25 @@
+diff -Naur higan-110-old/higan/GNUmakefile higan-110-new/higan/GNUmakefile
+--- higan-110-old/higan/GNUmakefile	2020-04-15 11:06:00.279935557 -0300
++++ higan-110-new/higan/GNUmakefile	2020-04-15 11:08:32.982417291 -0300
+@@ -11,7 +11,7 @@
+ include $(nall.path)/GNUmakefile
+ 
+ ifeq ($(platform),local)
+-  flags += -march=native
++  flags +=
+ endif
+ 
+ ifeq ($(platform),windows)
+diff -Naur higan-110-old/nall/GNUmakefile higan-110-new/nall/GNUmakefile
+--- higan-110-old/nall/GNUmakefile	2020-04-15 11:06:00.396935154 -0300
++++ higan-110-new/nall/GNUmakefile	2020-04-15 11:10:37.738011488 -0300
+@@ -127,7 +127,8 @@
+ 
+ # linux settings
+ ifeq ($(platform),linux)
+-  options += -ldl
++  flags += $(CXXFLAGS)
++  options += $(LDFLAGS) -ldl
+ endif
+ 
+ # bsd settings
diff --git a/nixpkgs/pkgs/misc/emulators/higan/default.nix b/nixpkgs/pkgs/misc/emulators/higan/default.nix
new file mode 100644
index 000000000000..c7bc7e9f976e
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/higan/default.nix
@@ -0,0 +1,135 @@
+{ lib, stdenv, fetchFromGitHub
+, pkg-config
+, libX11, libXv
+, udev
+, libGLU, libGL, SDL2
+, libao, openal, libpulseaudio
+, alsaLib
+, gtk2, gtksourceview
+, runtimeShell
+# Darwin dependencies
+, libicns, Carbon, Cocoa, OpenGL, OpenAL}:
+
+let
+  inherit (lib) optionals;
+in
+stdenv.mkDerivation rec {
+
+  pname = "higan";
+  version = "110";
+
+  src = fetchFromGitHub {
+    owner = "higan-emu";
+    repo = "higan";
+    rev = "v${version}";
+    sha256 = "11rvm53c3p2f6zk8xbyv2j51xp8zmqnch7zravhj3fk590qrjrr2";
+  };
+
+  patches = [ ./0001-change-flags.diff ];
+  postPatch = ''
+    sed '1i#include <cmath>' -i higan/fc/ppu/ppu.cpp
+
+    for file in icarus/GNUmakefile higan/target-higan/GNUmakefile; do
+      substituteInPlace "$file" \
+        --replace 'sips -s format icns data/$(name).png --out out/$(name).app/Contents/Resources/$(name).icns' \
+                  'png2icns out/$(name).app/Contents/Resources/$(name).icns data/$(name).png'
+    done
+  '';
+
+  nativeBuildInputs = [ pkg-config ]
+    ++ optionals stdenv.isDarwin [ libicns ];
+
+  buildInputs = [ SDL2 libao ]
+                ++ optionals stdenv.isLinux [ alsaLib udev libpulseaudio openal
+                                              gtk2 gtksourceview libX11 libXv
+                                              libGLU libGL ]
+                ++ optionals stdenv.isDarwin [ Carbon Cocoa OpenGL OpenAL ];
+
+  buildPhase = ''
+    make compiler=c++ -C higan openmp=true target=higan
+    make compiler=c++ -C genius openmp=true
+    make compiler=c++ -C icarus openmp=true
+  '';
+
+  installPhase = (if stdenv.isDarwin then ''
+    mkdir "$out"
+    mv higan/out/higan.app "$out"/
+    mv icarus/out/icarus.app "$out"/
+    mv genius/out/genius.app "$out"/
+  '' else ''
+    install -dm 755 "$out"/bin "$out"/share/applications "$out"/share/pixmaps
+
+    install -m 755 higan/out/higan -t "$out"/bin/
+    install -m 644 higan/target-higan/resource/higan.desktop \
+            -t $out/share/applications/
+    install -m 644 higan/target-higan/resource/higan.svg \
+            $out/share/pixmaps/higan-icon.svg
+    install -m 644 higan/target-higan/resource/higan.png \
+            $out/share/pixmaps/higan-icon.png
+
+    install -m 755 icarus/out/icarus -t "$out"/bin/
+    install -m 644 icarus/data/icarus.desktop -t $out/share/applications/
+    install -m 644 icarus/data/icarus.svg $out/share/pixmaps/icarus-icon.svg
+    install -m 644 icarus/data/icarus.png $out/share/pixmaps/icarus-icon.png
+
+    install -m 755 genius/out/genius -t "$out"/bin/
+    install -m 644 genius/data/genius.desktop -t $out/share/applications/
+    install -m 644 genius/data/genius.svg $out/share/pixmaps/genius-icon.svg
+    install -m 644 genius/data/genius.png $out/share/pixmaps/genius-icon.png
+  '') + ''
+    mkdir -p "$out"/share/higan "$out"/share/icarus
+    cp --recursive --no-dereference --preserve='links' --no-preserve='ownership' \
+      higan/System/ "$out"/share/higan/
+    cp --recursive --no-dereference --preserve='links' --no-preserve='ownership' \
+      icarus/Database icarus/Firmware $out/share/icarus/
+  '';
+
+  fixupPhase = let
+    dest = if stdenv.isDarwin
+           then "\\$HOME/Library/Application Support/higan"
+           else "\\$HOME/higan";
+  in ''
+    # A dirty workaround, suggested by @cpages:
+    # we create a first-run script to populate
+    # $HOME with all the stuff needed at runtime
+
+    mkdir -p "$out"/bin
+    cat <<EOF > $out/bin/higan-init.sh
+    #!${runtimeShell}
+
+    cp --recursive --update $out/share/higan/System/ "${dest}"/
+
+    EOF
+
+    chmod +x $out/bin/higan-init.sh
+  '';
+
+  meta = with lib; {
+    description = "An open-source, cycle-accurate multi-system emulator";
+    longDescription = ''
+      higan is a multi-system game console emulator. The purpose of higan is to
+      serve as hardware documentation in source code form: it is meant to be as
+      accurate and complete as possible, with code that is easy to read and
+      understand.
+
+      It currently supports the following systems:
+      - Famicom + Famicom Disk System
+      - Super Famicom + Super Game Boy
+      - Game Boy + Game Boy Color
+      - Game Boy Advance + Game Boy Player
+      - SG-1000 + SC-3000
+      - Master System + Game Gear
+      - Mega Drive + Mega CD
+      - PC Engine + SuperGrafx
+      - MSX + MSX2
+      - ColecoVision
+      - Neo Geo Pocket + Neo Geo Pocket Color
+      - WonderSwan + WonderSwan Color + SwanCrystal + Pocket Challenge V2
+    '';
+    homepage = "https://byuu.org/higan/";
+    license = licenses.gpl3Plus;
+    maintainers = with maintainers; [ AndersonTorres ];
+    platforms = platforms.unix;
+  };
+}
+# TODO: Qt and GTK3+ support
diff --git a/nixpkgs/pkgs/misc/emulators/kega-fusion/default.nix b/nixpkgs/pkgs/misc/emulators/kega-fusion/default.nix
new file mode 100644
index 000000000000..1b00a55fe058
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/kega-fusion/default.nix
@@ -0,0 +1,78 @@
+{ stdenv, lib, writeText, fetchurl, upx, libGLU, glib, gtk2, alsaLib, libSM, libX11, gdk-pixbuf, pango, libXinerama, mpg123, runtimeShell }:
+
+let
+  libPath = lib.makeLibraryPath [ stdenv.cc.cc libGLU glib gtk2 alsaLib libSM libX11 gdk-pixbuf pango libXinerama ];
+
+in stdenv.mkDerivation {
+  pname = "kega-fusion";
+  version = "3.63x";
+
+  src = fetchurl {
+    url = "http://www.carpeludum.com/download/Fusion363x.tar.gz";
+    sha256 = "14s6czy20h5khyy7q95hd7k77v17ssafv9l6lafkiysvj2nmw94g";
+  };
+
+  plugins = fetchurl {
+    url = "http://www.carpeludum.com/download/PluginsLinux.tar.gz";
+    sha256 = "0d623cvh6n5ijj3wb64g93mxx2xbichsn7hj7brbb0ndw5cs70qj";
+  };
+
+  runner = writeText "kega-fusion" ''
+    #!${runtimeShell} -ex
+
+    kega_libdir="@out@/lib/kega-fusion"
+    kega_localdir="$HOME/.Kega Fusion"
+
+    # create local plugins directory if not present
+    mkdir -p "$kega_localdir/Plugins"
+
+    # create links for every included plugin
+    if [ $(ls -1A $kega_libdir/plugins | wc -l) -gt 0 ]; then
+      for i in $kega_libdir/plugins/*; do
+        if [ ! -e "$kega_localdir/Plugins/$(basename "$i")" ]; then
+          ln -sf "$i" "$kega_localdir/Plugins/"
+        fi
+      done
+    fi
+
+    # copy configuration file if not present
+    if ! [ -f "$kega_localdir/Fusion.ini" ]; then
+      cat > "$kega_localdir/Fusion.ini" <<EOF
+    ALSADeviceName=default
+    libmpg123path=${lib.getLib mpg123}/lib/libmpg123.so.0
+    EOF
+    else
+      sed -i 's,^\(libmpg123path=\).*,\1${lib.getLib mpg123}/lib/libmpg123.so.0,' "$kega_localdir/Fusion.ini"
+    fi
+
+    # here we go!
+    exec "$kega_libdir/Fusion" "$@"
+  '';
+
+  dontStrip = true;
+  dontPatchELF = true;
+
+  nativeBuildInputs = [ upx ];
+
+  installPhase = ''
+    upx -d Fusion
+    install -Dm755 Fusion "$out/lib/kega-fusion/Fusion"
+    patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" --set-rpath "${libPath}" "$out/lib/kega-fusion/Fusion"
+
+    tar -xaf $plugins
+    mkdir -p "$out/lib/kega-fusion/plugins"
+    cp -r Plugins/*.rpi "$out/lib/kega-fusion/plugins"
+
+    mkdir -p "$out/bin"
+    substitute "$runner" "$out/bin/kega-fusion" --subst-var out
+    chmod +x "$out/bin/kega-fusion"
+  '';
+
+  meta = with lib; {
+    description = "Sega SG1000, SC3000, SF7000, Master System, Game Gear, Genesis/Megadrive, SVP, Pico, SegaCD/MegaCD and 32X emulator";
+    homepage = "https://www.carpeludum.com/kega-fusion/";
+    maintainers = with maintainers; [ abbradar ];
+    license = licenses.unfreeRedistributable;
+    platforms = [ "i686-linux" ];
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/lambda-delta/default.nix b/nixpkgs/pkgs/misc/emulators/lambda-delta/default.nix
new file mode 100644
index 000000000000..a17a0eadfd5b
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/lambda-delta/default.nix
@@ -0,0 +1,26 @@
+{ lib, stdenv, fetchFromGitHub, autoreconfHook, pkg-config, SDL2 }:
+
+stdenv.mkDerivation rec {
+  pname = "lambda-delta";
+  version = "0.98.3";
+
+  src = fetchFromGitHub {
+    owner = "dseagrav";
+    repo = "ld";
+    rev = version;
+    sha256 = "02m43fj9dzc1i1jl01qwnhjiq1rh03jw1xq59sx2h3bhn7dk941x";
+  };
+
+  nativeBuildInputs = [ autoreconfHook pkg-config ];
+  buildInputs = [ SDL2 ];
+
+  configureFlags = [ "--without-SDL1" ];
+
+  meta = with lib; {
+    description = "LMI (Lambda Lisp Machine) emulator";
+    homepage = "https://github.com/dseagrav/ld";
+    license = licenses.gpl2;
+    maintainers = with maintainers; [ siraben ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/libdsk/default.nix b/nixpkgs/pkgs/misc/emulators/libdsk/default.nix
new file mode 100644
index 000000000000..c0e54e48db32
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/libdsk/default.nix
@@ -0,0 +1,19 @@
+{ lib, stdenv, fetchurl }:
+
+stdenv.mkDerivation rec {
+  pname = "libdsk";
+  version = "1.5.12";
+
+  src = fetchurl {
+    url = "https://www.seasip.info/Unix/LibDsk/${pname}-${version}.tar.gz";
+    sha256 = "0s2k9vkrf95pf4ydc6vazb29ysrnhdpcfjnf17lpk4nmlv1j3vyv";
+  };
+
+  meta = with lib; {
+    description = "A library for accessing discs and disc image files";
+    homepage = "http://www.seasip.info/Unix/LibDsk/";
+    license = licenses.gpl2Plus;
+    maintainers = [ ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/mame/default.nix b/nixpkgs/pkgs/misc/emulators/mame/default.nix
new file mode 100644
index 000000000000..c7ac7a65ccd3
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/mame/default.nix
@@ -0,0 +1,89 @@
+{ stdenv, mkDerivation, fetchFromGitHub, makeDesktopItem, makeWrapper
+, python, pkg-config, SDL2, SDL2_ttf, alsaLib, which, qtbase, libXinerama
+, libpcap, CoreAudioKit, ForceFeedback
+, installShellFiles }:
+
+with stdenv;
+
+let
+  majorVersion = "0";
+  minorVersion = "226";
+
+  desktopItem = makeDesktopItem {
+    name = "MAME";
+    exec = "mame${lib.optionalString stdenv.is64bit "64"}";
+    desktopName = "MAME";
+    genericName = "MAME is a multi-purpose emulation framework";
+    categories = "System;Emulator;";
+  };
+
+  dest = "$out/opt/mame";
+in mkDerivation {
+  pname = "mame";
+  version = "${majorVersion}.${minorVersion}";
+
+  src = fetchFromGitHub {
+    owner = "mamedev";
+    repo = "mame";
+    rev = "mame${majorVersion}${minorVersion}";
+    sha256 = "0pnsvz4vkjkqb1ac5wzwz31vx0iknyg5ffly90nhl13kcr656jrj";
+  };
+
+  hardeningDisable = [ "fortify" ];
+  NIX_CFLAGS_COMPILE = [ "-Wno-error=maybe-uninitialized" "-Wno-error=missing-braces" ];
+
+  makeFlags = [
+    "TOOLS=1"
+    "USE_LIBSDL=1"
+  ]
+  ++ lib.optionals stdenv.cc.isClang [ "CC=clang" "CXX=clang++" ]
+  ;
+
+  dontWrapQtApps = true;
+
+  buildInputs =
+    [ SDL2 SDL2_ttf qtbase libXinerama ]
+    ++ lib.optional stdenv.isLinux alsaLib
+    ++ lib.optionals stdenv.isDarwin [ libpcap CoreAudioKit ForceFeedback ]
+    ;
+  nativeBuildInputs = [ python pkg-config which makeWrapper installShellFiles ];
+
+  # by default MAME assumes that paths with stock resources
+  # are relative and that you run MAME changing to
+  # install directory, so we add absolute paths here
+  patches = [
+    ./emuopts.patch
+  ];
+
+  postPatch = ''
+    substituteInPlace src/emu/emuopts.cpp \
+      --subst-var-by mame ${dest}
+  '';
+
+  installPhase = ''
+    make -f dist.mak PTR64=${lib.optionalString stdenv.is64bit "1"}
+    mkdir -p ${dest}
+    mv build/release/*/Release/mame/* ${dest}
+
+    mkdir -p $out/bin
+    find ${dest} -maxdepth 1 -executable -type f -exec mv -t $out/bin {} \;
+    install -Dm755 src/osd/sdl/taputil.sh $out/bin/taputil.sh
+
+    installManPage ${dest}/docs/man/*.1 ${dest}/docs/man/*.6
+
+    mv artwork plugins samples ${dest}
+  '' + lib.optionalString stdenv.isLinux ''
+    mkdir -p $out/share
+    ln -s ${desktopItem}/share/applications $out/share
+  '';
+
+  meta = with lib; {
+    description = "Is a multi-purpose emulation framework";
+    homepage = "https://www.mamedev.org/";
+    license = with licenses; [ bsd3 gpl2Plus ];
+    platforms = platforms.unix;
+    # makefile needs fixes for install target
+    badPlatforms = [ "aarch64-linux" ];
+    maintainers = with maintainers; [ gnidorah ];
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/mame/emuopts.patch b/nixpkgs/pkgs/misc/emulators/mame/emuopts.patch
new file mode 100644
index 000000000000..b85291f52f74
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/mame/emuopts.patch
@@ -0,0 +1,29 @@
+diff --git a/src/emu/emuopts.cpp b/src/emu/emuopts.cpp
+index c42fcef848..d1bddae060 100644
+--- a/src/emu/emuopts.cpp
++++ b/src/emu/emuopts.cpp
+@@ -36,16 +36,16 @@ const options_entry emu_options::s_option_entries[] =
+ 	{ nullptr,                                           nullptr,     OPTION_HEADER,     "CORE SEARCH PATH OPTIONS" },
+ 	{ OPTION_HOMEPATH,                                   ".",         OPTION_STRING,     "path to base folder for plugin data (read/write)" },
+ 	{ OPTION_MEDIAPATH ";rp;biospath;bp",                "roms",      OPTION_STRING,     "path to ROM sets and hard disk images" },
+-	{ OPTION_HASHPATH ";hash_directory;hash",            "hash",      OPTION_STRING,     "path to software definition files" },
+-	{ OPTION_SAMPLEPATH ";sp",                           "samples",   OPTION_STRING,     "path to audio sample sets" },
+-	{ OPTION_ARTPATH,                                    "artwork",   OPTION_STRING,     "path to artwork files" },
+-	{ OPTION_CTRLRPATH,                                  "ctrlr",     OPTION_STRING,     "path to controller definitions" },
+-	{ OPTION_INIPATH,                                    ".;ini;ini/presets",     OPTION_STRING,     "path to ini files" },
+-	{ OPTION_FONTPATH,                                   ".",         OPTION_STRING,     "path to font files" },
++	{ OPTION_HASHPATH ";hash_directory;hash",            "hash;@mame@/hash",      OPTION_STRING,     "path to software definition files" },
++	{ OPTION_SAMPLEPATH ";sp",                           "samples;@mame@/samples",   OPTION_STRING,     "path to audio sample sets" },
++	{ OPTION_ARTPATH,                                    "artwork;@mame@/artwork",   OPTION_STRING,     "path to artwork files" },
++	{ OPTION_CTRLRPATH,                                  "ctrlr;@mame@/ctrlr",     OPTION_STRING,     "path to controller definitions" },
++	{ OPTION_INIPATH,                                    ".;ini;ini/presets;@mame@/ini/presets",     OPTION_STRING,     "path to ini files" },
++	{ OPTION_FONTPATH,                                   ".;@mame@",         OPTION_STRING,     "path to font files" },
+ 	{ OPTION_CHEATPATH,                                  "cheat",     OPTION_STRING,     "path to cheat files" },
+ 	{ OPTION_CROSSHAIRPATH,                              "crosshair", OPTION_STRING,     "path to crosshair files" },
+-	{ OPTION_PLUGINSPATH,                                "plugins",   OPTION_STRING,     "path to plugin files" },
+-	{ OPTION_LANGUAGEPATH,                               "language",  OPTION_STRING,     "path to UI translation files" },
++	{ OPTION_PLUGINSPATH,                                "plugins;@mame@/plugins",   OPTION_STRING,     "path to plugin files" },
++	{ OPTION_LANGUAGEPATH,                               "language;@mame@/language",  OPTION_STRING,     "path to UI translation files" },
+ 	{ OPTION_SWPATH,                                     "software",  OPTION_STRING,     "path to loose software" },
+ 
+ 	// output directory options
diff --git a/nixpkgs/pkgs/misc/emulators/mednafen/default.nix b/nixpkgs/pkgs/misc/emulators/mednafen/default.nix
new file mode 100644
index 000000000000..aaf736f3e5e4
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/mednafen/default.nix
@@ -0,0 +1,74 @@
+{ lib, stdenv, fetchurl, pkg-config, freeglut, libGLU, libGL, libcdio, libjack2
+, libsamplerate, libsndfile, libX11, SDL2, SDL2_net, zlib, alsaLib }:
+
+stdenv.mkDerivation rec {
+  pname = "mednafen";
+  version = "1.26.1";
+
+  src = fetchurl {
+    url = "https://mednafen.github.io/releases/files/${pname}-${version}.tar.xz";
+    sha256 = "1x7xhxjhwsdbak8l0iyb497f043xkhibk73w96xck4j2bk10fac4";
+  };
+
+  nativeBuildInputs = [ pkg-config ];
+
+  buildInputs = [
+    freeglut
+    libGLU libGL
+    libcdio
+    libjack2
+    alsaLib
+    libsamplerate
+    libsndfile
+    libX11
+    SDL2
+    SDL2_net
+    zlib
+  ];
+
+  hardeningDisable = [ "pic" ];
+
+  postInstall = ''
+    mkdir -p $out/share/doc
+    mv Documentation $out/share/doc/mednafen
+  '';
+
+  meta = with lib; {
+    description = "A portable, CLI-driven, SDL+OpenGL-based, multi-system emulator";
+    longDescription = ''
+      Mednafen is a portable, utilizing OpenGL and SDL,
+      argument(command-line)-driven multi-system emulator. Mednafen has the
+      ability to remap hotkey functions and virtual system inputs to a keyboard,
+      a joystick, or both simultaneously. Save states are supported, as is
+      real-time game rewinding. Screen snapshots may be taken, in the PNG file
+      format, at the press of a button. Mednafen can record audiovisual movies
+      in the QuickTime file format, with several different lossless codecs
+      supported.
+
+      The following systems are supported (refer to the emulation module
+      documentation for more details):
+
+      - Apple II/II+
+      - Atari Lynx
+      - Neo Geo Pocket (Color)
+      - WonderSwan
+      - GameBoy (Color)
+      - GameBoy Advance
+      - Nintendo Entertainment System
+      - Super Nintendo Entertainment System/Super Famicom
+      - Virtual Boy
+      - PC Engine/TurboGrafx 16 (CD)
+      - SuperGrafx
+      - PC-FX
+      - Sega Game Gear
+      - Sega Genesis/Megadrive
+      - Sega Master System
+      - Sega Saturn (experimental, x86_64 only)
+      - Sony PlayStation
+    '';
+    homepage = "https://mednafen.github.io/";
+    license = licenses.gpl2;
+    maintainers = with maintainers; [ AndersonTorres ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/mednafen/server.nix b/nixpkgs/pkgs/misc/emulators/mednafen/server.nix
new file mode 100644
index 000000000000..065426255549
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/mednafen/server.nix
@@ -0,0 +1,21 @@
+{ lib, stdenv, fetchurl }:
+
+stdenv.mkDerivation rec {
+  pname = "mednafen-server";
+  version = "0.5.2";
+
+  src = fetchurl {
+    url = "https://mednafen.github.io/releases/files/mednafen-server-${version}.tar.xz";
+    sha256 = "0xm7dj5nwnrsv69r72rcnlw03jm0l8rmrg3s05gjfvxyqmlb36dq";
+  };
+
+  postInstall = "install -m 644 -Dt $out/share/mednafen-server standard.conf";
+
+  meta = with lib; {
+    description = "Netplay server for Mednafen";
+    homepage = "https://mednafen.github.io/";
+    license = licenses.gpl2;
+    maintainers = with maintainers; [ AndersonTorres ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/mednaffe/default.nix b/nixpkgs/pkgs/misc/emulators/mednaffe/default.nix
new file mode 100644
index 000000000000..dbbbe4da5572
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/mednaffe/default.nix
@@ -0,0 +1,43 @@
+{ stdenv
+, lib
+, fetchFromGitHub
+, autoreconfHook
+, pkg-config
+, mednafen
+, gtk2 ? null
+, gtk3 ? null
+, wrapGAppsHook
+}:
+
+stdenv.mkDerivation rec {
+  pname = "mednaffe";
+  version = "0.8.8";
+
+  src = fetchFromGitHub {
+    owner = "AmatCoder";
+    repo = "mednaffe";
+    rev = version;
+    sha256 = "15qk3a3l1phr8bap2ayh3c0vyvw2jwhny1iz1ajq2adyjpm9fhr7";
+  };
+
+  nativeBuildInputs = [ autoreconfHook pkg-config wrapGAppsHook ];
+  buildInputs = [ gtk2 gtk3 mednafen ];
+
+  configureFlags = [ (lib.enableFeature (gtk3 != null) "gtk3") ];
+
+  dontWrapGApps = true;
+
+  postInstall = ''
+    wrapProgram $out/bin/mednaffe \
+      --prefix PATH ':' "${mednafen}/bin" \
+      "''${gappsWrapperArgs[@]}"
+   '';
+
+  meta = with lib; {
+    description = "GTK-based frontend for mednafen emulator";
+    homepage = "https://github.com/AmatCoder/mednaffe";
+    license = licenses.gpl3Plus;
+    maintainers = with maintainers; [ sheenobu yegortimoshenko AndersonTorres ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/melonDS/default.nix b/nixpkgs/pkgs/misc/emulators/melonDS/default.nix
new file mode 100644
index 000000000000..dbf658b8fcea
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/melonDS/default.nix
@@ -0,0 +1,41 @@
+{ lib, stdenv
+, fetchFromGitHub
+, mkDerivation
+, cmake
+, pkg-config
+, SDL2
+, qtbase
+, libpcap
+, libslirp
+, wrapGAppsHook
+}:
+
+mkDerivation rec {
+  pname = "melonDS";
+  version = "0.9";
+
+  src = fetchFromGitHub {
+    owner = "Arisotura";
+    repo = pname;
+    rev = version;
+    sha256 = "0m45m1ch0az8l3d3grjbqvi5vvydbffxwka9w3k3qiia50m7fnph";
+  };
+
+  nativeBuildInputs = [ cmake pkg-config wrapGAppsHook ];
+  buildInputs = [
+    SDL2
+    qtbase
+    libpcap
+    libslirp
+  ];
+
+  cmakeFlags = [ "-UUNIX_PORTABLE" ];
+
+  meta = with lib; {
+    homepage = "http://melonds.kuribo64.net/";
+    description = "Work in progress Nintendo DS emulator";
+    license = licenses.gpl3Plus;
+    maintainers = with maintainers; [ artemist benley shamilton ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/mgba/default.nix b/nixpkgs/pkgs/misc/emulators/mgba/default.nix
new file mode 100644
index 000000000000..032690175189
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/mgba/default.nix
@@ -0,0 +1,62 @@
+{ lib, stdenv, fetchFromGitHub, makeDesktopItem, wrapQtAppsHook, pkg-config
+, cmake, epoxy, libzip, libelf, libedit, ffmpeg_3, SDL2, imagemagick
+, qtbase, qtmultimedia, qttools, minizip }:
+
+let
+  desktopItem = makeDesktopItem {
+    name = "mgba";
+    exec = "mgba-qt";
+    icon = "mgba";
+    comment = "A Game Boy Advance Emulator";
+    desktopName = "mgba";
+    genericName = "Game Boy Advance Emulator";
+    categories = "Game;Emulator;";
+    startupNotify = "false";
+  };
+in stdenv.mkDerivation rec {
+  pname = "mgba";
+  version = "0.8.4";
+
+  src = fetchFromGitHub {
+    owner = "mgba-emu";
+    repo = "mgba";
+    rev = version;
+    sha256 = "0nqj4bnn5c2z1bq4bnbw1wznc0wpmq4sy3w8pipd6n6620b9m4qq";
+  };
+
+  nativeBuildInputs = [ wrapQtAppsHook pkg-config cmake ];
+
+  buildInputs = [
+    epoxy libzip libelf libedit ffmpeg_3 SDL2 imagemagick
+    qtbase qtmultimedia qttools minizip
+  ];
+
+  postInstall = ''
+    cp -r ${desktopItem}/share/applications $out/share
+  '';
+
+  meta = with lib; {
+    homepage = "https://mgba.io";
+    description = "A modern GBA emulator with a focus on accuracy";
+
+    longDescription = ''
+      mGBA is a new Game Boy Advance emulator written in C.
+
+      The project started in April 2013 with the goal of being fast
+      enough to run on lower end hardware than other emulators
+      support, without sacrificing accuracy or portability. Even in
+      the initial version, games generally play without problems. It
+      is loosely based on the previous GBA.js emulator, although very
+      little of GBA.js can still be seen in mGBA.
+
+      Other goals include accurate enough emulation to provide a
+      development environment for homebrew software, a good workflow
+      for tool-assist runners, and a modern feature set for emulators
+      that older emulators may not support.
+    '';
+
+    license = licenses.mpl20;
+    maintainers = with maintainers; [ MP2E AndersonTorres ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/mupen64plus/default.nix b/nixpkgs/pkgs/misc/emulators/mupen64plus/default.nix
new file mode 100644
index 000000000000..f5d17d9d3951
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/mupen64plus/default.nix
@@ -0,0 +1,29 @@
+{lib, stdenv, fetchurl, boost, dash, freetype, libpng, pkg-config, SDL, which, zlib, nasm }:
+
+stdenv.mkDerivation rec {
+  pname = "mupen64plus";
+  version = "2.5.9";
+
+  src = fetchurl {
+    url = "https://github.com/mupen64plus/mupen64plus-core/releases/download/${version}/mupen64plus-bundle-src-${version}.tar.gz";
+    sha256 = "1a21n4gqdvag6krwcjm5bnyw5phrlxw6m0mk73jy53iq03f3s96m";
+  };
+
+  nativeBuildInputs = [ pkg-config nasm ];
+  buildInputs = [ boost dash freetype libpng SDL which zlib ];
+
+  buildPhase = ''
+    dash m64p_build.sh PREFIX="$out" COREDIR="$out/lib/" PLUGINDIR="$out/lib/mupen64plus" SHAREDIR="$out/share/mupen64plus"
+  '';
+  installPhase = ''
+    dash m64p_install.sh DESTDIR="$out" PREFIX=""
+  '';
+
+  meta = with lib; {
+    description = "A Nintendo 64 Emulator";
+    license = licenses.gpl2Plus;
+    homepage = "http://www.mupen64plus.org/";
+    maintainers = [ maintainers.sander ];
+    platforms = [ "x86_64-linux" ];
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/nestopia/build-fix.patch b/nixpkgs/pkgs/misc/emulators/nestopia/build-fix.patch
new file mode 100644
index 000000000000..a7d82ead15ca
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/nestopia/build-fix.patch
@@ -0,0 +1,18 @@
+diff -wbBur rdanbrook-nestopia-f1dde9b/Makefile rdanbrook-nestopia-f1dde9b.my/Makefile
+--- rdanbrook-nestopia-f1dde9b/Makefile	2013-01-20 20:10:25.000000000 +0400
++++ rdanbrook-nestopia-f1dde9b.my/Makefile	2013-01-21 15:18:54.727577673 +0400
+@@ -197,11 +197,11 @@
+ 	install -m 0644 NstDatabase.xml $(DATADIR)
+ 	install -m 0644 source/unix/icons/*.png $(DATADIR)/icons
+ 	install -m 0644 source/unix/icons/*.svg $(DATADIR)/icons
+-	install -m 0644 source/unix/icons/nestopia.svg $(PREFIX)/share/pixmaps
+-	xdg-desktop-menu install --novendor $(DATADIR)/nestopia.desktop
++	install -m 0644 source/unix/icons/nestopia.svg $(PREFIX)/share/pixmaps/nestopia.svg
++	install -Dm0644 $(DATADIR)/nestopia.desktop $(PREFIX)/share/applications/nestopia.desktop
+ 
+ uninstall:
+-	xdg-desktop-menu uninstall $(DATADIR)/nestopia.desktop
++	rm $(PREFIX)/share/applications/nestopia.desktop
+ 	rm $(PREFIX)/share/pixmaps/nestopia.svg
+ 	rm $(BINDIR)/$(BIN)
+ 	rm -rf $(DATADIR)
diff --git a/nixpkgs/pkgs/misc/emulators/nestopia/default.nix b/nixpkgs/pkgs/misc/emulators/nestopia/default.nix
new file mode 100644
index 000000000000..956161209fcb
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/nestopia/default.nix
@@ -0,0 +1,72 @@
+{ lib, stdenv, fetchFromGitHub, pkg-config, SDL2, alsaLib, gtk3
+, makeWrapper, libGLU, libGL, libarchive, libao, unzip, xdg_utils
+, epoxy, gdk-pixbuf, gnome3, wrapGAppsHook
+}:
+
+stdenv.mkDerivation rec {
+  version = "1.47";
+  pname = "nestopia";
+
+  src = fetchFromGitHub {
+    owner = "rdanbrook";
+    repo = "nestopia";
+    rev = version;
+    sha256 = "0frr0gvjh5mxzdhj0ii3sh671slgnzlm8naqlc4h87rx4p4sz2y2";
+  };
+
+  # nondeterministic failures when creating directories
+  enableParallelBuilding = false;
+
+  hardeningDisable = [ "format" ];
+
+  buildInputs = [
+    SDL2
+    alsaLib
+    epoxy
+    gtk3
+    gdk-pixbuf
+    libGLU libGL
+    libarchive
+    libao
+    unzip
+    xdg_utils
+    gnome3.adwaita-icon-theme
+  ];
+
+  nativeBuildInputs = [
+    pkg-config
+    makeWrapper
+    wrapGAppsHook
+  ];
+
+  installPhase = ''
+    mkdir -p $out/{bin,share/nestopia}
+    make install PREFIX=$out
+  '';
+
+  preFixup = ''
+     for f in $out/bin/*; do
+       wrapProgram $f \
+         --prefix XDG_DATA_DIRS : "$GSETTINGS_SCHEMAS_PATH:$out/share"
+     done
+  '';
+
+  patches = [
+    #(fetchpatch {
+    #  url = "https://github.com/rdanbrook/nestopia/commit/f4bc74ac4954328b25e961e7afb7337377084079.patch";
+    #  name = "gcc6.patch";
+    #  sha256 = "1jy0c85xsfk9hrv5a6v0kk48d94864qb62yyni9fp93kyl33y2p4";
+    #})
+    ./gcc6.patch
+    ./build-fix.patch
+  ];
+
+  meta = {
+    homepage = "http://0ldsk00l.ca/nestopia/";
+    description = "NES emulator with a focus on accuracy";
+    license = lib.licenses.gpl2;
+    platforms = lib.platforms.linux;
+    maintainers = with lib.maintainers; [ MP2E ];
+  };
+}
+
diff --git a/nixpkgs/pkgs/misc/emulators/nestopia/gcc6.patch b/nixpkgs/pkgs/misc/emulators/nestopia/gcc6.patch
new file mode 100644
index 000000000000..65dcc72c0c25
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/nestopia/gcc6.patch
@@ -0,0 +1,92 @@
+From f4bc74ac4954328b25e961e7afb7337377084079 Mon Sep 17 00:00:00 2001
+From: David Seifert <soap@gentoo.org>
+Date: Sat, 31 Dec 2016 18:21:18 +0200
+Subject: [PATCH] Fix compiling in C++14 mode
+
+* Left shifting a negative signed is undefined behaviour
+* Fix incorrect printf() specifiers found with -Wformat
+---
+ source/core/NstCore.hpp            | 4 ++--
+ source/unix/gtkui/gtkui.cpp        | 2 +-
+ source/unix/gtkui/gtkui.h          | 1 -
+ source/unix/gtkui/gtkui_cheats.cpp | 8 ++++----
+ source/unix/video.cpp              | 2 +-
+ 5 files changed, 8 insertions(+), 9 deletions(-)
+
+diff --git a/source/core/NstCore.hpp b/source/core/NstCore.hpp
+index 50e20f6..420cc4a 100644
+--- a/source/core/NstCore.hpp
++++ b/source/core/NstCore.hpp
+@@ -279,14 +279,14 @@ namespace Nes
+ 		template<typename T>

+ 		inline long signed_shl(T v,uint c)

+ 		{

+-			enum {NATIVE = T(-7) << 1 == -14};

++			enum {NATIVE = -(T(7) << 1) == -14};

+ 			return Helper::ShiftSigned<T,NATIVE>::Left( v, c );

+ 		}

+ 

+ 		template<typename T>

+ 		inline long signed_shr(T v,uint c)

+ 		{

+-			enum {NATIVE = T(-7) >> 1 == -4 || T(-7) >> 1 == -3};

++			enum {NATIVE = -(T(7) >> 1) == -4 || -(T(7) >> 1) == -3};

+ 			return Helper::ShiftSigned<T,NATIVE>::Right( v, c );

+ 		}

+ 

+diff --git a/source/unix/gtkui/gtkui.cpp b/source/unix/gtkui/gtkui.cpp
+index 3cfeeab..d4a5e2d 100644
+--- a/source/unix/gtkui/gtkui.cpp
++++ b/source/unix/gtkui/gtkui.cpp
+@@ -438,7 +438,7 @@ void gtkui_message(const char* message) {
+ 				GTK_DIALOG_DESTROY_WITH_PARENT,
+ 				GTK_MESSAGE_INFO,
+ 				GTK_BUTTONS_OK,
+-				message);
++				"%s", message);
+ 	gtk_dialog_run(GTK_DIALOG(messagewindow));
+ 	gtk_widget_destroy(messagewindow);
+ }
+diff --git a/source/unix/gtkui/gtkui_cheats.cpp b/source/unix/gtkui/gtkui_cheats.cpp
+index afc01b0..e7b691a 100644
+--- a/source/unix/gtkui/gtkui_cheats.cpp
++++ b/source/unix/gtkui/gtkui_cheats.cpp
+@@ -373,7 +373,7 @@ void gtkui_cheats_fill_tree(char *filename) {
+ 				else if (node.GetChild(L"address")) { // Raw
+ 					char rawbuf[11];
+ 					snprintf(rawbuf, sizeof(rawbuf),
+-								"%04x %02x %02x",
++								"%04lu %02lu %02lu",
+ 								node.GetChild(L"address").GetUnsignedValue(),
+ 								node.GetChild(L"value").GetUnsignedValue(),
+ 								node.GetChild(L"compare").GetUnsignedValue());
+@@ -545,13 +545,13 @@ gboolean gtkui_cheats_scan_list(GtkTreeModel *model, GtkTreePath *path, GtkTreeI
+ 			int addr, value, compare;
+ 			char buf[5];
+ 			
+-			snprintf(buf, sizeof(buf), "%c%c%c%c\0", rawcode[0], rawcode[1], rawcode[2], rawcode[3]);
++			snprintf(buf, sizeof(buf), "%c%c%c%c", rawcode[0], rawcode[1], rawcode[2], rawcode[3]);
+ 			sscanf(buf, "%x", &addr);
+ 			
+-			snprintf(buf, sizeof(buf), "%c%c\0", rawcode[5], rawcode[6]);
++			snprintf(buf, sizeof(buf), "%c%c", rawcode[5], rawcode[6]);
+ 			sscanf(buf, "%x", &value);
+ 			
+-			snprintf(buf, sizeof(buf), "%c%c\0", rawcode[8], rawcode[9]);
++			snprintf(buf, sizeof(buf), "%c%c", rawcode[8], rawcode[9]);
+ 			sscanf(buf, "%x", &compare);
+ 			
+ 			code.address = addr;
+diff --git a/source/unix/video.cpp b/source/unix/video.cpp
+index 3eff19d..c34bb22 100644
+--- a/source/unix/video.cpp
++++ b/source/unix/video.cpp
+@@ -757,7 +757,7 @@ void video_screenshot(const char* filename) {
+ 	if (filename == NULL) {
+ 		// Set the filename
+ 		char sshotpath[512];
+-		snprintf(sshotpath, sizeof(sshotpath), "%sscreenshots/%s-%d-%d.png", nstpaths.nstdir, nstpaths.gamename, time(NULL), rand() % 899 + 100);
++		snprintf(sshotpath, sizeof(sshotpath), "%sscreenshots/%s-%ld-%d.png", nstpaths.nstdir, nstpaths.gamename, time(NULL), rand() % 899 + 100);
+ 		
+ 		// Save the file
+ 		lodepng_encode32_file(sshotpath, (const unsigned char*)pixels, rendersize.w, rendersize.h);
diff --git a/nixpkgs/pkgs/misc/emulators/np2kai/default.nix b/nixpkgs/pkgs/misc/emulators/np2kai/default.nix
new file mode 100644
index 000000000000..0ed47af8f5bf
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/np2kai/default.nix
@@ -0,0 +1,196 @@
+{ stdenv
+, lib
+, fetchFromGitHub
+, enable16Bit ? true
+, enable32Bit ? true
+
+, enableSDL ? true
+, withSDLVersion ? "2"
+, SDL
+, SDL_ttf
+, SDL_mixer
+, SDL2
+, SDL2_ttf
+, SDL2_mixer
+
+, enableX11 ? stdenv.hostPlatform.isLinux
+, automake
+, autoconf
+, autoconf-archive
+, libtool
+, pkg-config
+, unzip
+, gtk2
+, libusb1
+, libXxf86vm
+, nasm
+, libICE
+, libSM
+
+  # HAXM build succeeds but the binary segfaults, seemingly due to the missing HAXM kernel module
+  # Enable once there is a HAXM kernel module option in NixOS? Or somehow bind it to the system kernel having HAXM?
+  # Or leave it disabled by default?
+  # https://github.com/intel/haxm/blob/master/docs/manual-linux.md
+, enableHAXM ? false
+}:
+
+assert lib.assertMsg (enable16Bit || enable32Bit)
+  "Must enable 16-Bit and/or 32-Bit system variant.";
+assert lib.assertMsg (enableSDL || enableX11)
+  "Must enable SDL and/or X11 graphics interfaces.";
+assert lib.assertOneOf "withSDLVersion" withSDLVersion [ "1" "2" ];
+assert enableHAXM -> (lib.assertMsg enableX11
+  "Must enable X11 graphics interface for HAXM build.");
+let
+  inherit (lib) optional optionals optionalString;
+  inherit (lib.strings) concatStringsSep concatMapStringsSep;
+  isSDL2 = (withSDLVersion == "2");
+  sdlInfix = optionalString isSDL2 "2";
+  sdlDeps1 = [
+    SDL
+    SDL_ttf
+    SDL_mixer
+  ];
+  sdlDeps2 = [
+    SDL2
+    SDL2_ttf
+    SDL2_mixer
+  ];
+  sdlDepsBuildonly = if isSDL2 then sdlDeps1 else sdlDeps2;
+  sdlDepsTarget = if isSDL2 then sdlDeps2 else sdlDeps1;
+  sdlMakefileSuffix =
+    if stdenv.hostPlatform.isWindows then "win"
+    else if stdenv.hostPlatform.isDarwin then "mac"
+    else "unix";
+  sdlMakefiles = concatMapStringsSep " " (x: x + "." + sdlMakefileSuffix)
+    (optionals enable16Bit [
+      "Makefile"
+    ] ++ optionals enable32Bit [
+      "Makefile21"
+    ]);
+  sdlBuildFlags = concatStringsSep " "
+    (optionals enableSDL [
+      "SDL_VERSION=${withSDLVersion}"
+    ]);
+  sdlBins = concatStringsSep " "
+    (optionals enable16Bit [
+      "np2kai"
+    ] ++ optionals enable32Bit [
+      "np21kai"
+    ]);
+  x11ConfigureFlags = concatStringsSep " "
+    ((
+      if ((enableHAXM && (enable16Bit || enable32Bit)) || (enable16Bit && enable32Bit)) then [
+        "--enable-build-all"
+      ] else if enableHAXM then [
+        "--enable-haxm"
+      ] else if enable32Bit then [
+        "--enable-ia32"
+      ] else [ ]
+    ) ++ optionals (!isSDL2) [
+      "--enable-sdl"
+      "--enable-sdlmixer"
+      "--enable-sdlttf"
+
+      "--enable-sdl2=no"
+      "--enable-sdl2mixer=no"
+      "--enable-sdl2ttf=no"
+    ]);
+  x11BuildFlags = concatStringsSep " " [
+    "SDL2_CONFIG=sdl2-config"
+    "SDL_CONFIG=sdl-config"
+    "SDL_CFLAGS=\"$(sdl${sdlInfix}-config --cflags)\""
+    "SDL_LIBS=\"$(sdl${sdlInfix}-config --libs) -lSDL${sdlInfix}_mixer -lSDL${sdlInfix}_ttf\""
+  ];
+  x11Bins = concatStringsSep " "
+    (optionals enable16Bit [
+      "xnp2kai"
+    ] ++ optionals enable32Bit [
+      "xnp21kai"
+    ] ++ optionals enableHAXM [
+      "xnp21kai_haxm"
+    ]);
+in
+stdenv.mkDerivation rec {
+  pname = "np2kai";
+  version = "0.86rev22"; #update src.rev to commit rev accordingly
+
+  src = fetchFromGitHub rec {
+    owner = "AZO234";
+    repo = "NP2kai";
+    rev = "4a317747724669343e4c33ebdd34783fb7043221";
+    sha256 = "0kxysxhx6jyk82mx30ni0ydzmwdcbnlxlnarrlq018rsnwb4md72";
+  };
+
+  configurePhase = ''
+    export GIT_VERSION=${builtins.substring 0 7 src.rev}
+    buildFlags="$buildFlags ''${enableParallelBuilding:+-j$NIX_BUILD_CORES -l$NIX_BUILD_CORES}"
+  '' + optionalString enableX11 ''
+    cd x11
+    substituteInPlace Makefile.am \
+      --replace 'GIT_VERSION :=' 'GIT_VERSION ?='
+    ./autogen.sh ${x11ConfigureFlags}
+    ./configure ${x11ConfigureFlags}
+    cd ..
+  '';
+
+  nativeBuildInputs = sdlDepsBuildonly
+    ++ optionals enableX11 [
+    automake
+    autoconf
+    autoconf-archive
+    libtool
+    pkg-config
+    unzip
+    nasm
+  ];
+
+  buildInputs = sdlDepsTarget
+    ++ optionals enableX11 [
+    gtk2
+    libICE
+    libSM
+    libusb1
+    libXxf86vm
+  ];
+
+  enableParallelBuilding = true;
+
+  buildPhase = optionalString enableSDL ''
+    cd sdl2
+    for mkfile in ${sdlMakefiles}; do
+      substituteInPlace $mkfile \
+        --replace 'GIT_VERSION :=' 'GIT_VERSION ?='
+      echo make -f $mkfile $buildFlags ${sdlBuildFlags} clean
+      make -f $mkfile $buildFlags ${sdlBuildFlags} clean
+      make -f $mkfile $buildFlags ${sdlBuildFlags}
+    done
+    cd ..
+  '' + optionalString enableX11 ''
+    cd x11
+    make $buildFlags ${x11BuildFlags}
+    cd ..
+  '';
+
+  installPhase = optionalString enableSDL ''
+    cd sdl2
+    for emu in ${sdlBins}; do
+      install -D -m 755 $emu $out/bin/$emu
+    done
+    cd ..
+  '' + optionalString enableX11 ''
+    cd x11
+    for emu in ${x11Bins}; do
+      install -D -m 755 $emu $out/bin/$emu
+    done
+    cd ..
+  '';
+
+  meta = with lib; {
+    description = "A PC-9801 series emulator";
+    homepage = "https://github.com/AZO234/NP2kai";
+    license = licenses.mit;
+    maintainers = with maintainers; [ OPNA2608 ];
+    platforms = platforms.x86;
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/oberon-risc-emu/default.nix b/nixpkgs/pkgs/misc/emulators/oberon-risc-emu/default.nix
new file mode 100644
index 000000000000..749e3549bf80
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/oberon-risc-emu/default.nix
@@ -0,0 +1,27 @@
+{ lib, stdenv, fetchFromGitHub, SDL2 }:
+
+stdenv.mkDerivation {
+  pname = "oberon-risc-emu";
+  version = "unstable-2020-08-18";
+
+  src = fetchFromGitHub {
+    owner = "pdewacht";
+    repo = "oberon-risc-emu";
+    rev = "26c8ac5737c71811803c87ad51f1f0d6e62e71fe";
+    sha256 = "1iriix3cfcpbkjb5xjb4ysh592xppgprwzp3b6qhwcx44g7kdvxq";
+  };
+
+  buildInputs = [ SDL2 ];
+
+  installPhase = ''
+    mkdir -p $out/bin
+    mv risc $out/bin
+  '';
+
+  meta = with lib; {
+    homepage    = "https://github.com/pdewacht/oberon-risc-emu/";
+    description = "Emulator for the Oberon RISC machine";
+    license     = licenses.isc;
+    maintainers = with maintainers; [ siraben ];
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/openmsx/custom-nix.mk b/nixpkgs/pkgs/misc/emulators/openmsx/custom-nix.mk
new file mode 100644
index 000000000000..9098762e40d5
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/openmsx/custom-nix.mk
@@ -0,0 +1,9 @@
+# This file substitutes $sourceRoot/build/custom.mk
+
+VERSION_EXEC:=false
+SYMLINK_FOR_BINARY:=false
+INSTALL_CONTRIB:=true
+INSTALL_BASE:=${out}
+INSTALL_DOC_DIR:=${INSTALL_BASE}/share/doc/openmsx
+INSTALL_SHARE_DIR:=${INSTALL_BASE}/share/openmsx
+INSTALL_BINARY_DIR:=${INSTALL_BASE}/bin
diff --git a/nixpkgs/pkgs/misc/emulators/openmsx/default.nix b/nixpkgs/pkgs/misc/emulators/openmsx/default.nix
new file mode 100644
index 000000000000..d34a921e1773
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/openmsx/default.nix
@@ -0,0 +1,48 @@
+{ lib, stdenv, fetchFromGitHub, pkg-config
+, python
+, alsaLib, glew, libGL, libpng
+, libogg, libtheora, libvorbis
+, SDL2, SDL2_image, SDL2_ttf
+, freetype, tcl, zlib
+}:
+
+stdenv.mkDerivation rec {
+  pname = "openmsx";
+  version = "16.0";
+
+  src = fetchFromGitHub {
+    owner = "openMSX";
+    repo = "openMSX";
+    rev = "RELEASE_${builtins.replaceStrings ["."] ["_"] version}";
+    sha256 = "04sphn9ph378r0qv881riv90cgz58650jcqcwmi1mv6gbcb3img5";
+    fetchSubmodules = true;
+  };
+
+  nativeBuildInputs = [ pkg-config python ];
+
+  buildInputs = [ alsaLib glew libGL libpng
+    libogg libtheora libvorbis freetype
+    SDL2 SDL2_image SDL2_ttf tcl zlib ];
+
+  postPatch = ''
+    cp ${./custom-nix.mk} build/custom.mk
+  '';
+
+  dontAddPrefix = true;
+
+  # Many thanks @mthuurne from OpenMSX project
+  # for providing support to Nixpkgs :)
+  TCL_CONFIG="${tcl}/lib/";
+
+  meta = with lib;{
+    description = "The MSX emulator that aims for perfection";
+    longDescription = ''
+      OpenMSX is an emulator for the MSX home computer system. Its goal is
+      to emulate all aspects of the MSX with 100% accuracy.
+    '';
+    homepage = "https://openmsx.org";
+    maintainers = with maintainers; [ AndersonTorres ];
+    platforms = platforms.unix;
+    license = with licenses; [ bsd2 boost gpl2 ];
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/pcem/default.nix b/nixpkgs/pkgs/misc/emulators/pcem/default.nix
new file mode 100644
index 000000000000..6e7e3bc6379c
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/pcem/default.nix
@@ -0,0 +1,29 @@
+{ stdenv, lib, fetchzip, wxGTK31, coreutils, SDL2, openal, alsaLib, pkg-config
+, autoreconfHook, withNetworking ? true, withALSA ? true }:
+
+stdenv.mkDerivation rec {
+  pname = "pcem";
+  version = "17";
+
+  src = fetchzip {
+    url = "https://pcem-emulator.co.uk/files/PCemV${version}Linux.tar.gz";
+    stripRoot = false;
+    sha256 = "067pbnc15h6a4pnnym82klr1w8qwfm6p0pkx93gx06wvwqsxvbdv";
+  };
+
+  nativeBuildInputs = [ autoreconfHook pkg-config ];
+  buildInputs = [ wxGTK31 coreutils SDL2 openal ]
+    ++ lib.optional withALSA alsaLib;
+
+  configureFlags = [ "--enable-release-build" ]
+    ++ lib.optional withNetworking "--enable-networking"
+    ++ lib.optional withALSA "--enable-alsa";
+
+  meta = with lib; {
+    description = "Emulator for IBM PC computers and clones";
+    homepage = "https://pcem-emulator.co.uk/";
+    license = licenses.gpl2Only;
+    maintainers = [ maintainers.terin ];
+    platforms = platforms.linux ++ platforms.windows;
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/pcsx2/default.nix b/nixpkgs/pkgs/misc/emulators/pcsx2/default.nix
new file mode 100644
index 000000000000..7f46d9a0034d
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/pcsx2/default.nix
@@ -0,0 +1,113 @@
+{ alsaLib
+, cmake
+, fetchFromGitHub
+, fmt
+, gcc-unwrapped
+, gettext
+, glib
+, gtk3
+, harfbuzz
+, libaio
+, libpcap
+, libpng
+, libpulseaudio
+, libsamplerate
+, libxml2
+, makeWrapper
+, perl
+, pkg-config
+, portaudio
+, SDL2
+, soundtouch
+, lib, stdenv
+, udev
+, wrapGAppsHook
+, wxGTK
+, zlib
+}:
+
+stdenv.mkDerivation {
+  pname = "pcsx2";
+  version = "unstable-2020-11-13";
+
+  src = fetchFromGitHub {
+    owner = "PCSX2";
+    repo = "pcsx2";
+    fetchSubmodules = true;
+    rev = "319287dbe552c8405720b25dfdf5fa518deeee0b";
+    sha256 = "1kswc8vw9hbv2nigp8cxrgf2s0ik7p4i203cbqci8zjmnkaqpsai";
+  };
+
+  cmakeFlags = [
+    "-DCMAKE_INSTALL_PREFIX=${placeholder "out"}"
+    "-DDISABLE_ADVANCE_SIMD=TRUE"
+    "-DDISABLE_PCSX2_WRAPPER=TRUE"
+    "-DDOC_DIR=${placeholder "out"}/share/doc/pcsx2"
+    "-DGAMEINDEX_DIR=${placeholder "out"}/share/pcsx2"
+    "-DGLSL_SHADER_DIR=${placeholder "out"}/share/pcsx2"
+    "-DGTK3_API=TRUE"
+    "-DPACKAGE_MODE=TRUE"
+    "-DPLUGIN_DIR=${placeholder "out"}/lib/pcsx2"
+    "-DREBUILD_SHADER=TRUE"
+    "-DUSE_LTO=TRUE"
+    "-DwxWidgets_CONFIG_EXECUTABLE=${wxGTK}/bin/wx-config"
+    "-DwxWidgets_INCLUDE_DIRS=${wxGTK}/include"
+    "-DwxWidgets_LIBRARIES=${wxGTK}/lib"
+    "-DXDG_STD=TRUE"
+  ];
+
+  postPatch = ''
+    substituteInPlace cmake/BuildParameters.cmake \
+      --replace /usr/bin/gcc-ar ${gcc-unwrapped}/bin/gcc-ar \
+      --replace /usr/bin/gcc-nm ${gcc-unwrapped}/bin/gcc-nm \
+      --replace /usr/bin/gcc-ranlib ${gcc-unwrapped}/bin/gcc-ranlib
+  '';
+
+  postFixup = ''
+    wrapProgram $out/bin/PCSX2 \
+      --set __GL_THREADED_OPTIMIZATIONS 1
+  '';
+
+  nativeBuildInputs = [ cmake makeWrapper perl pkg-config wrapGAppsHook ];
+
+  buildInputs = [
+    alsaLib
+    fmt
+    gettext
+    glib
+    gtk3
+    harfbuzz
+    libaio
+    libpcap
+    libpng
+    libpulseaudio
+    libsamplerate
+    libxml2
+    portaudio
+    SDL2
+    soundtouch
+    udev
+    wxGTK
+    zlib
+  ];
+
+  meta = with lib; {
+    description = "Playstation 2 emulator";
+    longDescription= ''
+      PCSX2 is an open-source PlayStation 2 (AKA PS2) emulator. Its purpose
+      is to emulate the PS2 hardware, using a combination of MIPS CPU
+      Interpreters, Recompilers and a Virtual Machine which manages hardware
+      states and PS2 system memory. This allows you to play PS2 games on your
+      PC, with many additional features and benefits.
+    '';
+    homepage = "https://pcsx2.net";
+    maintainers = with maintainers; [ hrdinka samuelgrf govanify ];
+
+    # PCSX2's source code is released under LGPLv3+. It However ships
+    # additional data files and code that are licensed differently.
+    # This might be solved in future, for now we should stick with
+    # license.free
+    license = licenses.free;
+    platforms = platforms.x86;
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/pcsxr/default.nix b/nixpkgs/pkgs/misc/emulators/pcsxr/default.nix
new file mode 100644
index 000000000000..e6f0ec477440
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/pcsxr/default.nix
@@ -0,0 +1,87 @@
+{ lib, stdenv, fetchurl, autoreconfHook, intltool, pkg-config, gtk3, SDL2, xorg
+, wrapGAppsHook, libcdio, nasm, ffmpeg, file
+, fetchpatch }:
+
+stdenv.mkDerivation rec {
+  pname = "pcsxr";
+  version = "1.9.94";
+
+  # codeplex does not support direct downloading
+  src = fetchurl {
+    url = "mirror://debian/pool/main/p/pcsxr/pcsxr_${version}.orig.tar.xz";
+    sha256 = "0q7nj0z687lmss7sgr93ij6my4dmhkm2nhjvlwx48dn2lxl6ndla";
+  };
+
+  patches = [
+    ( fetchpatch {
+      url = "https://salsa.debian.org/games-team/pcsxr/raw/315e56d16e36ef3011f72d0fe86190728d2ba596/debian/patches/01_fix-i386-exec-stack.patch";
+      sha256 = "17497wjxd6b92bj458s2769d9bpp68ydbvmfs9gp51yhnq4zl81x";
+    })
+    ( fetchpatch {
+      url = "https://salsa.debian.org/games-team/pcsxr/raw/315e56d16e36ef3011f72d0fe86190728d2ba596/debian/patches/02_disable-ppc-auto-dynarec.patch";
+      sha256 = "0v8n79z034w6cqdrzhgd9fkdpri42mzvkdjm19x4asz94gg2i2kf";
+    })
+    ( fetchpatch {
+      url = "https://salsa.debian.org/games-team/pcsxr/raw/315e56d16e36ef3011f72d0fe86190728d2ba596/debian/patches/03_fix-plugin-dir.patch";
+      sha256 = "0vkl0mv6whqaz79kvvvlmlmjpynyq4lh352j3bbxcr0vjqffxvsy";
+    })
+    ( fetchpatch {
+      url = "https://salsa.debian.org/games-team/pcsxr/raw/315e56d16e36ef3011f72d0fe86190728d2ba596/debian/patches/04_update-homedir-symlinks.patch";
+      sha256 = "18r6n025ybr8fljfsaqm4ap31wp8838j73lrsffi49fkis60dp4j";
+    })
+    ( fetchpatch {
+      url = "https://salsa.debian.org/games-team/pcsxr/raw/315e56d16e36ef3011f72d0fe86190728d2ba596/debian/patches/05_format-security.patch";
+      sha256 = "03m4kfc9bk5669hf7ji1anild08diliapx634f9cigyxh72jcvni";
+    })
+    ( fetchpatch {
+      url = "https://salsa.debian.org/games-team/pcsxr/raw/315e56d16e36ef3011f72d0fe86190728d2ba596/debian/patches/06_warnings.patch";
+      sha256 = "0iz3g9ihnhisfgrzma9l74y4lhh57na9h41bmiam1millb796g71";
+    })
+    ( fetchpatch {
+      url = "https://salsa.debian.org/games-team/pcsxr/raw/315e56d16e36ef3011f72d0fe86190728d2ba596/debian/patches/07_non-linux-ip-addr.patch";
+      sha256 = "14vb9l0l4nzxcymhjjs4q57nmsncmby9qpdr7c19rly5wavm4k77";
+    })
+    ( fetchpatch {
+      url = "https://salsa.debian.org/games-team/pcsxr/raw/315e56d16e36ef3011f72d0fe86190728d2ba596/debian/patches/08_reproducible.patch";
+      sha256 = "1cx9q59drsk9h6l31097lg4aanaj93ysdz5p88pg9c7wvxk1qz06";
+    })
+
+    ./uncompress2.patch
+  ];
+
+  nativeBuildInputs = [ autoreconfHook intltool pkg-config wrapGAppsHook ];
+  buildInputs = [
+    gtk3 SDL2 xorg.libXv xorg.libXtst libcdio nasm ffmpeg file
+  ];
+
+  dynarecTarget =
+   if stdenv.isx86_64 then "x86_64"
+   else if stdenv.isi686 then "x86"
+   else "no"; #debian patch 2 says ppc doesn't work
+
+  configureFlags = [
+    "--enable-opengl"
+    "--enable-ccdda"
+    "--enable-libcdio"
+    "--enable-dynarec=${dynarecTarget}"
+  ];
+
+  postInstall = ''
+    mkdir -p "$out/share/doc/${pname}-${version}"
+    cp README \
+       AUTHORS \
+       doc/keys.txt \
+       doc/tweaks.txt \
+       ChangeLog.df \
+       ChangeLog \
+       "$out/share/doc/${pname}-${version}"
+  '';
+
+  meta = with lib; {
+    description = "Playstation 1 emulator";
+    homepage = "https://pcsxr.codeplex.com/";
+    maintainers = with maintainers; [ rardiol ];
+    license = licenses.gpl2Plus;
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/pcsxr/uncompress2.patch b/nixpkgs/pkgs/misc/emulators/pcsxr/uncompress2.patch
new file mode 100644
index 000000000000..356868ce7a8b
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/pcsxr/uncompress2.patch
@@ -0,0 +1,20 @@
+--- a/libpcsxcore/cdriso.c
++++ b/libpcsxcore/cdriso.c
+@@ -1219,7 +1219,7 @@
+ 	return ret;
+ }
+ 
+-static int uncompress2(void *out, unsigned long *out_size, void *in, unsigned long in_size)
++static int uncompress3(void *out, unsigned long *out_size, void *in, unsigned long in_size)
+ {
+ 	static z_stream z;
+ 	int ret = 0;
+@@ -1298,7 +1298,7 @@
+ 	if (is_compressed) {
+ 		cdbuffer_size_expect = sizeof(compr_img->buff_raw[0]) << compr_img->block_shift;
+ 		cdbuffer_size = cdbuffer_size_expect;
+-		ret = uncompress2(compr_img->buff_raw[0], &cdbuffer_size, compr_img->buff_compressed, size);
++		ret = uncompress3(compr_img->buff_raw[0], &cdbuffer_size, compr_img->buff_compressed, size);
+ 		if (ret != 0) {
+ 			SysPrintf("uncompress failed with %d for block %d, sector %d\n",
+ 					ret, block, sector);
diff --git a/nixpkgs/pkgs/misc/emulators/ppsspp/default.nix b/nixpkgs/pkgs/misc/emulators/ppsspp/default.nix
new file mode 100644
index 000000000000..87dacd46d576
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/ppsspp/default.nix
@@ -0,0 +1,70 @@
+{ SDL2
+, cmake
+, fetchFromGitHub
+, ffmpeg_3
+, glew
+, lib
+, libzip
+, mkDerivation
+, pkg-config
+, python3
+, qtbase
+, qtmultimedia
+, snappy
+, zlib
+}:
+
+mkDerivation rec {
+  pname = "ppsspp";
+  version = "1.10.3";
+
+  src = fetchFromGitHub {
+    owner = "hrydgard";
+    repo = pname;
+    rev = "v${version}";
+    fetchSubmodules = true;
+    sha256 = "sha256-W41Poq5S+opkasIGYo13SQZWQF1HjfFnH7u9DW5HNA0=";
+  };
+
+  postPatch = ''
+    substituteInPlace git-version.cmake --replace unknown ${src.rev}
+    substituteInPlace UI/NativeApp.cpp --replace /usr/share $out/share
+  '';
+
+  nativeBuildInputs = [ cmake pkg-config python3 ];
+
+  buildInputs = [
+    SDL2
+    ffmpeg_3
+    glew
+    libzip
+    qtbase
+    qtmultimedia
+    snappy
+    zlib
+  ];
+
+  cmakeFlags = [
+    "-DOpenGL_GL_PREFERENCE=GLVND"
+    "-DUSE_SYSTEM_FFMPEG=ON"
+    "-DUSE_SYSTEM_LIBZIP=ON"
+    "-DUSE_SYSTEM_SNAPPY=ON"
+    "-DUSING_QT_UI=ON"
+    "-DHEADLESS=OFF"
+  ];
+
+  installPhase = ''
+    mkdir -p $out/share/ppsspp
+    install -Dm555 PPSSPPQt $out/bin/ppsspp
+    mv assets $out/share/ppsspp
+  '';
+
+  meta = with lib; {
+    description = "A HLE Playstation Portable emulator, written in C++";
+    homepage = "https://www.ppsspp.org/";
+    license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ AndersonTorres ];
+    platforms = platforms.linux;
+  };
+}
+# TODO: add SDL headless port
diff --git a/nixpkgs/pkgs/misc/emulators/qmc2/default.nix b/nixpkgs/pkgs/misc/emulators/qmc2/default.nix
new file mode 100644
index 000000000000..6c6a52fc65ca
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/qmc2/default.nix
@@ -0,0 +1,41 @@
+{ lib, stdenv
+, fetchurl, qttools, pkg-config
+, minizip, zlib
+, qtbase, qtsvg, qtmultimedia, qtwebkit, qttranslations, qtxmlpatterns
+, rsync, SDL2, xwininfo
+, util-linux
+, xorg
+}:
+
+stdenv.mkDerivation rec {
+  pname = "qmc2";
+  version = "0.195";
+
+  src = fetchurl {
+      url = "mirror://sourceforge/project/qmc2/qmc2/${version}/${pname}-${version}.tar.gz";
+      sha256 = "1dzmjlfk8pdspns6zg1jmd5fqzg8igd4q38cz4a1vf39lx74svns";
+  };
+
+  preBuild = ''
+    patchShebangs scripts
+  '';
+
+  nativeBuildInputs = [ qttools pkg-config ];
+  buildInputs = [ minizip qtbase qtsvg qtmultimedia qtwebkit
+                  qttranslations qtxmlpatterns rsync SDL2
+                  xwininfo zlib util-linux xorg.libxcb ];
+
+  makeFlags = [ "DESTDIR=$(out)"
+                "PREFIX=/"
+                "DATADIR=/share/"
+                "SYSCONFDIR=/etc" ];
+
+  meta = with lib; {
+    description = "A Qt frontend for MAME/MESS";
+    homepage = "https://qmc2.batcom-it.net";
+    license = licenses.gpl2;
+    maintainers = [ ];
+    platforms = platforms.linux;
+    broken = true;
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/reicast/default.nix b/nixpkgs/pkgs/misc/emulators/reicast/default.nix
new file mode 100644
index 000000000000..8c0bc30d4384
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/reicast/default.nix
@@ -0,0 +1,52 @@
+{ lib, stdenv
+, fetchFromGitHub
+, cmake
+, pkg-config
+, curl
+, alsaLib
+, libGLU
+, libX11
+, libevdev
+, udev
+, libpulseaudio
+}:
+
+stdenv.mkDerivation rec {
+  pname = "reicast";
+  version = "20.04";
+
+  src = fetchFromGitHub {
+    owner = "reicast";
+    repo = "reicast-emulator";
+    rev = "r${version}";
+    sha256 = "0vz3b1hg1qj6nycnqq5zcpzqpcbxw1c2ffamia5z3x7rapjx5d71";
+  };
+
+  nativeBuildInputs = [ cmake pkg-config ];
+  buildInputs = [
+    curl
+    alsaLib
+    libGLU
+    libX11
+    libevdev
+    udev
+    libpulseaudio
+  ];
+
+  # No rule to make target 'install'
+  installPhase = ''
+    runHook preInstall
+
+    install -D ./reicast $out/bin/reicast
+
+    runHook postInstall
+  '';
+
+  meta = with lib; {
+    homepage = "https://reicast.com/";
+    description = "A multi-platform Sega Dreamcast emulator";
+    license = with licenses; [ bsd3 gpl2Only lgpl2Only ];
+    platforms = ["x86_64-linux" ];
+    maintainers = [ maintainers.ivar ];
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/resim/default.nix b/nixpkgs/pkgs/misc/emulators/resim/default.nix
new file mode 100644
index 000000000000..6e759bd75522
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/resim/default.nix
@@ -0,0 +1,20 @@
+{ fetchFromGitHub, lib, stdenv, cmake, qt4 }:
+
+stdenv.mkDerivation {
+  name = "resim";
+  src = fetchFromGitHub {
+    owner = "itszor";
+    repo = "resim";
+    rev = "cdc7808ceb7ba4ac00d0d08ca646b58615059150";
+    sha256 = "1743lngqxd7ai4k6cd4d1cf9h60z2pnvr2iynfs1zlpcj3w1hx0c";
+  };
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ qt4 ];
+  installPhase = ''
+    mkdir -pv $out/{lib,bin}
+    cp -v libresim/libarmsim.so $out/lib/libarmsim.so
+    cp -v vc4emul/vc4emul $out/bin/vc4emul
+  '';
+
+  meta.license = lib.licenses.mit;
+}
diff --git a/nixpkgs/pkgs/misc/emulators/retroarch/cores.nix b/nixpkgs/pkgs/misc/emulators/retroarch/cores.nix
new file mode 100644
index 000000000000..c1b60ad63b2f
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/retroarch/cores.nix
@@ -0,0 +1,1098 @@
+{ lib, stdenv, fetchgit, fetchFromGitHub, fetchFromGitLab, fetchpatch, cmake, pkg-config, makeWrapper, python27, python37, retroarch
+, alsaLib, fluidsynth, curl, hidapi, libGLU, gettext, glib, gtk2, portaudio, SDL, SDL_net, SDL2, SDL2_image, libGL
+, ffmpeg_3, pcre, libevdev, libpng, libjpeg, libzip, udev, libvorbis, snappy, which, hexdump
+, miniupnpc, sfml, xorg, zlib, nasm, libpcap, boost, icu, openssl
+, buildPackages }:
+
+let
+
+  d2u = lib.replaceChars ["-"] ["_"];
+
+  mkLibRetroCore = { core, src, description, license, broken ? false, ... }@a:
+  lib.makeOverridable stdenv.mkDerivation ((rec {
+
+    name = "libretro-${a.core}-${version}";
+    version = "2020-03-06";
+    inherit (a) src;
+
+    buildInputs = [ zlib ] ++ a.extraBuildInputs or [];
+    nativeBuildInputs = [ makeWrapper ] ++ a.extraNativeBuildInputs or [];
+
+    makefile = "Makefile.libretro";
+    makeFlags = [
+      "platform=${{
+        linux = "unix";
+        darwin = "osx";
+        windows = "win";
+      }.${stdenv.hostPlatform.parsed.kernel.name} or stdenv.hostPlatform.parsed.kernel.name}"
+      "ARCH=${{
+        armv7l = "arm";
+        armv6l = "arm";
+        i686 = "x86";
+      }.${stdenv.hostPlatform.parsed.cpu.name} or stdenv.hostPlatform.parsed.cpu.name}"
+    ] ++ (a.makeFlags or []);
+
+    installPhase = ''
+      COREDIR="$out/lib/retroarch/cores"
+      mkdir -p $out/bin
+      mkdir -p $COREDIR
+      mv ${d2u a.core}_libretro${stdenv.hostPlatform.extensions.sharedLibrary} $COREDIR
+      makeWrapper ${retroarch}/bin/retroarch $out/bin/retroarch-${core} \
+        --add-flags "-L $COREDIR/${d2u core}_libretro${stdenv.hostPlatform.extensions.sharedLibrary} $@"
+    '';
+
+    passthru = {
+      inherit (a) core;
+      libretroCore = "/lib/retroarch/cores";
+    };
+
+    meta = with lib; {
+      inherit (a) description license;
+      broken = a.broken or false;
+      homepage = "https://www.libretro.com/";
+      maintainers = with maintainers; [ edwtjo hrdinka MP2E ];
+      platforms = platforms.unix;
+    };
+  }) // builtins.removeAttrs a ["core" "src" "description" "license" "makeFlags"]);
+
+  fetchRetro = { repo, rev, sha256 }:
+  fetchgit {
+    inherit rev sha256;
+    url = "https://github.com/libretro/${repo}.git";
+    fetchSubmodules = true;
+  };
+
+in with lib.licenses;
+
+{
+
+  atari800 = mkLibRetroCore rec {
+    core = "atari800";
+    src = fetchRetro {
+      repo = "libretro-" + core;
+      rev = "f9bf53b864344b8bbe8d425ed2f3c628eb10519c";
+      sha256 = "0sgk93zs423pwiqzvj0x1gfwcn9gacnlrrdq53ps395k64lig6lk";
+    };
+    description = "Port of Atari800 to libretro";
+    license = gpl2;
+    makefile = "Makefile";
+    makeFlags = [ "GIT_VERSION=" ];
+  };
+
+  beetle-snes = mkLibRetroCore {
+    core = "mednafen-snes";
+    src = fetchRetro {
+      repo = "beetle-bsnes-libretro";
+      rev = "de22d8420ea606f1b2f72afd4dda34619cf2cc20";
+      sha256 = "1nd4f8frmlhp1lyxz9zpxvwwz70x0i0rrp560cn9qlm1jzdv3xvf";
+    };
+    description = "Port of Mednafen's SNES core to libretro";
+    license = gpl2;
+    makefile = "Makefile";
+  };
+
+  beetle-gba = mkLibRetroCore {
+    core = "mednafen-gba";
+    src = fetchRetro {
+      repo = "beetle-gba-libretro";
+      rev = "135afdbb9591655a3e016b75abba07e481f6d406";
+      sha256 = "0fc0x24qn4y7pz3mp1mm1ain31aj9pznp1irr0k7hvazyklzy9g3";
+    };
+    description = "Port of Mednafen's GameBoy Advance core to libretro";
+    license = gpl2;
+    makefile = "Makefile";
+  };
+
+  beetle-lynx = mkLibRetroCore {
+    core = "mednafen-lynx";
+    src = fetchRetro {
+      repo = "beetle-lynx-libretro";
+      rev = "74dde204c0ec6c4bc4cd7821c14548387fbd9ce8";
+      sha256 = "05kwibjr30laalqzazswvmn9smm3mwqsz1i0z1s0pj7idfdhjfw0";
+    };
+    description = "Port of Mednafen's Lynx core to libretro";
+    license = gpl2;
+    makefile = "Makefile";
+  };
+
+  beetle-ngp = mkLibRetroCore {
+    core = "mednafen-ngp";
+    src = fetchRetro {
+      repo = "beetle-ngp-libretro";
+      rev = "6f15532b6ad17a2d5eb9dc8241d6af62416e796b";
+      sha256 = "05r8mk9rc19nzs3gpfsjr6i7pm6xx3gn3b4xs8ab7v4vcmfg4cn2";
+    };
+    description = "Port of Mednafen's NeoGeo Pocket core to libretro";
+    license = gpl2;
+    makefile = "Makefile";
+  };
+
+  beetle-pce-fast = let der = mkLibRetroCore {
+    core = "mednafen-pce-fast";
+    src = fetchRetro {
+      repo = "beetle-pce-fast-libretro";
+      rev = "40a42b7f43f029760c92bf0b2097e7d4b90ed29c";
+      sha256 = "1gr6wg4bd4chm4c39w0c1b5zfzr05zd7234vvlmr1imk0v6m0wj6";
+    };
+    description = "Port of Mednafen's PC Engine core to libretro";
+    license = gpl2;
+    makefile = "Makefile";
+  }; in der.override {
+    name = "beetle-pce-fast-${der.version}";
+  };
+
+  beetle-pcfx = mkLibRetroCore rec {
+    core = "mednafen-pcfx";
+    src = fetchRetro {
+      repo = "beetle-pcfx-libretro";
+      rev = "7bba6699d6f903bd701b0aa525d845de8427fee6";
+      sha256 = "1lh7dh96fyi005fcg3xaf7r4ssgkq840p6anldlqy52vfwmglw3p";
+    };
+    description = "Port of Mednafen's PCFX core to libretro";
+    license = gpl2;
+    makefile = "Makefile";
+  };
+
+  beetle-psx = let der = (mkLibRetroCore {
+    core = "mednafen-psx";
+    src = fetchRetro {
+      repo = "beetle-psx-libretro";
+      rev = "0f1e7e60827cad49ebba628abdc83ad97652ab89";
+      sha256 = "1j92jgddyl970v775d6gyb50l8md6yfym2fpqhfxcr4gj1b4ivwq";
+    };
+    description = "Port of Mednafen's PSX Engine core to libretro";
+    license = gpl2;
+    makefile = "Makefile";
+    makeFlags = [ "HAVE_HW=0" "HAVE_LIGHTREC=1" ];
+  }); in der.override {
+    name = "beetle-psx-${der.version}";
+  };
+
+  beetle-psx-hw = let der = (mkLibRetroCore {
+    core = "mednafen-psx-hw";
+    src = fetchRetro {
+      repo = "beetle-psx-libretro";
+      rev = "0f1e7e60827cad49ebba628abdc83ad97652ab89";
+      sha256 = "1j92jgddyl970v775d6gyb50l8md6yfym2fpqhfxcr4gj1b4ivwq";
+    };
+    description = "Port of Mednafen's PSX Engine (with HW accel) core to libretro";
+    license = gpl2;
+    extraBuildInputs = [ libGL libGLU ];
+    makefile = "Makefile";
+    makeFlags = [ "HAVE_VULKAN=1" "HAVE_OPENGL=1" "HAVE_HW=1" "HAVE_LIGHTREC=1" ];
+  }); in der.override {
+    name = "beetle-psx-hw-${der.version}";
+  };
+
+  beetle-saturn = let der = (mkLibRetroCore {
+    core = "mednafen-saturn";
+    src = fetchRetro {
+      repo = "beetle-saturn-libretro";
+      rev = "8a65943bb7bbc3183eeb0d57c4ac3e663f1bcc11";
+      sha256 = "1f0cd9wmvarsmf4jw0p6h3lbzs6515aja7krrwapja7i4xmgbrnh";
+    };
+    description = "Port of Mednafen's Saturn core to libretro";
+    license = gpl2;
+    makefile = "Makefile";
+    makeFlags = [ "HAVE_HW=0" ];
+    meta.platforms = [ "x86_64-linux" "aarch64-linux" ];
+  }); in der.override {
+    name = "beetle-saturn-${der.version}";
+  };
+
+  beetle-saturn-hw = let der = (mkLibRetroCore {
+    core = "mednafen-saturn-hw";
+    src = fetchRetro {
+      repo = "beetle-saturn-libretro";
+      rev = "8a65943bb7bbc3183eeb0d57c4ac3e663f1bcc11";
+      sha256 = "1f0cd9wmvarsmf4jw0p6h3lbzs6515aja7krrwapja7i4xmgbrnh";
+    };
+    description = "Port of Mednafen's Saturn core to libretro";
+    license = gpl2;
+    extraBuildInputs = [ libGL libGLU ];
+    makefile = "Makefile";
+    makeFlags = [ "HAVE_OPENGL=1" "HAVE_HW=1" ];
+    meta.platforms = [ "x86_64-linux" "aarch64-linux" ];
+  }); in der.override {
+    name = "beetle-saturn-${der.version}";
+  };
+
+  beetle-supergrafx = mkLibRetroCore rec {
+    core = "mednafen-supergrafx";
+    src = fetchRetro {
+      repo = "beetle-supergrafx-libretro";
+      rev = "fadef23d59fa5ec17bc99e1e722cfd9e10535695";
+      sha256 = "15rm7p5q38qy3xpyvamhphjnna8h91fsbcqnl9vhzx9cmjg0wf54";
+    };
+    description = "Port of Mednafen's SuperGrafx core to libretro";
+    license = gpl2;
+    makefile = "Makefile";
+  };
+
+  beetle-wswan = mkLibRetroCore rec {
+    core = "mednafen-wswan";
+    src = fetchRetro {
+      repo = "beetle-wswan-libretro";
+      rev = "5b03d1b09f70dc208387d3c8b59e12e1f0d2692f";
+      sha256 = "1sm6ww3y9m85lhp74dpxbs05yxdhhqqmj2022j9s0m235z29iygc";
+    };
+    description = "Port of Mednafen's WonderSwan core to libretro";
+    license = gpl2;
+    makefile = "Makefile";
+  };
+
+  beetle-vb = mkLibRetroCore rec {
+    core = "mednafen-vb";
+    src = fetchRetro {
+      repo = "beetle-vb-libretro";
+      rev = "9a4e604a7320a3c6ed30601989fe0bc417fa9ad3";
+      sha256 = "1gallwbqxn5qbmwxr1vxb41nncksai4rxc739a7vqvp65k5kl0qp";
+    };
+    description = "Port of Mednafen's VirtualBoy core to libretro";
+    license = gpl2;
+    makefile = "Makefile";
+  };
+
+  bluemsx = mkLibRetroCore rec {
+    core = "bluemsx";
+    src = fetchRetro {
+      repo = core + "-libretro";
+      rev = "7a1d40e750860580ab7cc21fbc244b5bc6db6586";
+      sha256 = "05hnkyr47djccspr8v438zimdfsgym7v0jn1hwpkqc4i5zf70981";
+    };
+    description = "Port of BlueMSX to libretro";
+    license = gpl2;
+  };
+
+  bsnes-mercury = let bname = "bsnes-mercury"; in mkLibRetroCore {
+    core = bname + "-accuracy";
+    src = fetchRetro {
+      repo = bname;
+      rev = "4a382621da58ae6da850f1bb003ace8b5f67968c";
+      sha256 = "0z8psz24nx8497vpk2wya9vs451rzzw915lkw3qiq9bzlzg9r2wv";
+    };
+    description = "Fork of bsnes with HLE DSP emulation restored";
+    license = gpl3;
+    makefile = "Makefile";
+    postBuild = "cd out";
+  };
+
+  citra = mkLibRetroCore rec {
+    core = "citra";
+    src = fetchgit {
+      url = "https://github.com/libretro/citra.git";
+      rev = "84f31e95160b029e6d614053705054ed6a34bb38";
+      sha256 = "0gkgxpwrh0q098cpx56hprvmazi5qi448c23svwa8ar1myh8p248";
+      fetchSubmodules = true;
+      deepClone = true;
+    };
+    description = "Port of Citra to libretro";
+    license = gpl2Plus;
+    extraNativeBuildInputs = [ cmake pkg-config ];
+    extraBuildInputs = [ libGLU libGL boost ];
+    makefile = "Makefile";
+    cmakeFlags = [
+      "-DENABLE_LIBRETRO=ON"
+      "-DENABLE_QT=OFF"
+      "-DENABLE_SDL2=OFF"
+      "-DENABLE_WEB_SERVICE=OFF"
+      "-DENABLE_DISCORD_PRESENCE=OFF"
+    ];
+    preConfigure = "sed -e '77d' -i externals/cmake-modules/GetGitRevisionDescription.cmake";
+    postBuild = "cd src/citra_libretro";
+  };
+
+  desmume = mkLibRetroCore rec {
+    core = "desmume";
+    src = fetchRetro {
+      repo = core;
+      rev = "e8cf461f83eebb195f09e70090f57b07d1bcdd9f";
+      sha256 = "0rc8s5226wn39jqs5yxi30jc1snc0p106sfym7kgi98hy5na8yab";
+    };
+    description = "libretro wrapper for desmume NDS emulator";
+    license = gpl2;
+    extraBuildInputs = [ libpcap libGLU libGL xorg.libX11 ];
+    preBuild = "cd desmume/src/frontend/libretro";
+    makeFlags = lib.optional stdenv.hostPlatform.isAarch32 "platform=armv-unix"
+             ++ lib.optional (!stdenv.hostPlatform.isx86) "DESMUME_JIT=0";
+  };
+
+  desmume2015 = mkLibRetroCore rec {
+    core = "desmume2015";
+    src = fetchRetro {
+      repo = core;
+      rev = "93d5789d60f82436e20ccad05ce9cb43c6e3656e";
+      sha256 = "12nii2pbnqgh7f7jkphbwjpr2hiy2mzbwpas3xyhpf9wpy3qiasg";
+    };
+    description = "libretro wrapper for desmume NDS emulator from 2015";
+    license = gpl2;
+    extraBuildInputs = [ libpcap libGLU libGL xorg.libX11 ];
+    makeFlags = lib.optional stdenv.hostPlatform.isAarch32 "platform=armv-unix"
+             ++ lib.optional (!stdenv.hostPlatform.isx86) "DESMUME_JIT=0";
+    preBuild = "cd desmume";
+  };
+
+  dolphin = mkLibRetroCore {
+    core = "dolphin";
+    src = fetchRetro {
+      repo = "dolphin";
+      rev = "1fbd59911d1b718c142d6448dee3ede98152e395";
+      sha256 = "1rymsvs034l1hbxc3w8zi9lhmgka2qaj3jynjy152dccd480nnd4";
+    };
+    description = "Port of Dolphin to libretro";
+    license = gpl2Plus;
+
+    extraNativeBuildInputs = [ cmake curl pkg-config ];
+    extraBuildInputs = [
+      libGLU libGL pcre sfml
+      gettext hidapi
+      libevdev udev
+    ] ++ (with xorg; [ libSM libX11 libXi libpthreadstubs libxcb xcbutil libXext libXrandr libXinerama libXxf86vm ]);
+    makefile = "Makefile";
+    cmakeFlags = [
+      "-DCMAKE_BUILD_TYPE=Release"
+      "-DLIBRETRO=ON"
+      "-DLIBRETRO_STATIC=1"
+      "-DENABLE_QT=OFF"
+      "-DENABLE_LTO=OFF"
+      "-DUSE_UPNP=OFF"
+      "-DUSE_DISCORD_PRESENCE=OFF"
+    ];
+    dontUseCmakeBuildDir = true;
+  };
+
+  dosbox = mkLibRetroCore rec {
+    core = "dosbox";
+    src = fetchRetro {
+      repo = core + "-libretro";
+      rev = "e4ed503b14ed59d5d745396ef1cc7d52cf912328";
+      sha256 = "13bx0ln9hwn6hy4sv0ivqmjgjbfq8svx15dsa24hwd8lkf0kakl4";
+    };
+    description = "Port of DOSBox to libretro";
+    license = gpl2;
+  };
+
+  eightyone = mkLibRetroCore rec {
+    core = "81";
+    src = fetchRetro {
+      repo = core + "-libretro";
+      rev = "4352130bd2363954262a804b086f86b9d13d97f9";
+      sha256 = "057ynnv85imjqhgixrx7p28wn42v88vsm3fc1lp3mpcfi2bk266h";
+    };
+    description = "Port of EightyOne to libretro";
+    license = gpl3;
+  };
+
+  fbalpha2012 = mkLibRetroCore rec {
+    core = "fbalpha2012";
+    src = fetchRetro {
+      repo = core;
+      rev = "fa97cd2784a337f8ac774c2ce8a136aee69b5f43";
+      sha256 = "1i75k0r6838hl77bjjmzvan33ka5qjrdpirmclzj20g5j97lmas7";
+    };
+    description = "Port of Final Burn Alpha ~2012 to libretro";
+    license = "Non-commercial";
+    makefile = "makefile.libretro";
+    preBuild = "cd svn-current/trunk";
+  };
+
+  fbneo = mkLibRetroCore rec {
+    core = "fbneo";
+    src = fetchRetro {
+      repo = core;
+      rev = "cf43fdb1755f9f5c886266e86ba40d339bc8f5d7";
+      sha256 = "13g3c6mbwhcf0rp95ga4klszh8dab2d4ahh2vzzlmd57r69lf2lv";
+    };
+    description = "Port of FBNeo to libretro";
+    license = "Non-commercial";
+    makefile = "Makefile";
+    postPatch = ''
+      sed -i -e 's:-Wall:-Wall -Wno-format-security:g' src/burner/libretro/Makefile
+    '';
+    preBuild = "cd src/burner/libretro";
+    makeFlags = [ "USE_EXPERIMENTAL_FLAGS=1" ];
+  };
+
+  fceumm = mkLibRetroCore rec {
+    core = "fceumm";
+    src = fetchRetro {
+      repo = "libretro-" + core;
+      rev = "9ed22e5a9a1360a7f599a64283af9fe24b858e3d";
+      sha256 = "0rz6iy281jpybmsz5rh06k5xvmd9id9w2q2gd0qdv9a2ylwv7s2j";
+    };
+    description = "FCEUmm libretro port";
+    license = gpl2;
+  };
+
+  flycast = mkLibRetroCore rec {
+    core = "flycast";
+    src = fetchRetro {
+      repo = core;
+      rev = "b12f3726d9093acb4e441b1cdcf6cd11403c8644";
+      sha256 = "0nczjhdqr7svq9aflczf7rwz64bih1wqy9q0gyglb55xlslf5jqc";
+    };
+    description = "Flycast libretro port";
+    license = gpl2;
+    extraBuildInputs = [ libGL libGLU ];
+    makefile = "Makefile";
+    makeFlags = lib.optional stdenv.hostPlatform.isAarch64 [ "platform=arm64" ];
+    meta.platforms = [ "aarch64-linux" "x86_64-linux" ];
+  };
+
+  fmsx = mkLibRetroCore rec {
+    core = "fmsx";
+    src = fetchRetro {
+      repo = core + "-libretro";
+      rev = "3de916bbf15062de1ab322432d38a1fee29d5e68";
+      sha256 = "1krr4lmdiv0d7bxk37fqz5y412znb5bmxapv9g7ci6fp87sr69jq";
+    };
+    description = "FMSX libretro port";
+    license = "Non-commercial";
+    makefile = "Makefile";
+  };
+
+  freeintv = mkLibRetroCore rec {
+    core = "freeintv";
+    src = fetchRetro {
+      repo = core;
+      rev = "45030e10cc1a50cf7a80c5d921aa8cba0aeaca91";
+      sha256 = "10lngk3p012bgrg752426701hfzsiy359h8i0vzsa64pgyjbqlag";
+    };
+    description = "FreeIntv libretro port";
+    license = gpl3;
+    makefile = "Makefile";
+  };
+
+  gambatte = mkLibRetroCore rec {
+    core = "gambatte";
+    src = fetchRetro {
+      repo = core + "-libretro";
+      rev = "132f36e990dfc6effdafa6cf261373432464f9bf";
+      sha256 = "19w5k9yc1cl99c5hiqbp6j54g6z06xcblpvd3x6nmhxij81yqxy7";
+    };
+    description = "Gambatte libretro port";
+    license = gpl2;
+  };
+
+  genesis-plus-gx = mkLibRetroCore {
+    core = "genesis-plus-gx";
+    src = fetchRetro {
+      repo = "Genesis-Plus-GX";
+      rev = "50551066f71f8a5ea782ea3747891fd6d24ebe67";
+      sha256 = "150lgdrv7idcq7jbd1jj7902rcsyixd7kfjs2m5xdinjvl22kihr";
+    };
+    description = "Enhanced Genesis Plus libretro port";
+    license = "Non-commercial";
+  };
+
+  gpsp = mkLibRetroCore rec {
+    core = "gpsp";
+    src = fetchRetro {
+      repo = core;
+      rev = "3f2f57c982ffead643957db5b26931df4913596f";
+      sha256 = "09fa1c623rmy1w9zx85r75viv8q1vknhbs8fn6xbss9rhpxhivwg";
+    };
+    description = "Port of gpSP to libretro";
+    license = gpl2;
+    makefile = "Makefile";
+  };
+
+  gw = mkLibRetroCore rec {
+    core = "gw";
+    src = fetchRetro {
+      repo = core + "-libretro";
+      rev = "819b1dde560013003eeac86c2069c5be7af25c6d";
+      sha256 = "1jhgfys8hiipvbwq3gc48d7v6wq645d10rbr4w5m6px0fk6csshk";
+    };
+    description = "Port of Game and Watch to libretro";
+    license = lib.licenses.zlib;
+    makefile = "Makefile";
+  };
+
+  handy = mkLibRetroCore rec {
+    core = "handy";
+    src = fetchRetro {
+      repo = "libretro-" + core;
+      rev = "c9fe65d1a2df454ee11404ac27bdc9be319dd9a2";
+      sha256 = "1l1gi8z68mv2cpdy7a6wvhd86q55khj3mv3drf43ak4kj2ij8cvq";
+    };
+    description = "Port of Handy to libretro";
+    license = "Handy-License";
+    makefile = "Makefile";
+  };
+
+  hatari = mkLibRetroCore rec {
+    core = "hatari";
+    src = fetchRetro {
+      repo = core;
+      rev = "ec1b59c4b6c7ca7d0d23d60cfe2cb61911b11173";
+      sha256 = "1pm821s2cz93xr7qx7dv0imr44bi4pvdvlnjl486p83vff9yawfg";
+    };
+    description = "Port of Hatari to libretro";
+    license = gpl2;
+    extraBuildInputs = [ SDL zlib ];
+    extraNativeBuildInputs = [ cmake which ];
+    dontUseCmakeConfigure = true;
+    dontConfigure = true;
+    makeFlags = [ "EXTERNAL_ZLIB=1" ];
+    depsBuildBuild = [ buildPackages.stdenv.cc ];
+  };
+
+  mame = mkLibRetroCore {
+    core = "mame";
+    src = fetchRetro {
+      repo = "mame";
+      rev = "ed987ad07964a938351ff3cc1ad42e02ffd2af6d";
+      sha256 = "0qc66mvraffx6ws972skx3wgblich17q6z42798qn13q1a264p4j";
+    };
+    description = "Port of MAME to libretro";
+    license = gpl2Plus;
+
+    extraBuildInputs = [ alsaLib libGLU libGL portaudio python27 xorg.libX11 ];
+    postPatch = ''
+      # Prevent the failure during the parallel building of:
+      # make -C 3rdparty/genie/build/gmake.linux -f genie.make obj/Release/src/host/lua-5.3.0/src/lgc.o
+      mkdir -p 3rdparty/genie/build/gmake.linux/obj/Release/src/host/lua-5.3.0/src
+    '';
+    makefile = "Makefile.libretro";
+  };
+
+  mame2000 = mkLibRetroCore rec {
+    core = "mame2000";
+    src = fetchRetro {
+      repo = core + "-libretro";
+      rev = "e5d4a934c60adc6d42a3f87319312aad89595a15";
+      sha256 = "1zn63yqyrsnsk196v5f3nm7cx41mvsm3icpis1yxbma2r3dk3f89";
+    };
+    description = "Port of MAME ~2000 to libretro";
+    license = gpl2Plus;
+    makefile = "Makefile";
+    makeFlags = lib.optional (!stdenv.hostPlatform.isx86) "IS_X86=0";
+  };
+
+  mame2003 = mkLibRetroCore rec {
+    core = "mame2003";
+    src = fetchRetro {
+      repo = core + "-libretro";
+      rev = "82596014905ad38c80c9eb322ab08c625d1d92cd";
+      sha256 = "17dp2rz6p7q7nr0lajn3vhk9ghngxz16f7c6c87r6wgsy4y3xw0m";
+    };
+    description = "Port of MAME ~2003 to libretro";
+    license = gpl2Plus;
+    makefile = "Makefile";
+  };
+
+  mame2003-plus = mkLibRetroCore rec {
+    core = "mame2003-plus";
+    src = fetchRetro {
+      repo = core + "-libretro";
+      rev = "0134c428b75882aa474f78dbbf2c6ecde49b97b7";
+      sha256 = "0jln2ys6v9hrsrkhqd87jfslwvkca425f40mf7866g6b4pz56mwc";
+    };
+    description = "Port of MAME ~2003+ to libretro";
+    license = gpl2Plus;
+    makefile = "Makefile";
+  };
+
+  mame2010 = mkLibRetroCore rec {
+    core = "mame2010";
+    src = fetchRetro {
+      repo = core + "-libretro";
+      rev = "d3151837758eade73c85c28c20e7d2a8706f30c6";
+      sha256 = "0hj0yhc8zs32fkzn8j341ybhvrsknv0k6x0z2fv3l9ic7swgb93i";
+    };
+    description = "Port of MAME ~2010 to libretro";
+    license = gpl2Plus;
+    makefile = "Makefile";
+    makeFlags = lib.optionals stdenv.hostPlatform.isAarch64 [ "PTR64=1" "ARM_ENABLED=1" "X86_SH2DRC=0" "FORCE_DRC_C_BACKEND=1" ];
+  };
+
+  mame2015 = mkLibRetroCore rec {
+    core = "mame2015";
+    src = fetchRetro {
+      repo = core + "-libretro";
+      rev = "37333ed6fda4c798a1d6b055fe4708f9f0dcf5a7";
+      sha256 = "1asldlj1ywgmhabbhaagagg5hn0359122al07802q3l57ns41l64";
+    };
+    description = "Port of MAME ~2015 to libretro";
+    license = gpl2Plus;
+    extraNativeBuildInputs = [ python27 ];
+    extraBuildInputs = [ alsaLib ];
+    makefile = "Makefile";
+  };
+
+  mame2016 = mkLibRetroCore rec {
+    core = "mame2016";
+    src = fetchRetro {
+      repo = core + "-libretro";
+      rev = "02987af9b81a9c3294af8fb9d5a34f9826a2cf4d";
+      sha256 = "0gl7irmn5d8lk7kf484vgw6kb325fq4ghwsni3il4nm5n2a8yglh";
+    };
+    patches = [
+      (fetchpatch {
+        name = "fix_mame_build_on_make-4.3.patch";
+        url = "https://github.com/libretro/mame2016-libretro/commit/5874fae3d124f5e7c8a91634f5473a8eac902e47.patch";
+        sha256 = "061f1lcm72glksf475ikl8w10pnbgqa7049ylw06nikis2qdjlfn";
+      })
+    ];
+    description = "Port of MAME ~2016 to libretro";
+    license = gpl2Plus;
+    extraNativeBuildInputs = [ python27 ];
+    extraBuildInputs = [ alsaLib ];
+    postPatch = ''
+      # Prevent the failure during the parallel building of:
+      # make -C 3rdparty/genie/build/gmake.linux -f genie.make obj/Release/src/host/lua-5.3.0/src/lgc.o
+      mkdir -p 3rdparty/genie/build/gmake.linux/obj/Release/src/host/lua-5.3.0/src
+    '';
+  };
+
+  mesen = mkLibRetroCore rec {
+    core = "mesen";
+    src = fetchFromGitHub {
+      owner = "SourMesen";
+      repo = core;
+      rev = "cfc5bf6976f62ebd42ea30d5a803c138fc357509";
+      sha256 = "0ihlgvzvni1yqcyi5yxdvg36q20fsqd6n67zavwfb2ph09cqv7kz";
+    };
+    description = "Port of Mesen to libretro";
+    license = gpl3;
+    makefile = "Makefile";
+    preBuild = "cd Libretro";
+  };
+
+  meteor = mkLibRetroCore rec {
+    core = "meteor";
+    src = fetchRetro {
+      repo = core + "-libretro";
+      rev = "3d21e3b5a7596918bee0fcaca5752ae76624c05e";
+      sha256 = "0fghnxxbdrkdz6zswkd06w2r3dvr4ikvcp8jbr7nb9fc5yzn0avw";
+    };
+    description = "Port of Meteor to libretro";
+    license = gpl3;
+    makefile = "Makefile";
+    preBuild = "cd libretro";
+  };
+
+  mgba = mkLibRetroCore rec {
+    core = "mgba";
+    src = fetchRetro {
+      repo = core;
+      rev = "f87f9ef6cb38537e07dcaedeb82aecac6537d42e";
+      sha256 = "0yixvnzgk7qvcfz12r5y8i85czqxbxx6bvl1c7yms8riqn9ssvb7";
+    };
+    description = "Port of mGBA to libretro";
+    license = mpl20;
+  };
+
+  mupen64plus = mkLibRetroCore {
+    core = "mupen64plus-next";
+    src = fetchRetro {
+      repo = "mupen64plus-libretro-nx";
+      rev = "81a58df0263c90b10b7fc11b6deee04d47e3aa40";
+      sha256 = "1brqyrsdzdq53a68q7ph01q2bx5y4m8b3ymvpp25229imm88lgkn";
+    };
+    description = "Libretro port of Mupen64 Plus, GL only";
+    license = gpl2;
+
+    extraBuildInputs = [ libGLU libGL libpng nasm xorg.libX11 ];
+    makefile = "Makefile";
+  };
+
+  neocd = mkLibRetroCore rec {
+    core = "neocd";
+    src = fetchRetro {
+      repo = core + "_libretro";
+      rev = "3825848fe7dd7e0ef859729eefcb29e2ea2956b7";
+      sha256 = "018vfmjsx62zk45yx3pwisp4j133yxjbm7fnwwr244gnyms57711";
+    };
+    description = "NeoCD libretro port";
+    license = gpl3;
+    makefile = "Makefile";
+  };
+
+  nestopia = mkLibRetroCore rec {
+    core = "nestopia";
+    src = fetchRetro {
+      repo = core;
+      rev = "70c53f08c0cc92e90d095d6558ab737ce20431ac";
+      sha256 = "1hlfqml66wy6fn40f1iiy892vq9y9fj20vv3ynd2s3b3qxhwfx73";
+    };
+    description = "Nestopia libretro port";
+    license = gpl2;
+    makefile = "Makefile";
+    preBuild = "cd libretro";
+  };
+
+  np2kai = mkLibRetroCore rec {
+    core = "np2kai";
+    src = fetchFromGitHub rec {
+      owner = "AZO234";
+      repo = "NP2kai";
+      rev = "4a317747724669343e4c33ebdd34783fb7043221";
+      sha256 = "0kxysxhx6jyk82mx30ni0ydzmwdcbnlxlnarrlq018rsnwb4md72";
+    };
+    description = "Neko Project II kai libretro port";
+    license = mit;
+    makefile = "Makefile.libretro";
+    preBuild = ''
+      cd sdl2
+      substituteInPlace ${makefile} \
+        --replace 'GIT_VERSION :=' 'GIT_VERSION ?='
+      export GIT_VERSION=${builtins.substring 0 7 src.rev}
+    '';
+  };
+
+  o2em = mkLibRetroCore rec {
+    core = "o2em";
+    src = fetchRetro {
+      repo = "libretro-" + core;
+      rev = "b23a796dd3490e979ff43710317df6d43bd661e1";
+      sha256 = "1pkbq7nig394zdjdic0mzdsvx8xhzamsh53xh2hzznipyj46b7z0";
+    };
+    description = "Port of O2EM to libretro";
+    license = artistic1;
+    makefile = "Makefile";
+  };
+
+  opera = mkLibRetroCore rec {
+    core = "opera";
+    src = fetchRetro {
+      repo = core + "-libretro";
+      rev = "27bc2653ed469072a6a95102a8212a35fbb1e590";
+      sha256 = "10cxjpsd35rb4fjc5ycs1h00gvshpn2mxxvwb6xzrfrzva0kjw1l";
+    };
+    description = "Opera is a port of 4DO/libfreedo to libretro";
+    license = "Non-commercial";
+    makefile = "Makefile";
+    makeFlags = [ "CC_PREFIX=${stdenv.cc.targetPrefix}" ];
+  };
+
+  parallel-n64 = mkLibRetroCore rec {
+    core = "parallel-n64";
+    src = fetchRetro {
+      repo = core;
+      rev = "8fe07c62a364d0af1e22b7f75e839d42872dae7f";
+      sha256 = "0p3fpldw6w4n4l60bv55c17vhqwq4q39fp36h8iqmnj7c32c61kf";
+    };
+    description = "Parallel Mupen64plus rewrite for libretro.";
+    license = gpl2;
+    extraBuildInputs = [ libGLU libGL libpng ];
+    makefile = "Makefile";
+    postPatch = lib.optionalString stdenv.hostPlatform.isAarch64 ''
+      sed -i -e '1 i\CPUFLAGS += -DARM_FIX -DNO_ASM -DARM_ASM -DDONT_WANT_ARM_OPTIMIZATIONS -DARM64' Makefile \
+      && sed -i -e 's,CPUFLAGS  :=,,g' Makefile
+    '';
+  };
+
+  pcsx_rearmed = mkLibRetroCore rec {
+    core = "pcsx_rearmed";
+    src = fetchRetro {
+      repo = core;
+      rev = "8fda5dd0e28fe46621fb1ab57781c316143017da";
+      sha256 = "0k371d0xqzqwy8ishvxssgasm36q83qj7ksn2av110n879n4knwb";
+    };
+    description = "Port of PCSX ReARMed with GNU lightning to libretro";
+    license = gpl2;
+    dontConfigure = true;
+  };
+
+  picodrive = mkLibRetroCore rec {
+    core = "picodrive";
+    src = fetchRetro {
+      repo = core;
+      rev = "600894ec6eb657586a972a9ecd268f50907a279c";
+      sha256 = "1bxphwnq4b80ssmairy8sfc5cp4m6jyvrcjcj63q1vk7cs6qls7p";
+    };
+    description = "Fast MegaDrive/MegaCD/32X emulator";
+    license = "MAME";
+
+    extraBuildInputs = [ libpng SDL ];
+    SDL_CONFIG = "${SDL.dev}/bin/sdl-config";
+    dontAddPrefix = true;
+    configurePlatforms = [];
+    makeFlags = lib.optional stdenv.hostPlatform.isAarch64 [ "platform=aarch64" ];
+  };
+
+  play = mkLibRetroCore {
+    core = "play";
+    src = fetchRetro {
+      repo = "play-";
+      rev = "884ae3b96c631f235cd18b2643d1f318fa6951fb";
+      sha256 = "0m9pk20jh4y02visgzfw64bpbw93bzs15x3a3bnd19yivm34dbfc";
+    };
+    description = "Port of Play! to libretro";
+    license = bsd2;
+    extraBuildInputs = [ boost ];
+    extraNativeBuildInputs = [ cmake openssl curl icu libGL libGLU xorg.libX11 ];
+    makefile = "Makefile";
+    cmakeFlags = [ "-DBUILD_PLAY=OFF -DBUILD_LIBRETRO_CORE=ON" ];
+    postBuild = "mv Source/ui_libretro/play_libretro${stdenv.hostPlatform.extensions.sharedLibrary} play_libretro${stdenv.hostPlatform.extensions.sharedLibrary}";
+  };
+
+  ppsspp = mkLibRetroCore {
+    core = "ppsspp";
+    src = fetchgit {
+      url = "https://github.com/hrydgard/ppsspp";
+      rev = "bf1777f7d3702e6a0f71c7ec1fc51976e23c2327";
+      sha256 = "17sym0vk72lzbh9a1501mhw98c78x1gq7k1fpy69nvvb119j37wa";
+    };
+    description = "ppsspp libretro port";
+    license = gpl2;
+    extraNativeBuildInputs = [ cmake pkg-config ];
+    extraBuildInputs = [ libGLU libGL libzip ffmpeg_3 python37 snappy xorg.libX11 ];
+    makefile = "Makefile";
+    cmakeFlags = [ "-DLIBRETRO=ON -DUSE_SYSTEM_FFMPEG=ON -DUSE_SYSTEM_SNAPPY=ON -DUSE_SYSTEM_LIBZIP=ON -DOpenGL_GL_PREFERENCE=GLVND" ];
+    postBuild = "mv lib/ppsspp_libretro${stdenv.hostPlatform.extensions.sharedLibrary} ppsspp_libretro${stdenv.hostPlatform.extensions.sharedLibrary}";
+  };
+
+  prboom = mkLibRetroCore rec {
+    core = "prboom";
+    src = fetchRetro {
+      repo = "libretro-" + core;
+      rev = "991016b3c7a9c8b0e49b2bc9c72f68c60800fc7b";
+      sha256 = "1abv9qgfvh3x84shgyl3y90bjz77mjj17vibag7bg6i8hgjikjgq";
+    };
+    description = "Prboom libretro port";
+    license = gpl2;
+    makefile = "Makefile";
+  };
+
+  prosystem = mkLibRetroCore rec {
+    core = "prosystem";
+    src = fetchRetro {
+      repo = core + "-libretro";
+      rev = "6f7e34aea89db5ba2fbf674e5ff0ad6fc68a198e";
+      sha256 = "0pqkb0f51s8ma0l4m9xk2y85z2kh3fgay9g4g8fingbgqq1klvzs";
+    };
+    description = "Port of ProSystem to libretro";
+    license = gpl2;
+    makefile = "Makefile";
+  };
+
+  quicknes = mkLibRetroCore {
+    core = "quicknes";
+    src = fetchRetro {
+      repo = "QuickNES_Core";
+      rev = "31654810b9ebf8b07f9c4dc27197af7714364ea7";
+      sha256 = "15fr5a9hv7wgndb0fpmr6ws969him41jidzir2ix9xkb0mmvcm86";
+    };
+    description = "QuickNES libretro port";
+    license = lgpl21Plus;
+    makefile = "Makefile";
+  };
+
+  sameboy = mkLibRetroCore rec {
+    core = "sameboy";
+    src = fetchRetro {
+      repo = "sameboy";
+      rev = "c9e547c1063fd62c40a4b7a86e7db99dc9089051";
+      sha256 = "0bff6gicm24d7h270aqvgd8il6mi7j689nj5zl9ij0wc77hrrpmq";
+    };
+    description = "SameBoy libretro port";
+    license = mit;
+    extraNativeBuildInputs = [ which hexdump ];
+    preBuild = "cd libretro";
+    makefile = "Makefile";
+  };
+
+  scummvm = mkLibRetroCore rec {
+    core = "scummvm";
+    src = fetchRetro {
+      repo = core;
+      rev = "de91bf9bcbf4449f91e2f50fde173496a2b52ee0";
+      sha256 = "06h9xaf2b1cjk85nbslpjj0fm9iy9b2lxr1wf3i09hgs4sh6x464";
+    };
+    description = "Libretro port of ScummVM";
+    license = gpl2;
+    extraBuildInputs = [ fluidsynth libjpeg libvorbis libGLU libGL SDL ];
+    makefile = "Makefile";
+    preConfigure = "cd backends/platform/libretro/build";
+  };
+
+  smsplus-gx = mkLibRetroCore rec {
+    core = "smsplus";
+    src = fetchRetro {
+      repo = core + "-gx";
+      rev = "36c82768c03d889f1cf4b66369edac2297acba32";
+      sha256 = "1f9waikyp7kp2abb76wlv9hmf2jpc76zjmfqyc7wk2pc70ljm3l4";
+    };
+    description = "SMS Plus GX libretro port";
+    license = gpl2Plus;
+  };
+
+  snes9x = mkLibRetroCore rec {
+    core = "snes9x";
+    src = fetchFromGitHub {
+      owner = "snes9xgit";
+      repo = core;
+      rev = "6db918cfe32b157239da44096091c212fdfb3b60";
+      sha256 = "0y3jhy50qdhhfglybys9m0fgk9r24ksdcgv5iqpyxy5a4cjvhv8j";
+    };
+    description = "Port of SNES9x git to libretro";
+    license = "Non-commercial";
+    makefile = "Makefile";
+    preBuild = "cd libretro";
+  };
+
+  snes9x2002 = mkLibRetroCore rec {
+    core = "snes9x2002";
+    src = fetchRetro {
+      repo = core;
+      rev = "a869da7f22c63ee1cb316f79c6dd7691a369da3e";
+      sha256 = "11lcwscnxg6sk9as2xlr4nai051qhidbsymyis4nz3r4dmgzf8j8";
+    };
+    description = "Optimized port/rewrite of SNES9x 1.39 to Libretro";
+    license = "Non-commercial";
+    makefile = "Makefile";
+  };
+
+  snes9x2005 = mkLibRetroCore rec {
+    core = "snes9x2005";
+    src = fetchRetro {
+      repo = core;
+      rev = "c216559b9e0dc3d7f059dcf31b813402ad47fea5";
+      sha256 = "19b2rpj6i32c34ryvlna4yca84y5ypza78w4x9l17qlhp021h9pv";
+    };
+    description = "Optimized port/rewrite of SNES9x 1.43 to Libretro";
+    license = "Non-commercial";
+    makefile = "Makefile";
+    makeFlags = [ "USE_BLARGG_APU=1" ];
+    postBuild = "mv snes9x2005_plus_libretro${stdenv.hostPlatform.extensions.sharedLibrary} snes9x2005_libretro${stdenv.hostPlatform.extensions.sharedLibrary}";
+  };
+
+  snes9x2010 = mkLibRetroCore rec {
+    core = "snes9x2010";
+    src = fetchRetro {
+      repo = core;
+      rev = "ba9f2240360f8db270fb6ba5465c79c317070560";
+      sha256 = "00y53sjrsp8sccpp1qqw88iawsz30g6d370cbqcxs4ya1r6awn5x";
+    };
+    description = "Optimized port/rewrite of SNES9x 1.52+ to Libretro";
+    license = "Non-commercial";
+  };
+
+  stella = mkLibRetroCore rec {
+    core = "stella";
+    src = fetchFromGitHub {
+      owner = "stella-emu";
+      repo = core;
+      rev = "506bb0bd0618e676b1959931dcc00a9d0f5f0f3d";
+      sha256 = "09nclx0ksixngnxkkjjcyhf3d0vl4ykm8fx7m307lvag8nxj7z03";
+    };
+    description = "Port of Stella to libretro";
+    license = gpl2;
+    extraBuildInputs = [ libpng pkg-config SDL ];
+    makefile = "Makefile";
+    preBuild = "cd src/libretro";
+    dontConfigure = true;
+  };
+
+  stella2014 = mkLibRetroCore rec {
+    core = "stella2014";
+    src = fetchRetro {
+      repo = core + "-libretro";
+      rev = "fc87f2c78d3b177f4b9b19698557dce452ac3ce7";
+      sha256 = "0yqzavk1w0d0ngpls32c4wlihii97fz2g6zsgadhm48apwjvn3xx";
+    };
+    description = "Port of Stella to libretro";
+    license = gpl2;
+    makefile = "Makefile";
+  };
+
+  tgbdual = mkLibRetroCore rec {
+    core = "tgbdual";
+    src = fetchRetro {
+      repo = core + "-libretro";
+      rev = "9be31d373224cbf288db404afc785df41e61b213";
+      sha256 = "19m3f3hj3jyg711z1xq8qn1hgsr593krl6s6hi0r6vf8p5x0zbzw";
+    };
+    description = "Port of TGBDual to libretro";
+    license = gpl2;
+    makefile = "Makefile";
+  };
+
+  tic80 = mkLibRetroCore {
+    core = "tic80";
+    src = fetchRetro {
+      repo = "tic-80";
+      rev = "f43bad908d5f05f2a66d5cd1d6f21b234d4abd2c";
+      sha256 = "0bp34r8qqyw52alws1z4ib9j7bs4d641q6nvqszd07snp9lpvwym";
+    };
+    description = "Port of TIC-80 to libretro";
+    license = mit;
+    extraNativeBuildInputs = [ cmake pkg-config ];
+    makefile = "Makefile";
+    cmakeFlags = [
+      "-DBUILD_LIBRETRO=ON"
+      "-DBUILD_DEMO_CARTS=OFF"
+      "-DBUILD_PRO=OFF"
+      "-DBUILD_PLAYER=OFF"
+      "-DBUILD_SDL=OFF"
+      "-DBUILD_SOKOL=OFF"
+    ];
+    postBuild = "cd lib";
+  };
+
+  vba-next = mkLibRetroCore rec {
+    core = "vba-next";
+    src = fetchRetro {
+      repo = core;
+      rev = "019132daf41e33a9529036b8728891a221a8ce2e";
+      sha256 = "0hab4rhvvcg30jifd9h9jq5q2vqk2hz5i1q456w6v2d10hl1lf15";
+    };
+    description = "VBA-M libretro port with modifications for speed";
+    license = gpl2;
+  };
+
+  vba-m = mkLibRetroCore rec {
+    core = "vbam";
+    src = fetchRetro {
+      repo = core + "-libretro";
+      rev = "7d88e045a2fe44e56b3f84846beec446b4c4b2d9";
+      sha256 = "04f8adg99a36qkqhij54vkw5z18m5ld33p78lbmv8cxk7k7g7yhy";
+    };
+    description = "vanilla VBA-M libretro port";
+    license = gpl2;
+    makefile = "Makefile";
+    preBuild = "cd src/libretro";
+  };
+
+  vecx = mkLibRetroCore rec {
+    core = "vecx";
+    src = fetchRetro {
+      repo = "libretro-" + core;
+      rev = "321205271b1c6be5dbdb8d309097a5b5c2032dbd";
+      sha256 = "1w54394yhf2yqmq1b8wi5y7lvixc5hpjxpyiancrdbjd0af7pdvd";
+    };
+    description = "Port of Vecx to libretro";
+    license = gpl3;
+  };
+
+  virtualjaguar = mkLibRetroCore rec {
+    core = "virtualjaguar";
+    src = fetchRetro {
+      repo = core + "-libretro";
+      rev = "a162fb75926f5509f187e9bfc69958bced40b0a6";
+      sha256 = "06k8xpn5y9rzmi2lwfw0v9v9pz4wvmpalycc608bw9cl39lmz10h";
+    };
+    description = "Port of VirtualJaguar to libretro";
+    license = gpl3;
+    makefile = "Makefile";
+  };
+
+  yabause = mkLibRetroCore rec {
+    core = "yabause";
+    src = fetchRetro {
+      repo = core;
+      rev = "9be109f9032afa793d2a79b837c4cc232cea5929";
+      sha256 = "0aj862bs4dmnldy62wdssj5l63ibfkbzqvkxcqa3wyvdz4i367jc";
+    };
+    description = "Port of Yabause to libretro";
+    license = gpl2;
+    makefile = "Makefile";
+    # Disable SSE for non-x86. DYNAREC doesn't build on either Aarch64 or x86_64.
+    makeFlags = lib.optional (!stdenv.hostPlatform.isx86) "HAVE_SSE=0";
+    preBuild = "cd yabause/src/libretro";
+  };
+
+}
diff --git a/nixpkgs/pkgs/misc/emulators/retroarch/default.nix b/nixpkgs/pkgs/misc/emulators/retroarch/default.nix
new file mode 100644
index 000000000000..a6ada570a500
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/retroarch/default.nix
@@ -0,0 +1,63 @@
+{ lib, stdenv, fetchFromGitHub, which, pkg-config, makeWrapper
+, ffmpeg_3, libGLU, libGL, freetype, libxml2, python3
+, libobjc, AppKit, Foundation
+, alsaLib ? null
+, libdrm ? null
+, libpulseaudio ? null
+, libv4l ? null
+, libX11 ? null
+, libXdmcp ? null
+, libXext ? null
+, libXxf86vm ? null
+, mesa ? null
+, SDL2 ? null
+, udev ? null
+, enableNvidiaCgToolkit ? false, nvidia_cg_toolkit ? null
+, withVulkan ? stdenv.isLinux, vulkan-loader ? null
+, fetchurl
+, wayland
+, libxkbcommon
+}:
+
+with lib;
+
+stdenv.mkDerivation rec {
+  pname = "retroarch-bare";
+  version = "1.8.5";
+
+  src = fetchFromGitHub {
+    owner = "libretro";
+    repo = "RetroArch";
+    sha256 = "1pg8j9wvwgrzsv4xdai6i6jgdcc922v0m42rbqxvbghbksrc8la3";
+    rev = "v${version}";
+  };
+
+  nativeBuildInputs = [ pkg-config wayland ]
+                      ++ optional withVulkan makeWrapper;
+
+  buildInputs = [ ffmpeg_3 freetype libxml2 libGLU libGL python3 SDL2 which ]
+                ++ optional enableNvidiaCgToolkit nvidia_cg_toolkit
+                ++ optional withVulkan vulkan-loader
+                ++ optionals stdenv.isDarwin [ libobjc AppKit Foundation ]
+                ++ optionals stdenv.isLinux [ alsaLib libdrm libpulseaudio libv4l libX11
+                                              libXdmcp libXext libXxf86vm mesa udev
+                                              wayland libxkbcommon ];
+
+  enableParallelBuilding = true;
+
+  configureFlags = lib.optionals stdenv.isLinux [ "--enable-kms" "--enable-egl" ];
+
+  postInstall = optionalString withVulkan ''
+    wrapProgram $out/bin/retroarch --prefix LD_LIBRARY_PATH ':' ${vulkan-loader}/lib
+  '';
+
+  preFixup = "rm $out/bin/retroarch-cg2glsl";
+
+  meta = {
+    homepage = "https://libretro.com";
+    description = "Multi-platform emulator frontend for libretro cores";
+    license = licenses.gpl3;
+    platforms = platforms.all;
+    maintainers = with maintainers; [ MP2E edwtjo matthewbauer kolbycrouch ];
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/retroarch/kodi-advanced-launchers.nix b/nixpkgs/pkgs/misc/emulators/retroarch/kodi-advanced-launchers.nix
new file mode 100644
index 000000000000..79dd025cf948
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/retroarch/kodi-advanced-launchers.nix
@@ -0,0 +1,40 @@
+{ stdenv, pkgs, cores, runtimeShell }:
+
+assert cores != [];
+
+with pkgs.lib;
+
+let
+
+  script = exec: ''
+    #!${runtimeShell}
+    nohup sh -c "pkill -SIGTSTP kodi" &
+    # https://forum.kodi.tv/showthread.php?tid=185074&pid=1622750#pid1622750
+    nohup sh -c "sleep 10 && ${exec} '$@' -f;pkill -SIGCONT kodi"
+  '';
+  scriptSh = exec: pkgs.writeScript ("kodi-"+exec.name) (script exec.path);
+  execs = map (core: rec { name = core.core; path = core+"/bin/retroarch-"+name;}) cores;
+
+in
+
+stdenv.mkDerivation {
+  pname = "kodi-retroarch-advanced-launchers";
+  version = "0.2";
+
+  dontBuild = true;
+
+  buildCommand = ''
+    mkdir -p $out/bin
+    ${lib.concatMapStrings (exec: "ln -s ${scriptSh exec} $out/bin/kodi-${exec.name};") execs}
+  '';
+
+  meta = {
+    description = "Kodi retroarch advanced launchers";
+    longDescription = ''
+      These retroarch launchers are intended to be used with
+      advanced (emulation) launcher for Kodi since device input is
+      otherwise caught by both Kodi and the retroarch process.
+    '';
+    license = lib.licenses.gpl3;
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/retroarch/wrapper.nix b/nixpkgs/pkgs/misc/emulators/retroarch/wrapper.nix
new file mode 100644
index 000000000000..08ebf8ea8544
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/retroarch/wrapper.nix
@@ -0,0 +1,37 @@
+{ stdenv, lib, makeWrapper, retroarch, cores }:
+
+stdenv.mkDerivation {
+  pname = "retroarch";
+  version = lib.getVersion retroarch;
+
+  buildInputs = [ makeWrapper ];
+
+  buildCommand = ''
+    mkdir -p $out/lib
+    $(for coreDir in $cores
+    do
+      $(ln -s $coreDir/* $out/lib/.)
+    done)
+
+    ln -s -t $out ${retroarch}/share
+
+    if [ -d ${retroarch}/Applications ]; then
+      ln -s -t $out ${retroarch}/Applications
+    fi
+
+    makeWrapper ${retroarch}/bin/retroarch $out/bin/retroarch \
+      --suffix-each LD_LIBRARY_PATH ':' "$cores" \
+      --add-flags "-L $out/lib/" \
+  '';
+
+  cores = map (x: x + x.libretroCore) cores;
+  preferLocalBuild = true;
+
+  meta = with retroarch.meta; {
+    inherit license homepage platforms maintainers;
+    description = description
+                  + " (with cores: "
+                  + lib.concatStrings (lib.intersperse ", " (map (x: ""+x.name) cores))
+                  + ")";
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/retrofe/default.nix b/nixpkgs/pkgs/misc/emulators/retrofe/default.nix
new file mode 100644
index 000000000000..558b5ca63377
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/retrofe/default.nix
@@ -0,0 +1,78 @@
+{ lib, stdenv, fetchhg, cmake, glib, gst_all_1, makeWrapper, pkg-config
+, python, SDL2, SDL2_image, SDL2_mixer, SDL2_ttf, sqlite, zlib, runtimeShell
+}:
+
+stdenv.mkDerivation {
+  pname = "retrofe";
+  version = "0.6.169";
+
+  src = fetchhg {
+    url = "https://bitbucket.org/teamretro/retrofe";
+    rev = "8793e03";
+    sha256 = "0cvsg07ff0fdqh5zgiv2fs7s6c98hn150kpxmpw5fn6jilaszwkm";
+  };
+
+  nativeBuildInputs = [ cmake makeWrapper pkg-config python ];
+
+  buildInputs = [
+    glib gst_all_1.gstreamer SDL2 SDL2_image SDL2_mixer SDL2_ttf sqlite zlib
+  ] ++ (with gst_all_1; [ gst-libav gst-plugins-base gst-plugins-good ]);
+
+  patches = [ ./include-paths.patch ];
+
+  configurePhase = ''
+    cmake RetroFE/Source -BRetroFE/Build -DCMAKE_BUILD_TYPE=Release \
+      -DVERSION_MAJOR=0 -DVERSION_MINOR=0 -DVERSION_BUILD=0 \
+      -DGSTREAMER_BASE_INCLUDE_DIRS='${gst_all_1.gst-plugins-base.dev}/include/gstreamer-1.0'
+  '';
+
+  buildPhase = ''
+    cmake --build RetroFE/Build
+    python Scripts/Package.py --os=linux --build=full
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin
+    mkdir -p $out/share/retrofe
+    cp -r Artifacts/linux/RetroFE $out/share/retrofe/example
+    mv $out/share/retrofe/example/retrofe $out/bin/
+
+    cat > $out/bin/retrofe-init << EOF
+    #!${runtimeShell}
+
+    echo "This will install retrofe's example files into this directory"
+    echo "Example files location: $out/share/retrofe/example/"
+
+    while true; do
+        read -p "Do you want to proceed? [yn] " yn
+        case \$yn in
+            [Yy]* ) cp -r --no-preserve=all $out/share/retrofe/example/* .; break;;
+            [Nn]* ) exit;;
+            * ) echo "Please answer with yes or no.";;
+        esac
+    done
+    EOF
+
+    chmod +x $out/bin/retrofe-init
+
+    runHook postInstall
+  '';
+
+  # retrofe will look for config files in its install path ($out/bin).
+  # When set it will use $RETROFE_PATH instead. Sadly this behaviour isn't
+  # documented well. To make it behave more like as expected it's set to
+  # $PWD by default here.
+  postInstall = ''
+    wrapProgram "$out/bin/retrofe" \
+      --prefix GST_PLUGIN_PATH : "$GST_PLUGIN_SYSTEM_PATH_1_0" \
+      --run 'export RETROFE_PATH=''${RETROFE_PATH:-$PWD}'
+  '';
+
+  meta = with lib; {
+    description = "A frontend for arcade cabinets and media PCs";
+    homepage = "http://retrofe.com";
+    license = licenses.gpl3Plus;
+    maintainers = with maintainers; [ hrdinka ];
+    platforms = with platforms; linux;
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/retrofe/include-paths.patch b/nixpkgs/pkgs/misc/emulators/retrofe/include-paths.patch
new file mode 100644
index 000000000000..02eef2594ea6
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/retrofe/include-paths.patch
@@ -0,0 +1,11 @@
+diff -ur RetroFE.1/RetroFE/Source/CMakeLists.txt RetroFE.2/RetroFE/Source/CMakeLists.txt
+--- RetroFE.1/RetroFE/Source/CMakeLists.txt	2016-02-21 14:52:36.726070602 +0100
++++ RetroFE.2/RetroFE/Source/CMakeLists.txt	2016-02-21 14:38:43.036249029 +0100
+@@ -59,6 +59,7 @@
+ set(RETROFE_INCLUDE_DIRS

+ 	"${GLIB2_INCLUDE_DIRS}"

+ 	"${GSTREAMER_INCLUDE_DIRS}"

++	"${GSTREAMER_BASE_INCLUDE_DIRS}"

+ 	"${SDL2_INCLUDE_DIRS}"

+ 	"${SDL2_IMAGE_INCLUDE_DIRS}"

+ 	"${SDL2_MIXER_INCLUDE_DIRS}"

diff --git a/nixpkgs/pkgs/misc/emulators/rpcs3/default.nix b/nixpkgs/pkgs/misc/emulators/rpcs3/default.nix
new file mode 100644
index 000000000000..ecda439e7ab7
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/rpcs3/default.nix
@@ -0,0 +1,54 @@
+{ mkDerivation, lib, fetchgit, cmake, pkg-config, git
+, qtbase, qtquickcontrols, openal, glew, vulkan-headers, vulkan-loader, libpng
+, ffmpeg, libevdev, python3
+, pulseaudioSupport ? true, libpulseaudio
+, waylandSupport ? true, wayland
+, alsaSupport ? true, alsaLib
+}:
+
+let
+  majorVersion = "0.0.12";
+  gitVersion = "10811-a86a3d2fe"; # echo $(git rev-list HEAD --count)-$(git rev-parse --short HEAD)
+in
+mkDerivation {
+  pname = "rpcs3";
+  version = "${majorVersion}-${gitVersion}";
+
+  src = fetchgit {
+    url = "https://github.com/RPCS3/rpcs3";
+    rev = "v${majorVersion}";
+    sha256 = "182rkmbnnlcfzam4bwas7lwv10vqiqvvaw3299a3hariacd7rq8x";
+  };
+
+  preConfigure = ''
+    cat > ./rpcs3/git-version.h <<EOF
+    #define RPCS3_GIT_VERSION "${gitVersion}"
+    #define RPCS3_GIT_FULL_BRANCH "RPCS3/rpcs3/master"
+    #define RPCS3_GIT_BRANCH "HEAD"
+    #define RPCS3_GIT_VERSION_NO_UPDATE 1
+    EOF
+  '';
+
+  cmakeFlags = [
+    "-DUSE_SYSTEM_LIBPNG=ON"
+    "-DUSE_SYSTEM_FFMPEG=ON"
+    "-DUSE_NATIVE_INSTRUCTIONS=OFF"
+  ];
+
+  nativeBuildInputs = [ cmake pkg-config git ];
+
+  buildInputs = [
+    qtbase qtquickcontrols openal glew vulkan-headers vulkan-loader libpng ffmpeg
+    libevdev python3
+  ] ++ lib.optional pulseaudioSupport libpulseaudio
+    ++ lib.optional alsaSupport alsaLib
+    ++ lib.optional waylandSupport wayland;
+
+  meta = with lib; {
+    description = "PS3 emulator/debugger";
+    homepage = "https://rpcs3.net/";
+    maintainers = with maintainers; [ abbradar neonfuz ilian ];
+    license = licenses.gpl2;
+    platforms = [ "x86_64-linux" ];
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/ruffle/default.nix b/nixpkgs/pkgs/misc/emulators/ruffle/default.nix
new file mode 100644
index 000000000000..475e54076fc2
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/ruffle/default.nix
@@ -0,0 +1,57 @@
+{ alsaLib
+, fetchFromGitHub
+, makeWrapper
+, openssl
+, pkg-config
+, python3
+, rustPlatform
+, lib, stdenv
+, wayland
+, xorg
+, vulkan-loader
+}:
+
+rustPlatform.buildRustPackage rec {
+  pname = "ruffle";
+  version = "nightly-2021-01-12";
+
+  src = fetchFromGitHub {
+    owner = "ruffle-rs";
+    repo = pname;
+    rev = version;
+    sha256 = "1lywxn61w0b3pb8vjpavd9f3v58gq35ypwp41b7rjkc4rjxmf3cd";
+  };
+
+  nativeBuildInputs = [
+    makeWrapper
+    pkg-config
+    python3
+  ];
+
+  buildInputs = [
+    alsaLib
+    openssl
+    wayland
+    xorg.libX11
+    xorg.libXcursor
+    xorg.libXrandr
+    xorg.libXi
+    xorg.libxcb
+    xorg.libXrender
+    vulkan-loader
+  ];
+
+  postInstall = ''
+    wrapProgram $out/bin/ruffle_desktop --prefix LD_LIBRARY_PATH ':' ${vulkan-loader}/lib
+  '';
+
+  cargoSha256 = "113gh8nf2fs9shfvnzpwlc7zaq1l9l9jhlybcc4dq0wr4r8qpff5";
+
+  meta = with lib; {
+    description = "An Adobe Flash Player emulator written in the Rust programming language.";
+    homepage = "https://ruffle.rs/";
+    license = with licenses; [ mit asl20 ];
+    maintainers = with maintainers; [ govanify ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/ryujinx/default.nix b/nixpkgs/pkgs/misc/emulators/ryujinx/default.nix
new file mode 100644
index 000000000000..79d71301163a
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/ryujinx/default.nix
@@ -0,0 +1,106 @@
+{ lib, stdenv, fetchFromGitHub, fetchurl, makeWrapper, makeDesktopItem, linkFarmFromDrvs
+, dotnet-sdk_3, dotnetPackages, dotnetCorePackages
+, SDL2, libX11, openal
+, gtk3, gobject-introspection, wrapGAppsHook
+}:
+
+let
+  runtimeDeps = [
+    SDL2
+    gtk3
+    libX11
+    openal
+  ];
+in stdenv.mkDerivation rec {
+  pname = "ryujinx";
+  version = "1.0.5551"; # Versioning is based off of the official appveyor builds: https://ci.appveyor.com/project/gdkchan/ryujinx
+
+  src = fetchFromGitHub {
+    owner = "Ryujinx";
+    repo = "Ryujinx";
+    rev = "2dcc6333f8cbb959293832f52857bdaeab1918bf";
+    sha256 = "1hfa498fr9mdxas9s02y25ncb982wa1sqhl06jpnkhqsiicbkgcf";
+  };
+
+  nativeBuildInputs = [ dotnet-sdk_3 dotnetPackages.Nuget makeWrapper wrapGAppsHook gobject-introspection ];
+
+  nugetDeps = linkFarmFromDrvs "${pname}-nuget-deps" (import ./deps.nix {
+    fetchNuGet = { name, version, sha256 }: fetchurl {
+      name = "nuget-${name}-${version}.nupkg";
+      url = "https://www.nuget.org/api/v2/package/${name}/${version}";
+      inherit sha256;
+    };
+  });
+
+  patches = [ ./log.patch ]; # Without this, Ryujinx tries to write logs to the nix store. This patch makes it write to "~/.config/Ryujinx/Logs" on Linux.
+
+  configurePhase = ''
+    runHook preConfigure
+
+    export HOME=$(mktemp -d)
+    export DOTNET_CLI_TELEMETRY_OPTOUT=1
+    export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
+
+    nuget sources Add -Name nixos -Source "$PWD/nixos"
+    nuget init "$nugetDeps" "$PWD/nixos"
+
+    # FIXME: https://github.com/NuGet/Home/issues/4413
+    mkdir -p $HOME/.nuget/NuGet
+    cp $HOME/.config/NuGet/NuGet.Config $HOME/.nuget/NuGet
+
+    dotnet restore --source "$PWD/nixos" Ryujinx.sln
+
+    runHook postConfigure
+  '';
+
+  buildPhase = ''
+    runHook preBuild
+    dotnet build Ryujinx.sln \
+      --no-restore \
+      --configuration Release \
+      -p:Version=${version}
+    runHook postBuild
+  '';
+
+  installPhase = ''
+    runHook preInstall
+
+    dotnet publish Ryujinx.sln \
+      --no-build \
+      --configuration Release \
+      --no-self-contained \
+      --output $out/lib/ryujinx
+    shopt -s extglob
+
+    makeWrapper $out/lib/ryujinx/Ryujinx $out/bin/Ryujinx \
+      --set DOTNET_ROOT "${dotnetCorePackages.netcore_3_1}" \
+      --suffix LD_LIBRARY_PATH : "${lib.makeLibraryPath runtimeDeps}" \
+      ''${gappsWrapperArgs[@]}
+
+    for i in 16 32 48 64 96 128 256 512 1024; do
+      install -D ${src}/Ryujinx/Ui/assets/Icon.png $out/share/icons/hicolor/''${i}x$i/apps/ryujinx.png
+    done
+    cp -r ${makeDesktopItem {
+      desktopName = "Ryujinx";
+      name = "ryujinx";
+      exec = "Ryujinx";
+      icon = "ryujinx";
+      comment = meta.description;
+      type = "Application";
+      categories = "Game;";
+    }}/share/applications $out/share
+
+    runHook postInstall
+  '';
+
+  # Strip breaks the executable.
+  dontStrip = true;
+
+  meta = with lib; {
+    description = "Experimental Nintendo Switch Emulator written in C#";
+    homepage = "https://ryujinx.org/";
+    license = licenses.mit;
+    maintainers = [ maintainers.ivar ];
+    platforms = [ "x86_64-linux" ];
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/ryujinx/deps.nix b/nixpkgs/pkgs/misc/emulators/ryujinx/deps.nix
new file mode 100644
index 000000000000..4f30b159a280
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/ryujinx/deps.nix
@@ -0,0 +1,1072 @@
+{ fetchNuGet }: [
+  (fetchNuGet {
+    name = "AtkSharp";
+    version = "3.22.25.56";
+    sha256 = "069fm4wplxb4s1i6mdj00b22zqpz6pg9miglcj8mkf1b4lnn09g0";
+  })
+  (fetchNuGet {
+    name = "CairoSharp";
+    version = "3.22.25.56";
+    sha256 = "0b7p4yj88wgayh464j3rkbc4js8z57wxy3mprgvx86i3rc2v5jd9";
+  })
+  (fetchNuGet {
+    name = "Concentus";
+    version = "1.1.7";
+    sha256 = "0y5z444wrbhlmsqpy2sxmajl1fbf74843lvgj3y6vz260dn2q0l0";
+  })
+  (fetchNuGet {
+    name = "Crc32.NET";
+    version = "1.2.0";
+    sha256 = "0qaj3192k1vfji87zf50rhydn5mrzyzybrs2k4v7ap29k8i0vi5h";
+  })
+  (fetchNuGet {
+    name = "DiscordRichPresence";
+    version = "1.0.150";
+    sha256 = "0qmbi4sccia3w80q8xfvj3bw62nvz047wq198n2b2aflkf47bq79";
+  })
+  (fetchNuGet {
+    name = "FFmpeg.AutoGen";
+    version = "4.3.0";
+    sha256 = "03lb3xzgwxik8nljq87pr1b9bsxbsl3a4kvy0kqkw9f57n29ihvk";
+  })
+  (fetchNuGet {
+    name = "GdkSharp";
+    version = "3.22.25.56";
+    sha256 = "0f708dwy6i9hghxs711scwkww28lvfjd6gykk7xv921vich5xvy6";
+  })
+  (fetchNuGet {
+    name = "GioSharp";
+    version = "3.22.25.56";
+    sha256 = "1i7x1bakv5sq27ppl6w79c1wbvnfhf1713plc9ixaznh1fclcnwr";
+  })
+  (fetchNuGet {
+    name = "GLibSharp";
+    version = "3.22.25.56";
+    sha256 = "12czfm0lgjcy9hgqsiycwfv124dq619svrnsi036246i5hycj37w";
+  })
+  (fetchNuGet {
+    name = "GLWidget";
+    version = "1.0.2";
+    sha256 = "0nb46jiscnsywwdfy7zhx1bw4jfmca3s6l8dhbi99gc4bvp8ar7p";
+  })
+  (fetchNuGet {
+    name = "GtkSharp";
+    version = "3.22.25.56";
+    sha256 = "18dbn834wimdmxmgsqd81hyvjyyzgbnayzvz9f714cgw4yjkjyqs";
+  })
+  (fetchNuGet {
+    name = "GtkSharp.Dependencies";
+    version = "1.1.0";
+    sha256 = "1g1rhcn38ww97638rds6l5bysra43hkhv47fy71fvq89623zgyxn";
+  })
+  (fetchNuGet {
+    name = "LibHac";
+    version = "0.12.0";
+    sha256 = "08r9b9cdcbz6339sw8r5dfy2a8iw53df0j3xq9rygkg02xspimld";
+  })
+  (fetchNuGet {
+    name = "Microsoft.AspNetCore.App.Runtime.linux-x64";
+    version = "3.1.8";
+    sha256 = "140zr3nwkmf6xc52gq4iz6ycyh95fxy0jpgn637pkd9z423z8135";
+  })
+  (fetchNuGet {
+    name = "Microsoft.AspNetCore.App.Runtime.osx-x64";
+    version = "3.1.8";
+    sha256 = "0dkib4r4v5wqxsi6zca6x3zin1x4lha53dqbgsaiah961h1yhpp4";
+  })
+  (fetchNuGet {
+    name = "Microsoft.AspNetCore.App.Runtime.win-x64";
+    version = "3.1.8";
+    sha256 = "05sv39b6sc8fhh3m8kwq0lp58n8mrv5ivxa60rfqk6v6i7gs8b0f";
+  })
+  (fetchNuGet {
+    name = "Microsoft.CodeCoverage";
+    version = "16.7.0";
+    sha256 = "10f6y1q8w61vc8ffqd7jsndwfskkfqbdzfqswyxnrr0qkkqx29v1";
+  })
+  (fetchNuGet {
+    name = "Microsoft.CSharp";
+    version = "4.0.1";
+    sha256 = "0zxc0apx1gcx361jlq8smc9pfdgmyjh6hpka8dypc9w23nlsh6yj";
+  })
+  (fetchNuGet {
+    name = "Microsoft.DotNet.InternalAbstractions";
+    version = "1.0.0";
+    sha256 = "0mp8ihqlb7fsa789frjzidrfjc1lrhk88qp3xm5qvr7vf4wy4z8x";
+  })
+  (fetchNuGet {
+    name = "Microsoft.NETCore.App.Host.osx-x64";
+    version = "3.1.8";
+    sha256 = "1ip8pgra9z6ha3yc4xqkb85cl9kx2jbwhwzdi3dp8bkqbvlirvkb";
+  })
+  (fetchNuGet {
+    name = "Microsoft.NETCore.App.Host.win-x64";
+    version = "3.1.8";
+    sha256 = "1d7wlnibf9fgq57hwnjqhlh33hxg417ljf1djb9yan4xik1wl4hb";
+  })
+  (fetchNuGet {
+    name = "Microsoft.NETCore.App.Runtime.linux-x64";
+    version = "3.1.8";
+    sha256 = "1bv9n9wzsqf9g8h6z10p61xkcx8ad4nnip83qv8yyfvhr4kdmbsa";
+  })
+  (fetchNuGet {
+    name = "Microsoft.NETCore.App.Runtime.osx-x64";
+    version = "3.1.8";
+    sha256 = "1iabp5czrz9wmsqcl0gi8r580vlhky3aak5ndz9fw065wlsqpv7w";
+  })
+  (fetchNuGet {
+    name = "Microsoft.NETCore.App.Runtime.win-x64";
+    version = "3.1.8";
+    sha256 = "010c514ls1q9gdnyj0kvknx7a0z034lfbbcxqa8cjiv0snax4pqz";
+  })
+  (fetchNuGet {
+    name = "Microsoft.NETCore.Platforms";
+    version = "1.0.1";
+    sha256 = "01al6cfxp68dscl15z7rxfw9zvhm64dncsw09a1vmdkacsa2v6lr";
+  })
+  (fetchNuGet {
+    name = "Microsoft.NETCore.Platforms";
+    version = "1.1.0";
+    sha256 = "08vh1r12g6ykjygq5d3vq09zylgb84l63k49jc4v8faw9g93iqqm";
+  })
+  (fetchNuGet {
+    name = "Microsoft.NETCore.Platforms";
+    version = "2.0.0";
+    sha256 = "1fk2fk2639i7nzy58m9dvpdnzql4vb8yl8vr19r2fp8lmj9w2jr0";
+  })
+  (fetchNuGet {
+    name = "Microsoft.NETCore.Platforms";
+    version = "3.1.0";
+    sha256 = "1gc1x8f95wk8yhgznkwsg80adk1lc65v9n5rx4yaa4bc5dva0z3j";
+  })
+  (fetchNuGet {
+    name = "Microsoft.NETCore.Targets";
+    version = "1.0.1";
+    sha256 = "0ppdkwy6s9p7x9jix3v4402wb171cdiibq7js7i13nxpdky7074p";
+  })
+  (fetchNuGet {
+    name = "Microsoft.NETCore.Targets";
+    version = "1.1.0";
+    sha256 = "193xwf33fbm0ni3idxzbr5fdq3i2dlfgihsac9jj7whj0gd902nh";
+  })
+  (fetchNuGet {
+    name = "Microsoft.NET.Test.Sdk";
+    version = "16.7.0";
+    sha256 = "1vkp6b82566z2pxn9035wrh4339kz3ki17g5qlwmwdbn4br6lcfy";
+  })
+  (fetchNuGet {
+    name = "Microsoft.TestPlatform.ObjectModel";
+    version = "16.7.0";
+    sha256 = "0nmw80ap2rn9h4i1x7qb15n763sh3wy8hjp1i5n0av7100g0yjqz";
+  })
+  (fetchNuGet {
+    name = "Microsoft.TestPlatform.TestHost";
+    version = "16.7.0";
+    sha256 = "0485nv0wcwdwjhif5a7d1i0znaf9acqyawhpqcwschw827chqzrs";
+  })
+  (fetchNuGet {
+    name = "Microsoft.Win32.Primitives";
+    version = "4.0.1";
+    sha256 = "1n8ap0cmljbqskxpf8fjzn7kh1vvlndsa75k01qig26mbw97k2q7";
+  })
+  (fetchNuGet {
+    name = "Microsoft.Win32.Primitives";
+    version = "4.3.0";
+    sha256 = "0j0c1wj4ndj21zsgivsc24whiya605603kxrbiw6wkfdync464wq";
+  })
+  (fetchNuGet {
+    name = "Microsoft.Win32.Registry";
+    version = "4.3.0";
+    sha256 = "1gxyzxam8163vk1kb6xzxjj4iwspjsz9zhgn1w9rjzciphaz0ig7";
+  })
+  (fetchNuGet {
+    name = "Microsoft.Win32.Registry";
+    version = "4.5.0";
+    sha256 = "1zapbz161ji8h82xiajgriq6zgzmb1f3ar517p2h63plhsq5gh2q";
+  })
+  (fetchNuGet {
+    name = "Microsoft.Win32.Registry";
+    version = "4.7.0";
+    sha256 = "0bx21jjbs7l5ydyw4p6cn07chryxpmchq2nl5pirzz4l3b0q4dgs";
+  })
+  (fetchNuGet {
+    name = "Microsoft.Win32.SystemEvents";
+    version = "4.5.0";
+    sha256 = "0fnkv3ky12227zqg4zshx4kw2mvysq2ppxjibfw02cc3iprv4njq";
+  })
+  (fetchNuGet {
+    name = "Mono.Posix.NETStandard";
+    version = "1.0.0";
+    sha256 = "0xlja36hwpjm837haq15mjh2prcf68lyrmn72nvgpz8qnf9vappw";
+  })
+  (fetchNuGet {
+    name = "MsgPack.Cli";
+    version = "1.0.1";
+    sha256 = "1dk2bs3g16lsxcjjm7gfx6jxa4667wccw94jlh2ql7y7smvh9z8r";
+  })
+  (fetchNuGet {
+    name = "NETStandard.Library";
+    version = "1.6.0";
+    sha256 = "0nmmv4yw7gw04ik8ialj3ak0j6pxa9spih67hnn1h2c38ba8h58k";
+  })
+  (fetchNuGet {
+    name = "NETStandard.Library";
+    version = "2.0.0";
+    sha256 = "1bc4ba8ahgk15m8k4nd7x406nhi0kwqzbgjk2dmw52ss553xz7iy";
+  })
+  (fetchNuGet {
+    name = "Newtonsoft.Json";
+    version = "12.0.2";
+    sha256 = "0w2fbji1smd2y7x25qqibf1qrznmv4s6s0jvrbvr6alb7mfyqvh5";
+  })
+  (fetchNuGet {
+    name = "Newtonsoft.Json";
+    version = "9.0.1";
+    sha256 = "0mcy0i7pnfpqm4pcaiyzzji4g0c8i3a5gjz28rrr28110np8304r";
+  })
+  (fetchNuGet {
+    name = "NuGet.Frameworks";
+    version = "5.0.0";
+    sha256 = "18ijvmj13cwjdrrm52c8fpq021531zaz4mj4b4zapxaqzzxf2qjr";
+  })
+  (fetchNuGet {
+    name = "NUnit";
+    version = "3.12.0";
+    sha256 = "1880j2xwavi8f28vxan3hyvdnph4nlh5sbmh285s4lc9l0b7bdk2";
+  })
+  (fetchNuGet {
+    name = "NUnit3TestAdapter";
+    version = "3.17.0";
+    sha256 = "0kxc6z3b8ccdrcyqz88jm5yh5ch9nbg303v67q8sp5hhs8rl8nk6";
+  })
+  (fetchNuGet {
+    name = "OpenTK.NetStandard";
+    version = "1.0.5.22";
+    sha256 = "10bdhc4qbffac862zg03ab5j3iqrr33bydxmnmrxn82brldahm23";
+  })
+  (fetchNuGet {
+    name = "PangoSharp";
+    version = "3.22.25.56";
+    sha256 = "12b0761nfsci4rvzcba4hrh5rcn6q24qaxwwz66myb82c999qj8w";
+  })
+  (fetchNuGet {
+    name = "runtime.any.System.Collections";
+    version = "4.3.0";
+    sha256 = "0bv5qgm6vr47ynxqbnkc7i797fdi8gbjjxii173syrx14nmrkwg0";
+  })
+  (fetchNuGet {
+    name = "runtime.any.System.Diagnostics.Tools";
+    version = "4.3.0";
+    sha256 = "1wl76vk12zhdh66vmagni66h5xbhgqq7zkdpgw21jhxhvlbcl8pk";
+  })
+  (fetchNuGet {
+    name = "runtime.any.System.Diagnostics.Tracing";
+    version = "4.3.0";
+    sha256 = "00j6nv2xgmd3bi347k00m7wr542wjlig53rmj28pmw7ddcn97jbn";
+  })
+  (fetchNuGet {
+    name = "runtime.any.System.Globalization";
+    version = "4.3.0";
+    sha256 = "1daqf33hssad94lamzg01y49xwndy2q97i2lrb7mgn28656qia1x";
+  })
+  (fetchNuGet {
+    name = "runtime.any.System.Globalization.Calendars";
+    version = "4.3.0";
+    sha256 = "1ghhhk5psqxcg6w88sxkqrc35bxcz27zbqm2y5p5298pv3v7g201";
+  })
+  (fetchNuGet {
+    name = "runtime.any.System.IO";
+    version = "4.3.0";
+    sha256 = "0l8xz8zn46w4d10bcn3l4yyn4vhb3lrj2zw8llvz7jk14k4zps5x";
+  })
+  (fetchNuGet {
+    name = "runtime.any.System.Reflection";
+    version = "4.3.0";
+    sha256 = "02c9h3y35pylc0zfq3wcsvc5nqci95nrkq0mszifc0sjx7xrzkly";
+  })
+  (fetchNuGet {
+    name = "runtime.any.System.Reflection.Extensions";
+    version = "4.3.0";
+    sha256 = "0zyri97dfc5vyaz9ba65hjj1zbcrzaffhsdlpxc9bh09wy22fq33";
+  })
+  (fetchNuGet {
+    name = "runtime.any.System.Reflection.Primitives";
+    version = "4.3.0";
+    sha256 = "0x1mm8c6iy8rlxm8w9vqw7gb7s1ljadrn049fmf70cyh42vdfhrf";
+  })
+  (fetchNuGet {
+    name = "runtime.any.System.Resources.ResourceManager";
+    version = "4.3.0";
+    sha256 = "03kickal0iiby82wa5flar18kyv82s9s6d4xhk5h4bi5kfcyfjzl";
+  })
+  (fetchNuGet {
+    name = "runtime.any.System.Runtime";
+    version = "4.3.0";
+    sha256 = "1cqh1sv3h5j7ixyb7axxbdkqx6cxy00p4np4j91kpm492rf4s25b";
+  })
+  (fetchNuGet {
+    name = "runtime.any.System.Runtime.Handles";
+    version = "4.3.0";
+    sha256 = "0bh5bi25nk9w9xi8z23ws45q5yia6k7dg3i4axhfqlnj145l011x";
+  })
+  (fetchNuGet {
+    name = "runtime.any.System.Runtime.InteropServices";
+    version = "4.3.0";
+    sha256 = "0c3g3g3jmhlhw4klrc86ka9fjbl7i59ds1fadsb2l8nqf8z3kb19";
+  })
+  (fetchNuGet {
+    name = "runtime.any.System.Text.Encoding";
+    version = "4.3.0";
+    sha256 = "0aqqi1v4wx51h51mk956y783wzags13wa7mgqyclacmsmpv02ps3";
+  })
+  (fetchNuGet {
+    name = "runtime.any.System.Text.Encoding.Extensions";
+    version = "4.3.0";
+    sha256 = "0lqhgqi0i8194ryqq6v2gqx0fb86db2gqknbm0aq31wb378j7ip8";
+  })
+  (fetchNuGet {
+    name = "runtime.any.System.Threading.Tasks";
+    version = "4.3.0";
+    sha256 = "03mnvkhskbzxddz4hm113zsch1jyzh2cs450dk3rgfjp8crlw1va";
+  })
+  (fetchNuGet {
+    name = "runtime.any.System.Threading.Timer";
+    version = "4.3.0";
+    sha256 = "0aw4phrhwqz9m61r79vyfl5la64bjxj8l34qnrcwb28v49fg2086";
+  })
+  (fetchNuGet {
+    name = "runtime.debian.8-x64.runtime.native.System.Security.Cryptography.OpenSsl";
+    version = "4.3.0";
+    sha256 = "16rnxzpk5dpbbl1x354yrlsbvwylrq456xzpsha1n9y3glnhyx9d";
+  })
+  (fetchNuGet {
+    name = "runtime.fedora.23-x64.runtime.native.System.Security.Cryptography.OpenSsl";
+    version = "4.3.0";
+    sha256 = "0hkg03sgm2wyq8nqk6dbm9jh5vcq57ry42lkqdmfklrw89lsmr59";
+  })
+  (fetchNuGet {
+    name = "runtime.fedora.24-x64.runtime.native.System.Security.Cryptography.OpenSsl";
+    version = "4.3.0";
+    sha256 = "0c2p354hjx58xhhz7wv6div8xpi90sc6ibdm40qin21bvi7ymcaa";
+  })
+  (fetchNuGet {
+    name = "runtime.native.System";
+    version = "4.0.0";
+    sha256 = "1ppk69xk59ggacj9n7g6fyxvzmk1g5p4fkijm0d7xqfkig98qrkf";
+  })
+  (fetchNuGet {
+    name = "runtime.native.System";
+    version = "4.3.0";
+    sha256 = "15hgf6zaq9b8br2wi1i3x0zvmk410nlmsmva9p0bbg73v6hml5k4";
+  })
+  (fetchNuGet {
+    name = "runtime.native.System.IO.Compression";
+    version = "4.1.0";
+    sha256 = "0d720z4lzyfcabmmnvh0bnj76ll7djhji2hmfh3h44sdkjnlkknk";
+  })
+  (fetchNuGet {
+    name = "runtime.native.System.Net.Http";
+    version = "4.0.1";
+    sha256 = "1hgv2bmbaskx77v8glh7waxws973jn4ah35zysnkxmf0196sfxg6";
+  })
+  (fetchNuGet {
+    name = "runtime.native.System.Security.Cryptography";
+    version = "4.0.0";
+    sha256 = "0k57aa2c3b10wl3hfqbgrl7xq7g8hh3a3ir44b31dn5p61iiw3z9";
+  })
+  (fetchNuGet {
+    name = "runtime.native.System.Security.Cryptography.OpenSsl";
+    version = "4.3.0";
+    sha256 = "18pzfdlwsg2nb1jjjjzyb5qlgy6xjxzmhnfaijq5s2jw3cm3ab97";
+  })
+  (fetchNuGet {
+    name = "runtime.opensuse.13.2-x64.runtime.native.System.Security.Cryptography.OpenSsl";
+    version = "4.3.0";
+    sha256 = "0qyynf9nz5i7pc26cwhgi8j62ps27sqmf78ijcfgzab50z9g8ay3";
+  })
+  (fetchNuGet {
+    name = "runtime.opensuse.42.1-x64.runtime.native.System.Security.Cryptography.OpenSsl";
+    version = "4.3.0";
+    sha256 = "1klrs545awhayryma6l7g2pvnp9xy4z0r1i40r80zb45q3i9nbyf";
+  })
+  (fetchNuGet {
+    name = "runtime.osx.10.10-x64.runtime.native.System.Security.Cryptography.OpenSsl";
+    version = "4.3.0";
+    sha256 = "0zcxjv5pckplvkg0r6mw3asggm7aqzbdjimhvsasb0cgm59x09l3";
+  })
+  (fetchNuGet {
+    name = "runtime.rhel.7-x64.runtime.native.System.Security.Cryptography.OpenSsl";
+    version = "4.3.0";
+    sha256 = "0vhynn79ih7hw7cwjazn87rm9z9fj0rvxgzlab36jybgcpcgphsn";
+  })
+  (fetchNuGet {
+    name = "runtime.ubuntu.14.04-x64.runtime.native.System.Security.Cryptography.OpenSsl";
+    version = "4.3.0";
+    sha256 = "160p68l2c7cqmyqjwxydcvgw7lvl1cr0znkw8fp24d1by9mqc8p3";
+  })
+  (fetchNuGet {
+    name = "runtime.ubuntu.16.04-x64.runtime.native.System.Security.Cryptography.OpenSsl";
+    version = "4.3.0";
+    sha256 = "15zrc8fgd8zx28hdghcj5f5i34wf3l6bq5177075m2bc2j34jrqy";
+  })
+  (fetchNuGet {
+    name = "runtime.ubuntu.16.10-x64.runtime.native.System.Security.Cryptography.OpenSsl";
+    version = "4.3.0";
+    sha256 = "1p4dgxax6p7rlgj4q73k73rslcnz4wdcv8q2flg1s8ygwcm58ld5";
+  })
+  (fetchNuGet {
+    name = "runtime.unix.Microsoft.Win32.Primitives";
+    version = "4.3.0";
+    sha256 = "0y61k9zbxhdi0glg154v30kkq7f8646nif8lnnxbvkjpakggd5id";
+  })
+  (fetchNuGet {
+    name = "runtime.unix.System.Console";
+    version = "4.3.0";
+    sha256 = "1pfpkvc6x2if8zbdzg9rnc5fx51yllprl8zkm5npni2k50lisy80";
+  })
+  (fetchNuGet {
+    name = "runtime.unix.System.Diagnostics.Debug";
+    version = "4.3.0";
+    sha256 = "1lps7fbnw34bnh3lm31gs5c0g0dh7548wfmb8zz62v0zqz71msj5";
+  })
+  (fetchNuGet {
+    name = "runtime.unix.System.IO.FileSystem";
+    version = "4.3.0";
+    sha256 = "14nbkhvs7sji5r1saj2x8daz82rnf9kx28d3v2qss34qbr32dzix";
+  })
+  (fetchNuGet {
+    name = "runtime.unix.System.Net.Primitives";
+    version = "4.3.0";
+    sha256 = "0bdnglg59pzx9394sy4ic66kmxhqp8q8bvmykdxcbs5mm0ipwwm4";
+  })
+  (fetchNuGet {
+    name = "runtime.unix.System.Net.Sockets";
+    version = "4.3.0";
+    sha256 = "03npdxzy8gfv035bv1b9rz7c7hv0rxl5904wjz51if491mw0xy12";
+  })
+  (fetchNuGet {
+    name = "runtime.unix.System.Private.Uri";
+    version = "4.3.0";
+    sha256 = "1jx02q6kiwlvfksq1q9qr17fj78y5v6mwsszav4qcz9z25d5g6vk";
+  })
+  (fetchNuGet {
+    name = "runtime.unix.System.Runtime.Extensions";
+    version = "4.3.0";
+    sha256 = "0pnxxmm8whx38dp6yvwgmh22smknxmqs5n513fc7m4wxvs1bvi4p";
+  })
+  (fetchNuGet {
+    name = "runtime.win.Microsoft.Win32.Primitives";
+    version = "4.3.0";
+    sha256 = "0k1h8nnp1s0p8rjwgjyj1387cc1yycv0k22igxc963lqdzrx2z36";
+  })
+  (fetchNuGet {
+    name = "runtime.win.System.Console";
+    version = "4.3.0";
+    sha256 = "0x2yajfrbc5zc6g7nmlr44xpjk6p1hxjq47jn3xki5j7i33zw9jc";
+  })
+  (fetchNuGet {
+    name = "runtime.win.System.Diagnostics.Debug";
+    version = "4.3.0";
+    sha256 = "16fbn4bcynad1ygdq0yk1wmckvs8jvrrf104xa5dc2hlc8y3x58f";
+  })
+  (fetchNuGet {
+    name = "runtime.win.System.IO.FileSystem";
+    version = "4.3.0";
+    sha256 = "1c01nklbxywszsbfaxc76hsz7gdxac3jkphrywfkdsi3v4bwd6g8";
+  })
+  (fetchNuGet {
+    name = "runtime.win.System.Net.Primitives";
+    version = "4.3.0";
+    sha256 = "1dixh195bi7473n17hspll6i562gghdz9m4jk8d4kzi1mlzjk9cf";
+  })
+  (fetchNuGet {
+    name = "runtime.win.System.Net.Sockets";
+    version = "4.3.0";
+    sha256 = "0lr3zki831vs6qhk5wckv2b9qbfk9rcj0ds2926qvj1b9y9m6sck";
+  })
+  (fetchNuGet {
+    name = "runtime.win.System.Runtime.Extensions";
+    version = "4.3.0";
+    sha256 = "1700famsxndccfbcdz9q14qb20p49lax67mqwpgy4gx3vja1yczr";
+  })
+  (fetchNuGet {
+    name = "Ryujinx.Graphics.Nvdec.Dependencies";
+    version = "4.3.0";
+    sha256 = "0szgbdhyhvzpw8nb9k2ww37p5qipab1pdll8idkk57y5xnl2f7ll";
+  })
+  (fetchNuGet {
+    name = "SharpZipLib";
+    version = "1.2.0";
+    sha256 = "0ynhx1qkjm723bwjwsrdviw1d2s9azndpa12dagrjshhma3igqm5";
+  })
+  (fetchNuGet {
+    name = "System.AppContext";
+    version = "4.1.0";
+    sha256 = "0fv3cma1jp4vgj7a8hqc9n7hr1f1kjp541s6z0q1r6nazb4iz9mz";
+  })
+  (fetchNuGet {
+    name = "System.Buffers";
+    version = "4.0.0";
+    sha256 = "13s659bcmg9nwb6z78971z1lr6bmh2wghxi1ayqyzl4jijd351gr";
+  })
+  (fetchNuGet {
+    name = "System.Buffers";
+    version = "4.3.0";
+    sha256 = "0fgns20ispwrfqll4q1zc1waqcmylb3zc50ys9x8zlwxh9pmd9jy";
+  })
+  (fetchNuGet {
+    name = "System.CodeDom";
+    version = "4.4.0";
+    sha256 = "1zgbafm5p380r50ap5iddp11kzhr9khrf2pnai6k593wjar74p1g";
+  })
+  (fetchNuGet {
+    name = "System.CodeDom";
+    version = "4.7.0";
+    sha256 = "1lch8gwmw420wsvbv9ir4v5g1ij2ag23cbgi3c9gramj1h4vhlz2";
+  })
+  (fetchNuGet {
+    name = "System.Collections";
+    version = "4.0.11";
+    sha256 = "1ga40f5lrwldiyw6vy67d0sg7jd7ww6kgwbksm19wrvq9hr0bsm6";
+  })
+  (fetchNuGet {
+    name = "System.Collections";
+    version = "4.3.0";
+    sha256 = "19r4y64dqyrq6k4706dnyhhw7fs24kpp3awak7whzss39dakpxk9";
+  })
+  (fetchNuGet {
+    name = "System.Collections.Concurrent";
+    version = "4.0.12";
+    sha256 = "07y08kvrzpak873pmyxs129g1ch8l27zmg51pcyj2jvq03n0r0fc";
+  })
+  (fetchNuGet {
+    name = "System.Collections.NonGeneric";
+    version = "4.3.0";
+    sha256 = "07q3k0hf3mrcjzwj8fwk6gv3n51cb513w4mgkfxzm3i37sc9kz7k";
+  })
+  (fetchNuGet {
+    name = "System.Collections.Specialized";
+    version = "4.3.0";
+    sha256 = "1sdwkma4f6j85m3dpb53v9vcgd0zyc9jb33f8g63byvijcj39n20";
+  })
+  (fetchNuGet {
+    name = "System.ComponentModel";
+    version = "4.3.0";
+    sha256 = "0986b10ww3nshy30x9sjyzm0jx339dkjxjj3401r3q0f6fx2wkcb";
+  })
+  (fetchNuGet {
+    name = "System.ComponentModel.EventBasedAsync";
+    version = "4.3.0";
+    sha256 = "1rv9bkb8yyhqqqrx6x95njv6mdxlbvv527b44mrd93g8fmgkifl7";
+  })
+  (fetchNuGet {
+    name = "System.ComponentModel.Primitives";
+    version = "4.3.0";
+    sha256 = "1svfmcmgs0w0z9xdw2f2ps05rdxmkxxhf0l17xk9l1l8xfahkqr0";
+  })
+  (fetchNuGet {
+    name = "System.ComponentModel.TypeConverter";
+    version = "4.3.0";
+    sha256 = "17ng0p7v3nbrg3kycz10aqrrlw4lz9hzhws09pfh8gkwicyy481x";
+  })
+  (fetchNuGet {
+    name = "System.Console";
+    version = "4.0.0";
+    sha256 = "0ynxqbc3z1nwbrc11hkkpw9skw116z4y9wjzn7id49p9yi7mzmlf";
+  })
+  (fetchNuGet {
+    name = "System.Diagnostics.Debug";
+    version = "4.0.11";
+    sha256 = "0gmjghrqmlgzxivd2xl50ncbglb7ljzb66rlx8ws6dv8jm0d5siz";
+  })
+  (fetchNuGet {
+    name = "System.Diagnostics.Debug";
+    version = "4.3.0";
+    sha256 = "00yjlf19wjydyr6cfviaph3vsjzg3d5nvnya26i2fvfg53sknh3y";
+  })
+  (fetchNuGet {
+    name = "System.Diagnostics.DiagnosticSource";
+    version = "4.0.0";
+    sha256 = "1n6c3fbz7v8d3pn77h4v5wvsfrfg7v1c57lg3nff3cjyh597v23m";
+  })
+  (fetchNuGet {
+    name = "System.Diagnostics.Process";
+    version = "4.3.0";
+    sha256 = "0g4prsbkygq8m21naqmcp70f24a1ksyix3dihb1r1f71lpi3cfj7";
+  })
+  (fetchNuGet {
+    name = "System.Diagnostics.Tools";
+    version = "4.0.1";
+    sha256 = "19cknvg07yhakcvpxg3cxa0bwadplin6kyxd8mpjjpwnp56nl85x";
+  })
+  (fetchNuGet {
+    name = "System.Diagnostics.Tracing";
+    version = "4.1.0";
+    sha256 = "1d2r76v1x610x61ahfpigda89gd13qydz6vbwzhpqlyvq8jj6394";
+  })
+  (fetchNuGet {
+    name = "System.Diagnostics.Tracing";
+    version = "4.3.0";
+    sha256 = "1m3bx6c2s958qligl67q7grkwfz3w53hpy7nc97mh6f7j5k168c4";
+  })
+  (fetchNuGet {
+    name = "System.Drawing.Common";
+    version = "4.5.0";
+    sha256 = "0knqa0zsm91nfr34br8gx5kjqq4v81zdhqkacvs2hzc8nqk0ddhc";
+  })
+  (fetchNuGet {
+    name = "System.Dynamic.Runtime";
+    version = "4.0.11";
+    sha256 = "1pla2dx8gkidf7xkciig6nifdsb494axjvzvann8g2lp3dbqasm9";
+  })
+  (fetchNuGet {
+    name = "System.Globalization";
+    version = "4.0.11";
+    sha256 = "070c5jbas2v7smm660zaf1gh0489xanjqymkvafcs4f8cdrs1d5d";
+  })
+  (fetchNuGet {
+    name = "System.Globalization";
+    version = "4.3.0";
+    sha256 = "1cp68vv683n6ic2zqh2s1fn4c2sd87g5hpp6l4d4nj4536jz98ki";
+  })
+  (fetchNuGet {
+    name = "System.Globalization.Calendars";
+    version = "4.0.1";
+    sha256 = "0bv0alrm2ck2zk3rz25lfyk9h42f3ywq77mx1syl6vvyncnpg4qh";
+  })
+  (fetchNuGet {
+    name = "System.Globalization.Extensions";
+    version = "4.0.1";
+    sha256 = "0hjhdb5ri8z9l93bw04s7ynwrjrhx2n0p34sf33a9hl9phz69fyc";
+  })
+  (fetchNuGet {
+    name = "System.Globalization.Extensions";
+    version = "4.3.0";
+    sha256 = "02a5zfxavhv3jd437bsncbhd2fp1zv4gxzakp1an9l6kdq1mcqls";
+  })
+  (fetchNuGet {
+    name = "System.IO";
+    version = "4.1.0";
+    sha256 = "1g0yb8p11vfd0kbkyzlfsbsp5z44lwsvyc0h3dpw6vqnbi035ajp";
+  })
+  (fetchNuGet {
+    name = "System.IO";
+    version = "4.3.0";
+    sha256 = "05l9qdrzhm4s5dixmx68kxwif4l99ll5gqmh7rqgw554fx0agv5f";
+  })
+  (fetchNuGet {
+    name = "System.IO.Compression";
+    version = "4.1.0";
+    sha256 = "0iym7s3jkl8n0vzm3jd6xqg9zjjjqni05x45dwxyjr2dy88hlgji";
+  })
+  (fetchNuGet {
+    name = "System.IO.Compression.ZipFile";
+    version = "4.0.1";
+    sha256 = "0h72znbagmgvswzr46mihn7xm7chfk2fhrp5krzkjf29pz0i6z82";
+  })
+  (fetchNuGet {
+    name = "System.IO.FileSystem";
+    version = "4.0.1";
+    sha256 = "0kgfpw6w4djqra3w5crrg8xivbanh1w9dh3qapb28q060wb9flp1";
+  })
+  (fetchNuGet {
+    name = "System.IO.FileSystem";
+    version = "4.3.0";
+    sha256 = "0z2dfrbra9i6y16mm9v1v6k47f0fm617vlb7s5iybjjsz6g1ilmw";
+  })
+  (fetchNuGet {
+    name = "System.IO.FileSystem.Primitives";
+    version = "4.0.1";
+    sha256 = "1s0mniajj3lvbyf7vfb5shp4ink5yibsx945k6lvxa96r8la1612";
+  })
+  (fetchNuGet {
+    name = "System.IO.FileSystem.Primitives";
+    version = "4.3.0";
+    sha256 = "0j6ndgglcf4brg2lz4wzsh1av1gh8xrzdsn9f0yznskhqn1xzj9c";
+  })
+  (fetchNuGet {
+    name = "System.Linq";
+    version = "4.1.0";
+    sha256 = "1ppg83svb39hj4hpp5k7kcryzrf3sfnm08vxd5sm2drrijsla2k5";
+  })
+  (fetchNuGet {
+    name = "System.Linq";
+    version = "4.3.0";
+    sha256 = "1w0gmba695rbr80l1k2h4mrwzbzsyfl2z4klmpbsvsg5pm4a56s7";
+  })
+  (fetchNuGet {
+    name = "System.Linq.Expressions";
+    version = "4.1.0";
+    sha256 = "1gpdxl6ip06cnab7n3zlcg6mqp7kknf73s8wjinzi4p0apw82fpg";
+  })
+  (fetchNuGet {
+    name = "System.Management";
+    version = "4.7.0";
+    sha256 = "0aw61jl6l78liiq04afxplz0ad5qbyg6vmyjaqrlnrv7whb58n66";
+  })
+  (fetchNuGet {
+    name = "System.Net.Http";
+    version = "4.1.0";
+    sha256 = "1i5rqij1icg05j8rrkw4gd4pgia1978mqhjzhsjg69lvwcdfg8yb";
+  })
+  (fetchNuGet {
+    name = "System.Net.NameResolution";
+    version = "4.3.0";
+    sha256 = "15r75pwc0rm3vvwsn8rvm2krf929mjfwliv0mpicjnii24470rkq";
+  })
+  (fetchNuGet {
+    name = "System.Net.Primitives";
+    version = "4.0.11";
+    sha256 = "10xzzaynkzkakp7jai1ik3r805zrqjxiz7vcagchyxs2v26a516r";
+  })
+  (fetchNuGet {
+    name = "System.Net.Sockets";
+    version = "4.1.0";
+    sha256 = "1385fvh8h29da5hh58jm1v78fzi9fi5vj93vhlm2kvqpfahvpqls";
+  })
+  (fetchNuGet {
+    name = "System.Numerics.Vectors";
+    version = "4.3.0";
+    sha256 = "05kji1mv4sl75iwmc613p873145nynm02xiajx8pn0h2kx53d23s";
+  })
+  (fetchNuGet {
+    name = "System.ObjectModel";
+    version = "4.0.12";
+    sha256 = "1sybkfi60a4588xn34nd9a58png36i0xr4y4v4kqpg8wlvy5krrj";
+  })
+  (fetchNuGet {
+    name = "System.Private.Uri";
+    version = "4.3.0";
+    sha256 = "04r1lkdnsznin0fj4ya1zikxiqr0h6r6a1ww2dsm60gqhdrf0mvx";
+  })
+  (fetchNuGet {
+    name = "System.Reflection";
+    version = "4.1.0";
+    sha256 = "1js89429pfw79mxvbzp8p3q93il6rdff332hddhzi5wqglc4gml9";
+  })
+  (fetchNuGet {
+    name = "System.Reflection";
+    version = "4.3.0";
+    sha256 = "0xl55k0mw8cd8ra6dxzh974nxif58s3k1rjv1vbd7gjbjr39j11m";
+  })
+  (fetchNuGet {
+    name = "System.Reflection.Emit";
+    version = "4.0.1";
+    sha256 = "0ydqcsvh6smi41gyaakglnv252625hf29f7kywy2c70nhii2ylqp";
+  })
+  (fetchNuGet {
+    name = "System.Reflection.Emit";
+    version = "4.3.0";
+    sha256 = "11f8y3qfysfcrscjpjym9msk7lsfxkk4fmz9qq95kn3jd0769f74";
+  })
+  (fetchNuGet {
+    name = "System.Reflection.Emit.ILGeneration";
+    version = "4.0.1";
+    sha256 = "1pcd2ig6bg144y10w7yxgc9d22r7c7ww7qn1frdfwgxr24j9wvv0";
+  })
+  (fetchNuGet {
+    name = "System.Reflection.Emit.ILGeneration";
+    version = "4.3.0";
+    sha256 = "0w1n67glpv8241vnpz1kl14sy7zlnw414aqwj4hcx5nd86f6994q";
+  })
+  (fetchNuGet {
+    name = "System.Reflection.Emit.Lightweight";
+    version = "4.0.1";
+    sha256 = "1s4b043zdbx9k39lfhvsk68msv1nxbidhkq6nbm27q7sf8xcsnxr";
+  })
+  (fetchNuGet {
+    name = "System.Reflection.Emit.Lightweight";
+    version = "4.3.0";
+    sha256 = "0ql7lcakycrvzgi9kxz1b3lljd990az1x6c4jsiwcacrvimpib5c";
+  })
+  (fetchNuGet {
+    name = "System.Reflection.Extensions";
+    version = "4.0.1";
+    sha256 = "0m7wqwq0zqq9gbpiqvgk3sr92cbrw7cp3xn53xvw7zj6rz6fdirn";
+  })
+  (fetchNuGet {
+    name = "System.Reflection.Extensions";
+    version = "4.3.0";
+    sha256 = "02bly8bdc98gs22lqsfx9xicblszr2yan7v2mmw3g7hy6miq5hwq";
+  })
+  (fetchNuGet {
+    name = "System.Reflection.Primitives";
+    version = "4.0.1";
+    sha256 = "1bangaabhsl4k9fg8khn83wm6yial8ik1sza7401621jc6jrym28";
+  })
+  (fetchNuGet {
+    name = "System.Reflection.Primitives";
+    version = "4.3.0";
+    sha256 = "04xqa33bld78yv5r93a8n76shvc8wwcdgr1qvvjh959g3rc31276";
+  })
+  (fetchNuGet {
+    name = "System.Reflection.TypeExtensions";
+    version = "4.1.0";
+    sha256 = "1bjli8a7sc7jlxqgcagl9nh8axzfl11f4ld3rjqsyxc516iijij7";
+  })
+  (fetchNuGet {
+    name = "System.Reflection.TypeExtensions";
+    version = "4.3.0";
+    sha256 = "0y2ssg08d817p0vdag98vn238gyrrynjdj4181hdg780sif3ykp1";
+  })
+  (fetchNuGet {
+    name = "System.Resources.ResourceManager";
+    version = "4.0.1";
+    sha256 = "0b4i7mncaf8cnai85jv3wnw6hps140cxz8vylv2bik6wyzgvz7bi";
+  })
+  (fetchNuGet {
+    name = "System.Resources.ResourceManager";
+    version = "4.3.0";
+    sha256 = "0sjqlzsryb0mg4y4xzf35xi523s4is4hz9q4qgdvlvgivl7qxn49";
+  })
+  (fetchNuGet {
+    name = "System.Runtime";
+    version = "4.1.0";
+    sha256 = "02hdkgk13rvsd6r9yafbwzss8kr55wnj8d5c7xjnp8gqrwc8sn0m";
+  })
+  (fetchNuGet {
+    name = "System.Runtime";
+    version = "4.3.0";
+    sha256 = "066ixvgbf2c929kgknshcxqj6539ax7b9m570cp8n179cpfkapz7";
+  })
+  (fetchNuGet {
+    name = "System.Runtime.CompilerServices.Unsafe";
+    version = "4.6.0";
+    sha256 = "0xmzi2gpbmgyfr75p24rqqsba3cmrqgmcv45lsqp5amgrdwd0f0m";
+  })
+  (fetchNuGet {
+    name = "System.Runtime.CompilerServices.Unsafe";
+    version = "5.0.0-preview.7.20364.11";
+    sha256 = "19sl184f6rjhfsizq0vapysazd6yd66lf638rszvrdhqlsxssz2m";
+  })
+  (fetchNuGet {
+    name = "System.Runtime.Extensions";
+    version = "4.1.0";
+    sha256 = "0rw4rm4vsm3h3szxp9iijc3ksyviwsv6f63dng3vhqyg4vjdkc2z";
+  })
+  (fetchNuGet {
+    name = "System.Runtime.Extensions";
+    version = "4.3.0";
+    sha256 = "1ykp3dnhwvm48nap8q23893hagf665k0kn3cbgsqpwzbijdcgc60";
+  })
+  (fetchNuGet {
+    name = "System.Runtime.Handles";
+    version = "4.0.1";
+    sha256 = "1g0zrdi5508v49pfm3iii2hn6nm00bgvfpjq1zxknfjrxxa20r4g";
+  })
+  (fetchNuGet {
+    name = "System.Runtime.Handles";
+    version = "4.3.0";
+    sha256 = "0sw2gfj2xr7sw9qjn0j3l9yw07x73lcs97p8xfc9w1x9h5g5m7i8";
+  })
+  (fetchNuGet {
+    name = "System.Runtime.InteropServices";
+    version = "4.1.0";
+    sha256 = "01kxqppx3dr3b6b286xafqilv4s2n0gqvfgzfd4z943ga9i81is1";
+  })
+  (fetchNuGet {
+    name = "System.Runtime.InteropServices";
+    version = "4.3.0";
+    sha256 = "00hywrn4g7hva1b2qri2s6rabzwgxnbpw9zfxmz28z09cpwwgh7j";
+  })
+  (fetchNuGet {
+    name = "System.Runtime.InteropServices.RuntimeInformation";
+    version = "4.0.0";
+    sha256 = "0glmvarf3jz5xh22iy3w9v3wyragcm4hfdr17v90vs7vcrm7fgp6";
+  })
+  (fetchNuGet {
+    name = "System.Runtime.InteropServices.RuntimeInformation";
+    version = "4.3.0";
+    sha256 = "0q18r1sh4vn7bvqgd6dmqlw5v28flbpj349mkdish2vjyvmnb2ii";
+  })
+  (fetchNuGet {
+    name = "System.Runtime.Numerics";
+    version = "4.0.1";
+    sha256 = "1y308zfvy0l5nrn46mqqr4wb4z1xk758pkk8svbz8b5ij7jnv4nn";
+  })
+  (fetchNuGet {
+    name = "System.Runtime.Serialization.Primitives";
+    version = "4.1.1";
+    sha256 = "042rfjixknlr6r10vx2pgf56yming8lkjikamg3g4v29ikk78h7k";
+  })
+  (fetchNuGet {
+    name = "System.Security.AccessControl";
+    version = "4.5.0";
+    sha256 = "1wvwanz33fzzbnd2jalar0p0z3x0ba53vzx1kazlskp7pwyhlnq0";
+  })
+  (fetchNuGet {
+    name = "System.Security.AccessControl";
+    version = "4.7.0";
+    sha256 = "0n0k0w44flkd8j0xw7g3g3vhw7dijfm51f75xkm1qxnbh4y45mpz";
+  })
+  (fetchNuGet {
+    name = "System.Security.Claims";
+    version = "4.3.0";
+    sha256 = "0jvfn7j22l3mm28qjy3rcw287y9h65ha4m940waaxah07jnbzrhn";
+  })
+  (fetchNuGet {
+    name = "System.Security.Cryptography.Algorithms";
+    version = "4.2.0";
+    sha256 = "148s9g5dgm33ri7dnh19s4lgnlxbpwvrw2jnzllq2kijj4i4vs85";
+  })
+  (fetchNuGet {
+    name = "System.Security.Cryptography.Cng";
+    version = "4.2.0";
+    sha256 = "118jijz446kix20blxip0f0q8mhsh9bz118mwc2ch1p6g7facpzc";
+  })
+  (fetchNuGet {
+    name = "System.Security.Cryptography.Csp";
+    version = "4.0.0";
+    sha256 = "1cwv8lqj8r15q81d2pz2jwzzbaji0l28xfrpw29kdpsaypm92z2q";
+  })
+  (fetchNuGet {
+    name = "System.Security.Cryptography.Encoding";
+    version = "4.0.0";
+    sha256 = "0a8y1a5wkmpawc787gfmnrnbzdgxmx1a14ax43jf3rj9gxmy3vk4";
+  })
+  (fetchNuGet {
+    name = "System.Security.Cryptography.OpenSsl";
+    version = "4.0.0";
+    sha256 = "16sx3cig3d0ilvzl8xxgffmxbiqx87zdi8fc73i3i7zjih1a7f4q";
+  })
+  (fetchNuGet {
+    name = "System.Security.Cryptography.Primitives";
+    version = "4.0.0";
+    sha256 = "0i7cfnwph9a10bm26m538h5xcr8b36jscp9sy1zhgifksxz4yixh";
+  })
+  (fetchNuGet {
+    name = "System.Security.Cryptography.X509Certificates";
+    version = "4.1.0";
+    sha256 = "0clg1bv55mfv5dq00m19cp634zx6inm31kf8ppbq1jgyjf2185dh";
+  })
+  (fetchNuGet {
+    name = "System.Security.Principal";
+    version = "4.3.0";
+    sha256 = "12cm2zws06z4lfc4dn31iqv7072zyi4m910d4r6wm8yx85arsfxf";
+  })
+  (fetchNuGet {
+    name = "System.Security.Principal.Windows";
+    version = "4.3.0";
+    sha256 = "00a0a7c40i3v4cb20s2cmh9csb5jv2l0frvnlzyfxh848xalpdwr";
+  })
+  (fetchNuGet {
+    name = "System.Security.Principal.Windows";
+    version = "4.5.0";
+    sha256 = "0rmj89wsl5yzwh0kqjgx45vzf694v9p92r4x4q6yxldk1cv1hi86";
+  })
+  (fetchNuGet {
+    name = "System.Security.Principal.Windows";
+    version = "4.7.0";
+    sha256 = "1a56ls5a9sr3ya0nr086sdpa9qv0abv31dd6fp27maqa9zclqq5d";
+  })
+  (fetchNuGet {
+    name = "System.Text.Encoding";
+    version = "4.0.11";
+    sha256 = "1dyqv0hijg265dwxg6l7aiv74102d6xjiwplh2ar1ly6xfaa4iiw";
+  })
+  (fetchNuGet {
+    name = "System.Text.Encoding";
+    version = "4.3.0";
+    sha256 = "1f04lkir4iladpp51sdgmis9dj4y8v08cka0mbmsy0frc9a4gjqr";
+  })
+  (fetchNuGet {
+    name = "System.Text.Encoding.Extensions";
+    version = "4.0.11";
+    sha256 = "08nsfrpiwsg9x5ml4xyl3zyvjfdi4mvbqf93kjdh11j4fwkznizs";
+  })
+  (fetchNuGet {
+    name = "System.Text.Encoding.Extensions";
+    version = "4.3.0";
+    sha256 = "11q1y8hh5hrp5a3kw25cb6l00v5l5dvirkz8jr3sq00h1xgcgrxy";
+  })
+  (fetchNuGet {
+    name = "System.Text.RegularExpressions";
+    version = "4.1.0";
+    sha256 = "1mw7vfkkyd04yn2fbhm38msk7dz2xwvib14ygjsb8dq2lcvr18y7";
+  })
+  (fetchNuGet {
+    name = "System.Text.RegularExpressions";
+    version = "4.3.0";
+    sha256 = "1bgq51k7fwld0njylfn7qc5fmwrk2137gdq7djqdsw347paa9c2l";
+  })
+  (fetchNuGet {
+    name = "System.Threading";
+    version = "4.0.11";
+    sha256 = "19x946h926bzvbsgj28csn46gak2crv2skpwsx80hbgazmkgb1ls";
+  })
+  (fetchNuGet {
+    name = "System.Threading";
+    version = "4.3.0";
+    sha256 = "0rw9wfamvhayp5zh3j7p1yfmx9b5khbf4q50d8k5rk993rskfd34";
+  })
+  (fetchNuGet {
+    name = "System.Threading.Overlapped";
+    version = "4.3.0";
+    sha256 = "1nahikhqh9nk756dh8p011j36rlcp1bzz3vwi2b4m1l2s3vz8idm";
+  })
+  (fetchNuGet {
+    name = "System.Threading.Tasks";
+    version = "4.0.11";
+    sha256 = "0nr1r41rak82qfa5m0lhk9mp0k93bvfd7bbd9sdzwx9mb36g28p5";
+  })
+  (fetchNuGet {
+    name = "System.Threading.Tasks";
+    version = "4.3.0";
+    sha256 = "134z3v9abw3a6jsw17xl3f6hqjpak5l682k2vz39spj4kmydg6k7";
+  })
+  (fetchNuGet {
+    name = "System.Threading.Tasks.Extensions";
+    version = "4.0.0";
+    sha256 = "1cb51z062mvc2i8blpzmpn9d9mm4y307xrwi65di8ri18cz5r1zr";
+  })
+  (fetchNuGet {
+    name = "System.Threading.Tasks.Extensions";
+    version = "4.3.0";
+    sha256 = "1xxcx2xh8jin360yjwm4x4cf5y3a2bwpn2ygkfkwkicz7zk50s2z";
+  })
+  (fetchNuGet {
+    name = "System.Threading.Thread";
+    version = "4.3.0";
+    sha256 = "0y2xiwdfcph7znm2ysxanrhbqqss6a3shi1z3c779pj2s523mjx4";
+  })
+  (fetchNuGet {
+    name = "System.Threading.ThreadPool";
+    version = "4.3.0";
+    sha256 = "027s1f4sbx0y1xqw2irqn6x161lzj8qwvnh2gn78ciiczdv10vf1";
+  })
+  (fetchNuGet {
+    name = "System.Threading.Timer";
+    version = "4.0.1";
+    sha256 = "15n54f1f8nn3mjcjrlzdg6q3520571y012mx7v991x2fvp73lmg6";
+  })
+  (fetchNuGet {
+    name = "System.Xml.ReaderWriter";
+    version = "4.0.11";
+    sha256 = "0c6ky1jk5ada9m94wcadih98l6k1fvf6vi7vhn1msjixaha419l5";
+  })
+  (fetchNuGet {
+    name = "System.Xml.ReaderWriter";
+    version = "4.3.0";
+    sha256 = "0c47yllxifzmh8gq6rq6l36zzvw4kjvlszkqa9wq3fr59n0hl3s1";
+  })
+  (fetchNuGet {
+    name = "System.Xml.XDocument";
+    version = "4.0.11";
+    sha256 = "0n4lvpqzy9kc7qy1a4acwwd7b7pnvygv895az5640idl2y9zbz18";
+  })
+  (fetchNuGet {
+    name = "System.Xml.XmlDocument";
+    version = "4.3.0";
+    sha256 = "0bmz1l06dihx52jxjr22dyv5mxv6pj4852lx68grjm7bivhrbfwi";
+  })
+  (fetchNuGet {
+    name = "System.Xml.XPath";
+    version = "4.3.0";
+    sha256 = "1cv2m0p70774a0sd1zxc8fm8jk3i5zk2bla3riqvi8gsm0r4kpci";
+  })
+  (fetchNuGet {
+    name = "System.Xml.XPath.XmlDocument";
+    version = "4.3.0";
+    sha256 = "1h9lh7qkp0lff33z847sdfjj8yaz98ylbnkbxlnsbflhj9xyfqrm";
+  })
+]
diff --git a/nixpkgs/pkgs/misc/emulators/ryujinx/fetch-deps.sh b/nixpkgs/pkgs/misc/emulators/ryujinx/fetch-deps.sh
new file mode 100755
index 000000000000..ce9873a16929
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/ryujinx/fetch-deps.sh
@@ -0,0 +1,41 @@
+#!/usr/bin/env nix-shell
+#!nix-shell -i bash -p curl jq common-updater-scripts dotnet-sdk_3
+set -eo pipefail
+cd "$(dirname "${BASH_SOURCE[0]}")"
+
+deps_file="$(realpath "./deps.nix")"
+
+# Setup empty nuget package folder to force reinstall.
+mkdir ./nuget_tmp.packages
+cat >./nuget_tmp.config <<EOF
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+  <packageSources>
+    <add key="nuget" value="https://api.nuget.org/v3/index.json" />
+  </packageSources>
+  <config>
+    <add key="globalPackagesFolder" value="$(realpath ./nuget_tmp.packages)" />
+  </config>
+</configuration>
+EOF
+
+dotnet restore Ryujinx.sln --configfile ./nuget_tmp.config
+
+echo "{ fetchNuGet }: [" >"$deps_file"
+while read pkg_spec; do
+  { read pkg_name; read pkg_version; } < <(
+    # Build version part should be ignored: `3.0.0-beta2.20059.3+77df2220` -> `3.0.0-beta2.20059.3`
+    sed -nE 's/.*<id>([^<]*).*/\1/p; s/.*<version>([^<+]*).*/\1/p' "$pkg_spec")
+  pkg_sha256="$(nix-hash --type sha256 --flat --base32 "$(dirname "$pkg_spec")"/*.nupkg)"
+  cat >>"$deps_file" <<EOF
+  (fetchNuGet {
+    name = "$pkg_name";
+    version = "$pkg_version";
+    sha256 = "$pkg_sha256";
+  })
+EOF
+done < <(find ./nuget_tmp.packages -name '*.nuspec' | sort)
+echo "]" >>"$deps_file"
+
+popd
+rm -r "$src"
diff --git a/nixpkgs/pkgs/misc/emulators/ryujinx/log.patch b/nixpkgs/pkgs/misc/emulators/ryujinx/log.patch
new file mode 100644
index 000000000000..7283ef9e7d5d
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/ryujinx/log.patch
@@ -0,0 +1,13 @@
+diff --git a/Ryujinx.Common/Configuration/LoggerModule.cs b/Ryujinx.Common/Configuration/LoggerModule.cs
+index 20c0fb46..534576bc 100644
+--- a/Ryujinx.Common/Configuration/LoggerModule.cs
++++ b/Ryujinx.Common/Configuration/LoggerModule.cs
+@@ -75,7 +75,7 @@ namespace Ryujinx.Configuration
+             if (e.NewValue)
+             {
+                 Logger.AddTarget(new AsyncLogTargetWrapper(
+-                    new FileLogTarget(AppDomain.CurrentDomain.BaseDirectory, "file"),
++                    new FileLogTarget(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Ryujinx"), "file"),
+                     1000,
+                     AsyncLogTargetOverflowAction.Block
+                 ));
diff --git a/nixpkgs/pkgs/misc/emulators/sameboy/default.nix b/nixpkgs/pkgs/misc/emulators/sameboy/default.nix
new file mode 100644
index 000000000000..d23129eba7e5
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/sameboy/default.nix
@@ -0,0 +1,53 @@
+{ lib, stdenv, fetchFromGitHub, gtk3, rgbds, SDL2, wrapGAppsHook, glib }:
+
+stdenv.mkDerivation rec {
+  pname = "sameboy";
+  version = "0.13.6";
+
+  src = fetchFromGitHub {
+    owner = "LIJI32";
+    repo = "SameBoy";
+    rev = "v${version}";
+    sha256 = "04w8lybi7ssnax37ka4qw7pmcm7cgnmk90p9m73zbyp5chgpqqzc";
+  };
+
+  enableParallelBuilding = true;
+  # glib and wrapGAppsHook are needed to make the Open ROM menu work.
+  nativeBuildInputs = [ rgbds glib wrapGAppsHook ];
+  buildInputs = [ SDL2 ];
+
+  makeFlags = "CONF=release DATA_DIR=$(out)/share/sameboy/";
+
+  patchPhase = ''
+    sed 's/-Werror //g' -i Makefile
+    sed 's@"libgtk-3.so"@"${gtk3}/lib/libgtk-3.so"@g' -i OpenDialog/gtk.c
+  '';
+
+  installPhase = ''
+    pushd build/bin/SDL
+    install -Dm755 sameboy $out/bin/sameboy
+    rm sameboy
+    mkdir -p $out/share/sameboy
+    cp -r * $out/share/sameboy
+    popd
+  '';
+
+  meta = with lib; {
+    homepage = "https://sameboy.github.io";
+    description = "Game Boy, Game Boy Color, and Super Game Boy emulator";
+
+    longDescription = ''
+      SameBoy is a user friendly Game Boy, Game Boy Color and Super
+      Game Boy emulator for macOS, Windows and Unix-like platforms.
+      SameBoy is extremely accurate and includes a wide range of
+      powerful debugging features, making it ideal for both casual
+      players and developers. In addition to accuracy and developer
+      capabilities, SameBoy has all the features one would expect from
+      an emulator – from save states to scaling filters.
+    '';
+
+    license = licenses.mit;
+    maintainers = with maintainers; [ NieDzejkob ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/simh/default.nix b/nixpkgs/pkgs/misc/emulators/simh/default.nix
new file mode 100644
index 000000000000..08068debeefc
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/simh/default.nix
@@ -0,0 +1,62 @@
+{ lib, stdenv
+, fetchFromGitHub
+, SDL2
+, SDL2_ttf
+, libpcap
+, vde2
+, pcre
+}:
+
+stdenv.mkDerivation rec {
+  pname = "simh";
+  version = "3.11-1";
+
+  src = fetchFromGitHub {
+    owner = "simh";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "sha256-65+YfOWpVXPeT64TZcSaWJY+ODQ0q/pwF9jb8xGdpIs=";
+  };
+
+  buildInputs = [ SDL2 SDL2_ttf libpcap vde2 pcre ];
+
+  dontConfigure = true;
+
+  makeFlags = [ "GCC=cc" "CC_STD=-std=c99" "LDFLAGS=-lm" ];
+
+  preInstall = ''
+    install -d ${placeholder "out"}/bin
+    install -d ${placeholder "out"}/share/simh
+  '';
+
+  installPhase = ''
+    runHook preInstall
+    for i in BIN/*; do
+      install -D $i ${placeholder "out"}/bin
+    done
+    for i in VAX/*bin; do
+      install -D $i ${placeholder "out"}/share/simh
+    done
+    runHook postInstall
+  '';
+
+  postInstall = ''
+    (cd $out/bin; for i in *; do ln -s $i simh-$i; done)
+  '';
+
+  meta = with lib; {
+    homepage = "http://simh.trailing-edge.com/";
+    description = "A collection of simulators of historic hardware";
+    longDescription = ''
+      SimH (History Simulator) is a collection of simulators for historically
+      significant or just plain interesting computer hardware and software from
+      the past. The goal of the project is to create highly portable system
+      simulators and to publish them as freeware on the Internet, with freely
+      available copies of significant or representative software.
+    '';
+    license = with licenses; mit;
+    maintainers = with maintainers; [ AndersonTorres ];
+    platforms = with platforms; unix;
+  };
+}
+# TODO: install documentation
diff --git a/nixpkgs/pkgs/misc/emulators/simplenes/default.nix b/nixpkgs/pkgs/misc/emulators/simplenes/default.nix
new file mode 100644
index 000000000000..d073098507ee
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/simplenes/default.nix
@@ -0,0 +1,33 @@
+{ lib, stdenv
+, fetchFromGitHub
+, cmake
+, sfml
+}:
+
+stdenv.mkDerivation rec {
+  pname = "simplenes";
+  version = "unstable-2019-03-13";
+
+  src = fetchFromGitHub {
+    owner = "amhndu";
+    repo = "SimpleNES";
+    rev = "4edb7117970c21a33b3bfe11a6606764fffc5173";
+    sha256 = "1nmwj431iwqzzcykxd4xinqmg0rm14mx7zsjyhcc5skz7pihz86g";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ sfml ];
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp ./SimpleNES $out/bin
+  '';
+
+  meta = with lib; {
+    homepage = "https://github.com/amhndu/SimpleNES";
+    description = "An NES emulator written in C++";
+    license = licenses.gpl3;
+    maintainers = with maintainers; [ ivar ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/snes9x-gtk/default.nix b/nixpkgs/pkgs/misc/emulators/snes9x-gtk/default.nix
new file mode 100644
index 000000000000..6698d0a5b488
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/snes9x-gtk/default.nix
@@ -0,0 +1,36 @@
+{ lib, stdenv, fetchFromGitHub, meson, ninja, pkg-config, wrapGAppsHook
+, SDL2, zlib, gtk3, libxml2, libXv, epoxy, minizip, pulseaudio, portaudio }:
+
+stdenv.mkDerivation rec {
+  pname = "snes9x-gtk";
+  version = "1.60";
+
+  src = fetchFromGitHub {
+    owner = "snes9xgit";
+    repo = "snes9x";
+    rev = version;
+    sha256 = "12hpn7zcdvp30ldpw2zf115yjqv55n1ldjbids7vx0lvbpr06dm1";
+  };
+
+  enableParallelBuilding = true;
+  nativeBuildInputs = [ meson ninja pkg-config wrapGAppsHook ];
+  buildInputs = [ SDL2 zlib gtk3 libxml2 libXv epoxy minizip pulseaudio portaudio ];
+
+  preConfigure = "cd gtk";
+
+  meta = with lib; {
+    homepage = "http://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.
+    '';
+
+    license = licenses.lgpl2;
+    maintainers = with maintainers; [ qknight ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/stella/default.nix b/nixpkgs/pkgs/misc/emulators/stella/default.nix
new file mode 100644
index 000000000000..458922bdc1da
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/stella/default.nix
@@ -0,0 +1,33 @@
+{ lib, stdenv, fetchFromGitHub, pkg-config, SDL2 }:
+
+stdenv.mkDerivation rec {
+  pname = "stella";
+  version = "6.4";
+
+  src = fetchFromGitHub {
+    owner = "stella-emu";
+    repo = pname;
+    rev = version;
+    sha256 = "0gva6pw5c1pplcf2g48zmm24h1134v0vr705rbzj4v6ifp3adrsl";
+  };
+
+  nativeBuildInputs = [ pkg-config ];
+  buildInputs = [ SDL2 ];
+
+  enableParallelBuilding = true;
+
+  meta = with lib;{
+    description = "An open-source Atari 2600 VCS emulator";
+    longDescription = ''
+    Stella is a multi-platform Atari 2600 VCS emulator released under
+    the GNU General Public License (GPL). Stella was originally
+    developed for Linux by Bradford W. Mott, and is currently
+    maintained by Stephen Anthony.
+    As of its 3.5 release, Stella is officially donationware.
+    '';
+    homepage = "https://stella-emu.github.io/";
+    license = licenses.gpl2;
+    maintainers = [ maintainers.AndersonTorres ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/termtekst/default.nix b/nixpkgs/pkgs/misc/emulators/termtekst/default.nix
new file mode 100644
index 000000000000..56f56cffad97
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/termtekst/default.nix
@@ -0,0 +1,36 @@
+{ lib, fetchFromGitHub, python3Packages, ncurses }:
+
+python3Packages.buildPythonApplication rec {
+  pname = "termtekst";
+  version = "1.0";
+
+  src = fetchFromGitHub {
+    owner = "zevv";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "1gm7j5d49a60wm7px82b76f610i8pl8ccz4r6qsz90z4mp3lyw9b";
+  };
+
+  propagatedBuildInputs = with python3Packages; [ ncurses requests ];
+
+  patchPhase = ''
+    substituteInPlace setup.py \
+      --replace "assert" "assert 1==1 #"
+    substituteInPlace src/tt \
+      --replace "locale.setlocale" "#locale.setlocale"
+    '';
+
+  meta = with lib; {
+    description = "Console NOS Teletekst viewer in Python";
+    longDescription = ''
+      Small Python app using curses to display Dutch NOS Teletekst on
+      the Linux console. The original Teletekst font includes 2x6
+      raster graphics glyphs which have no representation in unicode;
+      as a workaround the braille set is abused to approximate the
+      graphics.
+    '';
+    license = licenses.mit;
+    maintainers = with maintainers; [ leenaars ];
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/tilem/default.nix b/nixpkgs/pkgs/misc/emulators/tilem/default.nix
new file mode 100644
index 000000000000..d2252563d0a5
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/tilem/default.nix
@@ -0,0 +1,30 @@
+{ stdenv
+, fetchurl
+, lib
+, pkg-config
+, glib
+, gnome2
+, libticonv
+, libtifiles2
+, libticables2
+, libticalcs2
+}:
+
+stdenv.mkDerivation rec {
+  pname = "tilem";
+  version = "2.0";
+  src = fetchurl {
+    url = "mirror://sourceforge/${pname}/${pname}-${version}.tar.bz2";
+    sha256 = "1ba38xzhp3yf21ip3cgql6jzy49jc34sfnjsl4syxyrd81d269zw";
+  };
+  nativeBuildInputs = [ pkg-config ];
+  buildInputs = [ glib gnome2.gtk libticonv libtifiles2 libticables2 libticalcs2 ];
+  NIX_CFLAGS_COMPILE = [ "-lm" ];
+  meta = with lib; {
+    homepage = "http://lpg.ticalc.org/prj_tilem/";
+    description = "Emulator and debugger for Texas Instruments Z80-based graphing calculators";
+    license = licenses.gpl3Plus;
+    maintainers = with maintainers; [ siraben luc65r ];
+    platforms = platforms.linux ++ platforms.darwin;
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/uae/default.nix b/nixpkgs/pkgs/misc/emulators/uae/default.nix
new file mode 100644
index 000000000000..75b86eaeebd1
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/uae/default.nix
@@ -0,0 +1,26 @@
+{lib, stdenv, fetchurl, pkg-config, gtk2, alsaLib, SDL}:
+
+stdenv.mkDerivation rec {
+  name = "uae-0.8.29";
+
+  src = fetchurl {
+    url = "http://web.archive.org/web/20130905032631/http://www.amigaemulator.org/files/sources/develop/${name}.tar.bz2";
+    sha256 = "05s3cd1rd5a970s938qf4c2xm3l7f54g5iaqw56v8smk355m4qr4";
+  };
+
+  configureFlags = [ "--with-sdl" "--with-sdl-sound" "--with-sdl-gfx" "--with-alsa" ];
+
+  nativeBuildInputs = [ pkg-config ];
+  buildInputs = [ gtk2 alsaLib SDL ];
+
+  hardeningDisable = [ "format" ];
+  LDFLAGS = [ "-lm" ];
+
+  meta = {
+    description = "Ultimate/Unix/Unusable Amiga Emulator";
+    license = lib.licenses.gpl2Plus;
+    homepage = "http://web.archive.org/web/20130901222855/http://www.amigaemulator.org/";
+    maintainers = [ lib.maintainers.sander ];
+    platforms = lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/vbam/default.nix b/nixpkgs/pkgs/misc/emulators/vbam/default.nix
new file mode 100644
index 000000000000..c21f67845db4
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/vbam/default.nix
@@ -0,0 +1,57 @@
+{ lib, stdenv
+, cairo
+, cmake
+, fetchFromGitHub
+, ffmpeg
+, gettext
+, libGLU, libGL
+, openal
+, pkg-config
+, SDL2
+, sfml
+, zip
+, zlib
+}:
+
+stdenv.mkDerivation rec {
+  pname = "visualboyadvance-m";
+  version = "2.1.4";
+  src = fetchFromGitHub {
+    owner = "visualboyadvance-m";
+    repo = "visualboyadvance-m";
+    rev = "v${version}";
+    sha256 = "1kgpbvng3c12ws0dy92zc0azd94h0i3j4vm7b67zc8mi3pqsppdg";
+  };
+
+  nativeBuildInputs = [ cmake pkg-config ];
+
+  buildInputs = [
+    cairo
+    ffmpeg
+    gettext
+    libGLU libGL
+    openal
+    SDL2
+    sfml
+    zip
+    zlib
+  ];
+
+  cmakeFlags = [
+    "-DCMAKE_BUILD_TYPE='Release'"
+    "-DENABLE_FFMPEG='true'"
+    "-DENABLE_LINK='true'"
+    "-DSYSCONFDIR=etc"
+    "-DENABLE_WX='false'"
+    "-DENABLE_SDL='true'"
+  ];
+
+  meta =  with lib; {
+    description = "A merge of the original Visual Boy Advance forks";
+    license = licenses.gpl2;
+    maintainers = with maintainers; [ lassulus ];
+    homepage = "https://vba-m.com/";
+    platforms = lib.platforms.linux;
+    badPlatforms = [ "aarch64-linux" ];
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/vice/default.nix b/nixpkgs/pkgs/misc/emulators/vice/default.nix
new file mode 100644
index 000000000000..7d63927e33f6
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/vice/default.nix
@@ -0,0 +1,53 @@
+{ lib, stdenv, fetchurl, bison, flex, perl, libpng, giflib, libjpeg, alsaLib, readline, libGLU, libGL, libXaw
+, pkg-config, gtk2, SDL, autoreconfHook, makeDesktopItem
+}:
+
+stdenv.mkDerivation rec {
+  name = "vice-3.1";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/vice-emu/vice-3.1.tar.gz";
+    sha256 = "0h0jbml02s2a36hr78dxv1zshmfhxp1wadpcdl09aq416fb1bf1y";
+  };
+
+  buildInputs = [ bison flex perl libpng giflib libjpeg alsaLib readline libGLU libGL
+    pkg-config gtk2 SDL autoreconfHook libXaw ];
+  dontDisableStatic = true;
+  configureFlags = [ "--enable-fullscreen --enable-gnomeui" ];
+
+  desktopItem = makeDesktopItem {
+    name = "vice";
+    exec = "x64";
+    comment = "Commodore 64 emulator";
+    desktopName = "VICE";
+    genericName = "Commodore 64 emulator";
+    categories = "Emulator;";
+  };
+
+  preBuild = ''
+    for i in src/resid src/resid-dtv
+    do
+        mkdir -pv $i/src
+        ln -sv ../../wrap-u-ar.sh $i/src
+    done
+  '';
+  patchPhase = ''
+    # Disable font-cache update
+    sed -i -e "s|install: install-data-am|install-no: install-data-am|" data/fonts/Makefile.am
+  '';
+
+  #NIX_LDFLAGS = "-lX11 -L${libX11}/lib";
+
+  postInstall = ''
+    mkdir -p $out/share/applications
+    cp ${desktopItem}/share/applications/* $out/share/applications
+  '';
+
+  meta = {
+    description = "Commodore 64, 128 and other emulators";
+    homepage = "http://www.viceteam.org";
+    license = lib.licenses.gpl2Plus;
+    maintainers = [ lib.maintainers.sander ];
+    platforms = lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/wine/base.nix b/nixpkgs/pkgs/misc/emulators/wine/base.nix
new file mode 100644
index 000000000000..6d7c2543d805
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/wine/base.nix
@@ -0,0 +1,155 @@
+{ stdenv, lib, pkgArches, callPackage,
+  name, version, src, mingwGccs, monos, geckos, platforms,
+  bison, flex, fontforge, makeWrapper, pkg-config,
+  autoconf, hexdump, perl,
+  supportFlags,
+  patches,
+  buildScript ? null, configureFlags ? []
+}:
+
+with import ./util.nix { inherit lib; };
+
+let
+  vkd3d = callPackage ./vkd3d.nix {};
+  patches' = patches;
+in
+stdenv.mkDerivation ((lib.optionalAttrs (buildScript != null) {
+  builder = buildScript;
+}) // rec {
+  inherit name src configureFlags;
+
+  # Fixes "Compiler cannot create executables" building wineWow with mingwSupport
+  strictDeps = true;
+
+  nativeBuildInputs = [
+    bison
+    flex
+    fontforge
+    makeWrapper
+    pkg-config
+
+    # Required by staging
+    autoconf
+    hexdump
+    perl
+  ]
+  ++ lib.optionals supportFlags.mingwSupport mingwGccs;
+
+  buildInputs = toBuildInputs pkgArches (with supportFlags; (pkgs:
+  [ pkgs.freetype pkgs.perl pkgs.xorg.libX11 ]
+  ++ lib.optional stdenv.isLinux         pkgs.libcap
+  ++ lib.optional pngSupport             pkgs.libpng
+  ++ lib.optional jpegSupport            pkgs.libjpeg
+  ++ lib.optional cupsSupport            pkgs.cups
+  ++ lib.optional colorManagementSupport pkgs.lcms2
+  ++ lib.optional gettextSupport         pkgs.gettext
+  ++ lib.optional dbusSupport            pkgs.dbus
+  ++ lib.optional mpg123Support          pkgs.mpg123
+  ++ lib.optional openalSupport          pkgs.openal
+  ++ lib.optional cairoSupport           pkgs.cairo
+  ++ lib.optional tiffSupport            pkgs.libtiff
+  ++ lib.optional odbcSupport            pkgs.unixODBC
+  ++ lib.optional netapiSupport          pkgs.samba4
+  ++ lib.optional cursesSupport          pkgs.ncurses
+  ++ lib.optional vaSupport              pkgs.libva
+  ++ lib.optional pcapSupport            pkgs.libpcap
+  ++ lib.optional v4lSupport             pkgs.libv4l
+  ++ lib.optional saneSupport            pkgs.sane-backends
+  ++ lib.optional gsmSupport             pkgs.gsm
+  ++ lib.optional gphoto2Support         pkgs.libgphoto2
+  ++ lib.optional ldapSupport            pkgs.openldap
+  ++ lib.optional fontconfigSupport      pkgs.fontconfig
+  ++ lib.optional alsaSupport            pkgs.alsaLib
+  ++ lib.optional pulseaudioSupport      pkgs.libpulseaudio
+  ++ lib.optional xineramaSupport        pkgs.xorg.libXinerama
+  ++ lib.optional udevSupport            pkgs.udev
+  ++ lib.optional vulkanSupport          pkgs.vulkan-loader
+  ++ lib.optional sdlSupport             pkgs.SDL2
+  ++ lib.optional faudioSupport          pkgs.faudio
+  ++ lib.optional vkd3dSupport           vkd3d
+  ++ lib.optionals gstreamerSupport      (with pkgs.gst_all_1;
+    [ gstreamer gst-plugins-base gst-plugins-good gst-plugins-ugly gst-libav
+    (gst-plugins-bad.override { enableZbar = false; }) ])
+  ++ lib.optionals gtkSupport    [ pkgs.gtk3 pkgs.glib ]
+  ++ lib.optionals openclSupport [ pkgs.opencl-headers pkgs.ocl-icd ]
+  ++ lib.optionals xmlSupport    [ pkgs.libxml2 pkgs.libxslt ]
+  ++ lib.optionals tlsSupport    [ pkgs.openssl pkgs.gnutls ]
+  ++ lib.optionals openglSupport [ pkgs.libGLU pkgs.libGL pkgs.mesa.osmesa pkgs.libdrm ]
+  ++ lib.optionals stdenv.isDarwin (with pkgs.buildPackages.darwin.apple_sdk.frameworks; [
+     CoreServices Foundation ForceFeedback AppKit OpenGL IOKit DiskArbitration Security
+     ApplicationServices AudioToolbox CoreAudio AudioUnit CoreMIDI OpenAL OpenCL Cocoa Carbon
+  ])
+  ++ lib.optionals stdenv.isLinux  (with pkgs.xorg; [
+     libXi libXcursor libXrandr libXrender libXxf86vm libXcomposite libXext
+  ])));
+
+  patches = [ ] ++ patches';
+
+  # Wine locates a lot of libraries dynamically through dlopen().  Add
+  # them to the RPATH so that the user doesn't have to set them in
+  # LD_LIBRARY_PATH.
+  NIX_LDFLAGS = toString (map (path: "-rpath " + path) (
+      map (x: "${lib.getLib x}/lib") ([ stdenv.cc.cc ] ++ buildInputs)
+      # libpulsecommon.so is linked but not found otherwise
+      ++ lib.optionals supportFlags.pulseaudioSupport (map (x: "${lib.getLib x}/lib/pulseaudio")
+          (toBuildInputs pkgArches (pkgs: [ pkgs.libpulseaudio ])))
+    ));
+
+  # Don't shrink the ELF RPATHs in order to keep the extra RPATH
+  # elements specified above.
+  dontPatchELF = true;
+
+  ## FIXME
+  # Add capability to ignore known failing tests
+  # and enable doCheck
+  doCheck = false;
+
+  postInstall = let
+    links = prefix: pkg: "ln -s ${pkg} $out/${prefix}/${pkg.name}";
+  in ''
+    mkdir -p $out/share/wine/gecko $out/share/wine/mono/
+    ${lib.strings.concatStringsSep "\n"
+          ((map (links "share/wine/gecko") geckos)
+        ++ (map (links "share/wine/mono")  monos))}
+  '' + lib.optionalString supportFlags.gstreamerSupport ''
+    # Wrapping Wine is tricky.
+    # https://github.com/NixOS/nixpkgs/issues/63170
+    # https://github.com/NixOS/nixpkgs/issues/28486
+    # The main problem is that wine-preloader opens and loads the wine(64) binary, and
+    # breakage occurs if it finds a shell script instead of the real binary. We solve this
+    # by setting WINELOADER to point to the original binary. Additionally, the locations
+    # of the 32-bit and 64-bit binaries must differ only by the presence of "64" at the
+    # end, due to the logic Wine uses to find the other binary (see get_alternate_loader
+    # in dlls/kernel32/process.c). Therefore we do not use wrapProgram which would move
+    # the binaries to ".wine-wrapped" and ".wine64-wrapped", but use makeWrapper directly,
+    # and move the binaries to ".wine" and ".wine64".
+    for i in wine wine64 ; do
+      prog="$out/bin/$i"
+      if [ -e "$prog" ]; then
+        hidden="$(dirname "$prog")/.$(basename "$prog")"
+        mv "$prog" "$hidden"
+        makeWrapper "$hidden" "$prog" \
+          --argv0 "" \
+          --set WINELOADER "$hidden" \
+          --prefix GST_PLUGIN_SYSTEM_PATH_1_0 ":" "$GST_PLUGIN_SYSTEM_PATH_1_0"
+      fi
+    done
+  '';
+
+  enableParallelBuilding = true;
+
+  # https://bugs.winehq.org/show_bug.cgi?id=43530
+  # https://github.com/NixOS/nixpkgs/issues/31989
+  hardeningDisable = [ "bindnow" ]
+    ++ lib.optional (stdenv.hostPlatform.isDarwin) "fortify"
+    ++ lib.optional (supportFlags.mingwSupport) "format";
+
+  passthru = { inherit pkgArches; };
+  meta = {
+    inherit version platforms;
+    homepage = "https://www.winehq.org/";
+    license = with lib.licenses; [ lgpl21Plus ];
+    description = "An Open Source implementation of the Windows API on top of X, OpenGL, and Unix";
+    maintainers = with lib.maintainers; [ avnik raskin bendlas ];
+  };
+})
diff --git a/nixpkgs/pkgs/misc/emulators/wine/builder-wow.sh b/nixpkgs/pkgs/misc/emulators/wine/builder-wow.sh
new file mode 100644
index 000000000000..c006db3116b5
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/wine/builder-wow.sh
@@ -0,0 +1,30 @@
+## build described at http://wiki.winehq.org/Wine64
+
+source $stdenv/setup
+
+unpackPhase
+cd $TMP/$sourceRoot
+patchPhase
+
+configureScript=$TMP/$sourceRoot/configure
+mkdir -p $TMP/wine-wow $TMP/wine64
+
+cd $TMP/wine64
+sourceRoot=`pwd`
+configureFlags="--enable-win64"
+configurePhase
+buildPhase
+# checkPhase
+
+cd $TMP/wine-wow
+sourceRoot=`pwd`
+configureFlags="--with-wine64=../wine64"
+configurePhase
+buildPhase
+# checkPhase
+
+eval "$preInstall"
+cd $TMP/wine-wow && make install
+cd $TMP/wine64 && make install
+eval "$postInstall"
+fixupPhase
diff --git a/nixpkgs/pkgs/misc/emulators/wine/cert-path-stable.patch b/nixpkgs/pkgs/misc/emulators/wine/cert-path-stable.patch
new file mode 100644
index 000000000000..da01a4778102
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/wine/cert-path-stable.patch
@@ -0,0 +1,24 @@
+diff --git a/dlls/crypt32/rootstore.c b/dlls/crypt32/rootstore.c
+index f795181..fb4926a 100644
+--- a/dlls/crypt32/rootstore.c
++++ b/dlls/crypt32/rootstore.c
+@@ -18,6 +18,7 @@
+ #include "config.h"
+ #include <stdarg.h>
+ #include <stdio.h>
++#include <stdlib.h> /* getenv */
+ #include <sys/types.h>
+ #ifdef HAVE_SYS_STAT_H
+ #include <sys/stat.h>
+@@ -916,6 +917,11 @@ static void read_trusted_roots_from_known_locations(HCERTSTORE store)
+ 
+         for (i = 0; !ret && i < ARRAY_SIZE(CRYPT_knownLocations); i++)
+             ret = import_certs_from_path(CRYPT_knownLocations[i], from, TRUE);
++
++        char *nix_cert_file = getenv("NIX_SSL_CERT_FILE");
++        if (nix_cert_file != NULL)
++            ret = import_certs_from_path(nix_cert_file, from, TRUE);
++
+         check_and_store_certs(from, store);
+     }
+     CertCloseStore(from, 0);
diff --git a/nixpkgs/pkgs/misc/emulators/wine/cert-path.patch b/nixpkgs/pkgs/misc/emulators/wine/cert-path.patch
new file mode 100644
index 000000000000..18a90e1a9af8
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/wine/cert-path.patch
@@ -0,0 +1,23 @@
+diff --git a/dlls/crypt32/unixlib.c b/dlls/crypt32/unixlib.c
+index 035f2d936bb..959716d727a 100644
+--- a/dlls/crypt32/unixlib.c
++++ b/dlls/crypt32/unixlib.c
+@@ -24,6 +24,7 @@
+ #include "wine/port.h"
+ 
+ #include <stdarg.h>
++#include <stdlib.h>
+ #include <dirent.h>
+ #include <fcntl.h>
+ #include <unistd.h>
+@@ -605,6 +606,10 @@ static void load_root_certs(void)
+ 
+     for (i = 0; i < ARRAY_SIZE(CRYPT_knownLocations) && list_empty(&root_cert_list); i++)
+         import_certs_from_path( CRYPT_knownLocations[i], TRUE );
++
++    char *nix_cert_file = getenv("NIX_SSL_CERT_FILE");
++    if (nix_cert_file != NULL)
++        import_certs_from_path(nix_cert_file, TRUE);
+ }
+ 
+ static BOOL WINAPI enum_root_certs( void *buffer, SIZE_T size, SIZE_T *needed )
diff --git a/nixpkgs/pkgs/misc/emulators/wine/default.nix b/nixpkgs/pkgs/misc/emulators/wine/default.nix
new file mode 100644
index 000000000000..24f827b25ffe
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/wine/default.nix
@@ -0,0 +1,69 @@
+## Configuration:
+# Control you default wine config in nixpkgs-config:
+# wine = {
+#   release = "stable"; # "stable", "unstable", "staging"
+#   build = "wineWow"; # "wine32", "wine64", "wineWow"
+# };
+# Make additional configurations on demand:
+# wine.override { wineBuild = "wine32"; wineRelease = "staging"; };
+{ lib, stdenv, callPackage,
+  wineRelease ? "stable",
+  wineBuild ? if stdenv.hostPlatform.system == "x86_64-linux" then "wineWow" else "wine32",
+  pngSupport ? false,
+  jpegSupport ? false,
+  tiffSupport ? false,
+  gettextSupport ? false,
+  fontconfigSupport ? false,
+  alsaSupport ? false,
+  gtkSupport ? false,
+  openglSupport ? false,
+  tlsSupport ? false,
+  gstreamerSupport ? false,
+  cupsSupport ? false,
+  colorManagementSupport ? false,
+  dbusSupport ? false,
+  mpg123Support ? false,
+  openalSupport ? false,
+  openclSupport ? false,
+  cairoSupport ? false,
+  odbcSupport ? false,
+  netapiSupport ? false,
+  cursesSupport ? false,
+  vaSupport ? false,
+  pcapSupport ? false,
+  v4lSupport ? false,
+  saneSupport ? false,
+  gsmSupport ? false,
+  gphoto2Support ? false,
+  ldapSupport ? false,
+  pulseaudioSupport ? false,
+  udevSupport ? false,
+  xineramaSupport ? false,
+  xmlSupport ? false,
+  vulkanSupport ? false,
+  sdlSupport ? false,
+  faudioSupport ? false,
+  vkd3dSupport ? false,
+  mingwSupport ? false,
+}:
+
+let wine-build = build: release:
+      lib.getAttr build (callPackage ./packages.nix {
+        wineRelease = release;
+        supportFlags = {
+          inherit pngSupport jpegSupport cupsSupport colorManagementSupport gettextSupport
+                  dbusSupport mpg123Support openalSupport cairoSupport tiffSupport odbcSupport
+                  netapiSupport cursesSupport vaSupport pcapSupport v4lSupport saneSupport
+                  gsmSupport gphoto2Support ldapSupport fontconfigSupport alsaSupport
+                  pulseaudioSupport xineramaSupport gtkSupport openclSupport xmlSupport tlsSupport
+                  openglSupport gstreamerSupport udevSupport vulkanSupport sdlSupport faudioSupport
+                  vkd3dSupport mingwSupport;
+        };
+      });
+
+in if wineRelease == "staging" then
+  callPackage ./staging.nix {
+    wineUnstable = wine-build wineBuild "unstable";
+  }
+else
+  wine-build wineBuild wineRelease
diff --git a/nixpkgs/pkgs/misc/emulators/wine/fonts.nix b/nixpkgs/pkgs/misc/emulators/wine/fonts.nix
new file mode 100644
index 000000000000..0ee1b3973d86
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/wine/fonts.nix
@@ -0,0 +1,22 @@
+{ stdenv, lib, callPackage }:
+let src = (callPackage ./sources.nix {}).stable;
+in
+stdenv.mkDerivation {
+  pname = "wine-fonts";
+  inherit (src) version;
+
+  sourceRoot = "wine-${src.version}/fonts";
+  inherit src;
+
+  installPhase = ''
+    install *.ttf -Dt $out/share/fonts/wine
+  '';
+
+  meta = {
+    description = "Microsoft replacement fonts by the Wine project";
+    homepage = "https://wiki.winehq.org/Create_Fonts";
+    license = with lib.licenses; [ lgpl21Plus ];
+    platforms = lib.platforms.all;
+    maintainers = with lib.maintainers; [ avnik raskin bendlas johnazoidberg ];
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/wine/packages.nix b/nixpkgs/pkgs/misc/emulators/wine/packages.nix
new file mode 100644
index 000000000000..c4fec3360e1f
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/wine/packages.nix
@@ -0,0 +1,38 @@
+{ stdenv_32bit, lib, pkgs, pkgsi686Linux, pkgsCross, callPackage,
+  wineRelease ? "stable",
+  supportFlags
+}:
+
+let src = lib.getAttr wineRelease (callPackage ./sources.nix {});
+in with src; {
+  wine32 = pkgsi686Linux.callPackage ./base.nix {
+    name = "wine-${version}";
+    inherit src version supportFlags patches;
+    pkgArches = [ pkgsi686Linux ];
+    geckos = [ gecko32 ];
+    mingwGccs = with pkgsCross; [ mingw32.buildPackages.gcc ];
+    monos =  [ mono ];
+    platforms = [ "i686-linux" "x86_64-linux" ];
+  };
+  wine64 = callPackage ./base.nix {
+    name = "wine64-${version}";
+    inherit src version supportFlags patches;
+    pkgArches = [ pkgs ];
+    mingwGccs = with pkgsCross; [ mingwW64.buildPackages.gcc ];
+    geckos = [ gecko64 ];
+    monos =  [ mono ];
+    configureFlags = [ "--enable-win64" ];
+    platforms = [ "x86_64-linux" "x86_64-darwin" ];
+  };
+  wineWow = callPackage ./base.nix {
+    name = "wine-wow-${version}";
+    inherit src version supportFlags patches;
+    stdenv = stdenv_32bit;
+    pkgArches = [ pkgs pkgsi686Linux ];
+    geckos = [ gecko32 gecko64 ];
+    mingwGccs = with pkgsCross; [ mingw32.buildPackages.gcc mingwW64.buildPackages.gcc ];
+    monos =  [ mono ];
+    buildScript = ./builder-wow.sh;
+    platforms = [ "x86_64-linux" ];
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/wine/sources.nix b/nixpkgs/pkgs/misc/emulators/wine/sources.nix
new file mode 100644
index 000000000000..3a5abe18d754
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/wine/sources.nix
@@ -0,0 +1,78 @@
+{ pkgs ? import <nixpkgs> {} }:
+## we default to importing <nixpkgs> here, so that you can use
+## a simple shell command to insert new sha256's into this file
+## e.g. with emacs C-u M-x shell-command
+##
+##     nix-prefetch-url sources.nix -A {stable{,.mono,.gecko64,.gecko32}, unstable, staging, winetricks}
+
+# here we wrap fetchurl and fetchFromGitHub, in order to be able to pass additional args around it
+let fetchurl = args@{url, sha256, ...}:
+  pkgs.fetchurl { inherit url sha256; } // args;
+    fetchFromGitHub = args@{owner, repo, rev, sha256, ...}:
+  pkgs.fetchFromGitHub { inherit owner repo rev sha256; } // args;
+in rec {
+
+  stable = fetchurl rec {
+    version = "5.0.3";
+    url = "https://dl.winehq.org/wine/source/5.0/wine-${version}.tar.xz";
+    sha256 = "sha256-nBo1Ni/VE9/1yEW/dtpj6hBaeUrHFEqlA/cTYa820i8=";
+
+    ## see http://wiki.winehq.org/Gecko
+    gecko32 = fetchurl rec {
+      version = "2.47.1";
+      url = "https://dl.winehq.org/wine/wine-gecko/${version}/wine-gecko-${version}-x86.msi";
+      sha256 = "0ld03pjm65xkpgqkvfsmk6h9krjsqbgxw4b8rvl2fj20j8l0w2zh";
+    };
+    gecko64 = fetchurl rec {
+      version = "2.47.1";
+      url = "https://dl.winehq.org/wine/wine-gecko/${version}/wine-gecko-${version}-x86_64.msi";
+      sha256 = "0jj7azmpy07319238g52a8m4nkdwj9g010i355ykxnl8m5wjwcb9";
+    };
+
+    ## see http://wiki.winehq.org/Mono
+    mono = fetchurl rec {
+      version = "5.1.1";
+      url = "https://dl.winehq.org/wine/wine-mono/${version}/wine-mono-${version}-x86.msi";
+      sha256 = "09wjrfxbw0072iv6d2vqnkc3y7dzj15vp8mv4ay44n1qp5ji4m3l";
+    };
+
+    patches = [
+      # Also look for root certificates at $NIX_SSL_CERT_FILE
+      ./cert-path-stable.patch
+    ];
+  };
+
+  unstable = fetchurl rec {
+    # NOTE: Don't forget to change the SHA256 for staging as well.
+    version = "6.0-rc4";
+    url = "https://dl.winehq.org/wine/source/6.0/wine-${version}.tar.xz";
+    sha256 = "sha256-ndeBORgnfYmtPbvZEesaetocknePF8cnyjqfulkcfsU=";
+    inherit (stable) mono gecko32 gecko64;
+
+    patches = [
+      # Also look for root certificates at $NIX_SSL_CERT_FILE
+      ./cert-path.patch
+     ];
+  };
+
+  staging = fetchFromGitHub rec {
+    # https://github.com/wine-staging/wine-staging/releases
+    inherit (unstable) version;
+    sha256 = "sha256-GdFiCGnGSDOxGERlfsPMJdSrQTvnx8gf4z4joqIKT7c=";
+    owner = "wine-staging";
+    repo = "wine-staging";
+    rev = "v${version}";
+
+    # Just keep list empty, if current release haven't broken patchsets
+    disabledPatchsets = [ ];
+  };
+
+  winetricks = fetchFromGitHub rec {
+    # https://github.com/Winetricks/winetricks/releases
+    version = "20201206";
+    sha256 = "1xs09v1zr98yvwvdsmzgryc2hbk92mwn54yxx8162l461465razc";
+    owner = "Winetricks";
+    repo = "winetricks";
+    rev = version;
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/wine/staging.nix b/nixpkgs/pkgs/misc/emulators/wine/staging.nix
new file mode 100644
index 000000000000..24da1d86bbfd
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/wine/staging.nix
@@ -0,0 +1,28 @@
+{ lib, stdenv, callPackage, wineUnstable }:
+
+with callPackage ./util.nix {};
+
+let patch = (callPackage ./sources.nix {}).staging;
+    build-inputs = pkgNames: extra:
+      (mkBuildInputs wineUnstable.pkgArches pkgNames) ++ extra;
+in assert lib.getVersion wineUnstable == patch.version;
+
+(lib.overrideDerivation wineUnstable (self: {
+  buildInputs = build-inputs [ "perl" "util-linux" "autoconf" "gitMinimal" ] self.buildInputs;
+
+  name = "${self.name}-staging";
+
+  postPatch = self.postPatch or "" + ''
+    patchShebangs tools
+    cp -r ${patch}/patches .
+    chmod +w patches
+    cd patches
+    patchShebangs gitapply.sh
+    ./patchinstall.sh DESTDIR="$PWD/.." --all ${lib.concatMapStringsSep " " (ps: "-W ${ps}") patch.disabledPatchsets}
+    cd ..
+  '';
+})) // {
+  meta = wineUnstable.meta // {
+    description = wineUnstable.meta.description + " (with staging patches)";
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/wine/util.nix b/nixpkgs/pkgs/misc/emulators/wine/util.nix
new file mode 100644
index 000000000000..cd5bd03130b6
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/wine/util.nix
@@ -0,0 +1,9 @@
+{ lib }:
+rec {
+  toPackages = pkgNames: pkgs:
+    map (pn: lib.getAttr pn pkgs) pkgNames;
+  toBuildInputs = pkgArches: archPkgs:
+    lib.concatLists (map archPkgs pkgArches);
+  mkBuildInputs = pkgArches: pkgNames:
+    toBuildInputs pkgArches (toPackages pkgNames);
+}
diff --git a/nixpkgs/pkgs/misc/emulators/wine/vkd3d.nix b/nixpkgs/pkgs/misc/emulators/wine/vkd3d.nix
new file mode 100644
index 000000000000..303d33df217d
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/wine/vkd3d.nix
@@ -0,0 +1,26 @@
+{ lib, stdenv, fetchurl, vulkan-headers, spirv-headers, vulkan-loader }:
+
+#TODO: MoltenVK
+#TODO: unstable
+
+stdenv.mkDerivation rec {
+  pname = "vkd3d";
+  version = "1.2";
+
+  src = fetchurl {
+    url = "https://dl.winehq.org/vkd3d/source/vkd3d-${version}.tar.xz";
+    sha256 = "0szr1lw3xbgi9qjm13d1q4gyzzwv8i5wfxiwjg6dmwphrc7h6jxh";
+  };
+
+  buildInputs = [ vulkan-headers spirv-headers vulkan-loader ];
+
+  enableParallelBuilding = true;
+
+  meta = with lib; {
+    description = "A 3d library build on top on Vulkan with a similar api to DirectX 12";
+    homepage = "https://source.winehq.org/git/vkd3d.git";
+    license = licenses.lgpl21;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.marius851000 ];
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/wine/winetricks.nix b/nixpkgs/pkgs/misc/emulators/wine/winetricks.nix
new file mode 100644
index 000000000000..cfde64fc33ac
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/wine/winetricks.nix
@@ -0,0 +1,32 @@
+{ lib, stdenv, callPackage, wine, perl, which, coreutils, zenity, curl
+, cabextract, unzip, p7zip, gnused, gnugrep, bash } :
+
+stdenv.mkDerivation rec {
+  name = "winetricks-${src.version}";
+
+  src = (callPackage ./sources.nix {}).winetricks;
+
+  buildInputs = [ perl which ];
+
+  # coreutils is for sha1sum
+  pathAdd = lib.concatMapStringsSep ":" (x: x + "/bin")
+    (lib.filter (x: x != null)
+      [ wine perl which coreutils zenity curl cabextract unzip p7zip gnused gnugrep bash ]);
+
+  makeFlags = [ "PREFIX=$(out)" ];
+
+  doCheck = false; # requires "bashate"
+
+  postInstall = ''
+    sed -i \
+      -e '2i PATH="${pathAdd}:$PATH"' \
+      "$out/bin/winetricks"
+  '';
+
+  meta = {
+    description = "A script to install DLLs needed to work around problems in Wine";
+    license = lib.licenses.lgpl21;
+    homepage = "https://github.com/Winetricks/winetricks";
+    platforms = with lib.platforms; linux;
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/wxmupen64plus/default.nix b/nixpkgs/pkgs/misc/emulators/wxmupen64plus/default.nix
new file mode 100644
index 000000000000..8621d213b79d
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/wxmupen64plus/default.nix
@@ -0,0 +1,30 @@
+{ lib, stdenv, fetchurl, python, wxGTK29, mupen64plus, SDL, libX11, libGLU, libGL
+, wafHook }:
+
+stdenv.mkDerivation {
+  name = "wxmupen64plus-0.3";
+  src = fetchurl {
+    url = "https://bitbucket.org/auria/wxmupen64plus/get/0.3.tar.bz2";
+    sha256 = "1mnxi4k011dd300k35li2p6x4wccwi6im21qz8dkznnz397ps67c";
+  };
+
+  nativeBuildInputs = [ wafHook ];
+  buildInputs = [ python wxGTK29 SDL libX11 libGLU libGL ];
+
+  preConfigure = ''
+    tar xf ${mupen64plus.src}
+    APIDIR=$(eval echo `pwd`/mupen64plus*/source/mupen64plus-core/src/api)
+    export CXXFLAGS="-I${libX11.dev}/include/X11 -DLIBDIR=\\\"${mupen64plus}/lib/\\\""
+    export LDFLAGS="-lwx_gtk2u_adv-2.9"
+
+    wafConfigureFlagsArray+=("--mupenapi=$APIDIR" "--wxconfig=`type -P wx-config`")
+  '';
+
+  NIX_CFLAGS_COMPILE = "-fpermissive";
+
+  meta = {
+    description = "GUI for the Mupen64Plus 2.0 emulator";
+    license = lib.licenses.gpl2Plus;
+    homepage = "https://bitbucket.org/auria/wxmupen64plus/wiki/Home";
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/xcpc/default.nix b/nixpkgs/pkgs/misc/emulators/xcpc/default.nix
new file mode 100644
index 000000000000..633d44bb5ae4
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/xcpc/default.nix
@@ -0,0 +1,29 @@
+{ lib, stdenv, fetchurl, pkg-config, glib, libXaw, libX11, libXext
+  , libDSKSupport ? true, libdsk
+  , motifSupport ? false, lesstif
+}:
+
+with lib;
+stdenv.mkDerivation rec {
+  version = "20070122";
+  pname = "xcpc";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/xcpc/${pname}-${version}.tar.gz";
+    sha256 = "0hxsbhmyzyyrlidgg0q8izw55q0z40xrynw5a1c3frdnihj9jf7n";
+  };
+
+  nativeBuildInputs = [ pkg-config ];
+
+  buildInputs = [ glib libdsk libXaw libX11 libXext ]
+    ++ optional libDSKSupport libdsk
+    ++ optional motifSupport lesstif;
+
+  meta = {
+    description = "A portable Amstrad CPC 464/664/6128 emulator written in C";
+    homepage = "https://www.xcpc-emulator.net";
+    license = licenses.gpl2Plus;
+    maintainers = [ ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/yabause/0001-Fixes-for-Qt-5.11-upgrade.patch b/nixpkgs/pkgs/misc/emulators/yabause/0001-Fixes-for-Qt-5.11-upgrade.patch
new file mode 100644
index 000000000000..43539ef4ca58
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/yabause/0001-Fixes-for-Qt-5.11-upgrade.patch
@@ -0,0 +1,67 @@
+From 3140afd6fb7dad7a25296526a71b005fb9eae048 Mon Sep 17 00:00:00 2001
+From: Samuel Dionne-Riel <samuel@dionne-riel.com>
+Date: Sat, 8 Sep 2018 00:44:08 -0400
+Subject: [PATCH] Fixes for Qt 5.11 upgrade
+
+---
+ src/qt/ui/UICheatRaw.cpp | 2 --
+ src/qt/ui/UICheatRaw.h   | 2 +-
+ src/qt/ui/UICheats.cpp   | 2 ++
+ src/qt/ui/UIHexInput.h   | 2 ++
+ 4 files changed, 5 insertions(+), 3 deletions(-)
+
+diff --git a/src/qt/ui/UICheatRaw.cpp b/src/qt/ui/UICheatRaw.cpp
+index 4ad82d77..3f78486b 100755
+--- a/src/qt/ui/UICheatRaw.cpp
++++ b/src/qt/ui/UICheatRaw.cpp
+@@ -20,8 +20,6 @@
+ #include "UIHexInput.h"

+ #include "../QtYabause.h"

+ 

+-#include <QButtonGroup>

+-

+ UICheatRaw::UICheatRaw( QWidget* p )

+ 	: QDialog( p )

+ {

+diff --git a/src/qt/ui/UICheatRaw.h b/src/qt/ui/UICheatRaw.h
+index d97b429d..20318c67 100755
+--- a/src/qt/ui/UICheatRaw.h
++++ b/src/qt/ui/UICheatRaw.h
+@@ -21,7 +21,7 @@
+ 

+ #include "ui_UICheatRaw.h"

+ 

+-class QButtonGroup;

++#include <QButtonGroup>

+ 

+ class UICheatRaw : public QDialog, public Ui::UICheatRaw

+ {

+diff --git a/src/qt/ui/UICheats.cpp b/src/qt/ui/UICheats.cpp
+index c6027972..44d341c3 100755
+--- a/src/qt/ui/UICheats.cpp
++++ b/src/qt/ui/UICheats.cpp
+@@ -21,6 +21,8 @@
+ #include "UICheatRaw.h"
+ #include "../CommonDialogs.h"
+ 
++#include <QButtonGroup>
++
+ UICheats::UICheats( QWidget* p )
+ 	: QDialog( p )
+ {
+diff --git a/src/qt/ui/UIHexInput.h b/src/qt/ui/UIHexInput.h
+index f333b016..4bd8aed4 100644
+--- a/src/qt/ui/UIHexInput.h
++++ b/src/qt/ui/UIHexInput.h
+@@ -22,6 +22,8 @@
+ #include "ui_UIHexInput.h"

+ #include "../QtYabause.h"

+ 

++#include <QValidator>

++

+ class HexValidator : public QValidator

+ {

+    Q_OBJECT

+-- 
+2.16.4
+
diff --git a/nixpkgs/pkgs/misc/emulators/yabause/default.nix b/nixpkgs/pkgs/misc/emulators/yabause/default.nix
new file mode 100644
index 000000000000..43f077227dbf
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/yabause/default.nix
@@ -0,0 +1,36 @@
+{ mkDerivation, lib, stdenv, fetchurl, cmake, pkg-config, qtbase, qt5, libGLU, libGL
+, freeglut ? null, openal ? null, SDL2 ? null }:
+
+mkDerivation rec {
+  pname = "yabause";
+  version = "0.9.15";
+
+  src = fetchurl {
+    url = "https://download.tuxfamily.org/yabause/releases/${version}/${pname}-${version}.tar.gz";
+    sha256 = "1cn2rjjb7d9pkr4g5bqz55vd4pzyb7hg94cfmixjkzzkw0zw8d23";
+  };
+
+  nativeBuildInputs = [ cmake pkg-config ];
+  buildInputs = [ qtbase qt5.qtmultimedia libGLU libGL freeglut openal SDL2 ];
+
+  patches = [
+    ./linkage-rwx-linux-elf.patch
+    # Fixes derived from
+    # https://github.com/Yabause/yabause/commit/06a816c032c6f7fd79ced6e594dd4b33571a0e73
+    ./0001-Fixes-for-Qt-5.11-upgrade.patch
+  ];
+
+  cmakeFlags = [
+    "-DYAB_NETWORK=ON"
+    "-DYAB_OPTIMIZED_DMA=ON"
+    "-DYAB_PORTS=qt"
+  ] ;
+
+  meta = with lib; {
+    description = "An open-source Sega Saturn emulator";
+    homepage = "https://yabause.org/";
+    license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ AndersonTorres ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/yabause/linkage-rwx-linux-elf.patch b/nixpkgs/pkgs/misc/emulators/yabause/linkage-rwx-linux-elf.patch
new file mode 100644
index 000000000000..bb0491b373f8
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/yabause/linkage-rwx-linux-elf.patch
@@ -0,0 +1,20 @@
+--- a/src/sh2_dynarec/linkage_x64.s	2013-03-11 20:29:53.112870900 +0100
++++ b/src/sh2_dynarec/linkage_x64.s	2013-03-11 20:31:48.856778600 +0100
+@@ -747,3 +747,7 @@ breakpoint:
+ 	ret
+ 	/* Set breakpoint here for debugging */
+ 	.size	breakpoint, .-breakpoint
++
++#if defined(__linux__) && defined(__ELF__)
++.section .note.GNU-stack,"",%progbits
++#endif
+--- a/src/sh2_dynarec/linkage_x86.s	2013-03-11 20:30:08.157693100 +0100
++++ b/src/sh2_dynarec/linkage_x86.s	2013-03-11 20:32:30.993310600 +0100
+@@ -743,3 +743,7 @@ breakpoint:
+ 	ret
+ 	/* Set breakpoint here for debugging */
+ 	.size	breakpoint, .-breakpoint
++
++#if defined(__linux__) && defined(__ELF__)
++.section .note.GNU-stack,"",%progbits
++#endif
diff --git a/nixpkgs/pkgs/misc/emulators/yuzu/default.nix b/nixpkgs/pkgs/misc/emulators/yuzu/default.nix
new file mode 100644
index 000000000000..5bb01b9fca08
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/yuzu/default.nix
@@ -0,0 +1,47 @@
+{ lib, stdenv, fetchFromGitHub
+, cmake, pkg-config, wrapQtAppsHook
+, boost173, catch2, fmt, lz4, nlohmann_json, rapidjson, zlib, zstd, SDL2
+, udev, libusb1, libzip, qtbase, qtwebengine, qttools, ffmpeg
+, libpulseaudio, libjack2, alsaLib, sndio, ecasound
+, useVulkan ? true, vulkan-loader, vulkan-headers
+}:
+
+stdenv.mkDerivation rec {
+  pname = "yuzu";
+  version = "482";
+
+  src = fetchFromGitHub {
+    owner = "yuzu-emu";
+    repo = "yuzu-mainline"; # They use a separate repo for mainline “branch”
+    rev = "mainline-0-${version}";
+    sha256 = "1bhkdbhj1dv33qv0np26gzsw65p4z88whjmd6bc7mh2b5lvrjwxm";
+    fetchSubmodules = true;
+  };
+
+  nativeBuildInputs = [ cmake pkg-config wrapQtAppsHook ];
+  buildInputs = [ qtbase qtwebengine qttools boost173 catch2 fmt lz4 nlohmann_json rapidjson zlib zstd SDL2 udev libusb1 libpulseaudio alsaLib sndio ecasound libjack2 libzip ffmpeg ]
+    ++ lib.optionals useVulkan [ vulkan-loader vulkan-headers ];
+  cmakeFlags = [ "-DENABLE_QT_TRANSLATION=ON" "-DYUZU_USE_QT_WEB_ENGINE=ON" "-DUSE_DISCORD_PRESENCE=ON" ]
+    ++ lib.optionals (!useVulkan) [ "-DENABLE_VULKAN=No" ];
+
+  # Trick the configure system. This prevents a check for submodule directories.
+  preConfigure = "rm .gitmodules";
+
+  # Fix vulkan detection
+  postFixup = lib.optionals useVulkan ''
+    wrapProgram $out/bin/yuzu --prefix LD_LIBRARY_PATH : ${vulkan-loader}/lib
+    wrapProgram $out/bin/yuzu-cmd --prefix LD_LIBRARY_PATH : ${vulkan-loader}/lib
+  '';
+
+  meta = with lib; {
+    homepage = "https://yuzu-emu.org";
+    description = "An experimental Nintendo Switch emulator written in C++";
+    license = with licenses; [
+      gpl2Plus
+      # Icons
+      cc-by-nd-30 cc0
+    ];
+    maintainers = with maintainers; [ ivar joshuafern ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/misc/emulators/zsnes/default.nix b/nixpkgs/pkgs/misc/emulators/zsnes/default.nix
new file mode 100644
index 000000000000..4a6b1fbda279
--- /dev/null
+++ b/nixpkgs/pkgs/misc/emulators/zsnes/default.nix
@@ -0,0 +1,63 @@
+{ lib, stdenv, fetchFromGitHub, nasm, SDL, zlib, libpng, ncurses, libGLU, libGL
+, makeDesktopItem }:
+
+let
+  desktopItem = makeDesktopItem {
+    name = "zsnes";
+    exec = "zsnes";
+    icon = "zsnes";
+    comment = "A SNES emulator";
+    desktopName = "zsnes";
+    genericName = "zsnes";
+    categories = "Game;";
+  };
+
+in stdenv.mkDerivation {
+  name = "zsnes-1.51";
+
+  src = fetchFromGitHub {
+    owner = "emillon";
+    repo = "zsnes";
+    rev = "fc160b2538738995f600f8405d23a66b070dac02";
+    sha256 = "1gy79d5wdaacph0cc1amw7mqm7i0716n6mvav16p1svi26iz193v";
+  };
+
+  buildInputs = [ nasm SDL zlib libpng ncurses libGLU libGL ];
+
+  prePatch = ''
+    for i in $(cat debian/patches/series); do
+      echo "applying $i"
+      patch -p1 < "debian/patches/$i"
+    done
+  '';
+
+  preConfigure = ''
+    cd src
+    sed -i "/^STRIP/d" configure
+    sed -i "/\$STRIP/d" configure
+  '';
+
+  configureFlags = [ "--enable-release" ];
+
+  postInstall = ''
+    function installIcon () {
+        mkdir -p $out/share/icons/hicolor/$1/apps/
+        cp icons/$1x32.png $out/share/icons/hicolor/$1/apps/zsnes.png
+    }
+    installIcon "16x16"
+    installIcon "32x32"
+    installIcon "48x48"
+    installIcon "64x64"
+
+    mkdir -p $out/share/applications
+    ln -s ${desktopItem}/share/applications/* $out/share/applications/
+  '';
+
+  meta = {
+    description = "A Super Nintendo Entertainment System Emulator";
+    license = lib.licenses.gpl2Plus;
+    maintainers = [ lib.maintainers.sander ];
+    homepage = "http://www.zsnes.com";
+    platforms = [ "i686-linux" "x86_64-linux" ];
+  };
+}