anchor.diff:  , fetchFromGitHub
   , cmake
   , wrapQtAppsHook
  -, SDL2
  -, qtbase
  -, qtmultimedia
   , boost17x
  -, libpulseaudio
   , pkg-config
   , libusb1
   , zstd
   , libressl
  -, alsa-lib
  -, rapidjson
  -, aacHleDecoding ? true
  -, fdk_aac
  -, ffmpeg-full
  +, enableSdl2 ? true, SDL2
  +, enableQt ? true, qtbase, qtmultimedia
  +, enableQtTranslation ? enableQt, qttools
  +, enableWebService ? true
  +, enableCubeb ? true, libpulseaudio
  +, enableFfmpegAudioDecoder ? true
  +, enableFfmpegVideoDumper ? true
  +, ffmpeg
  +, useDiscordRichPresence ? true, rapidjson
  +, enableFdk ? false, fdk_aac
   }:
  +assert lib.assertMsg (!enableFfmpegAudioDecoder || !enableFdk) "Can't enable both enableFfmpegAudioDecoder and enableFdk";
   
   stdenv.mkDerivation {
     pname = "citra";
  
positive.code:     fetchSubmodules = true;
    };
  
    nativeBuildInputs = [ cmake wrapQtAppsHook pkg-config ];
    buildInputs = [
      SDL2
      qtbase
      qtmultimedia
      libpulseaudio
      boost17x
      libusb1
      alsa-lib
      rapidjson # for discord-rpc
    ] ++ lib.optional aacHleDecoding [ fdk_aac ffmpeg-full ];
  
    cmakeFlags = [
      "-DUSE_SYSTEM_BOOST=ON"
      "-DUSE_DISCORD_PRESENCE=ON"
    ] ++ lib.optionals aacHleDecoding [
      "-DENABLE_FFMPEG_AUDIO_DECODER=ON"
      "-DCITRA_USE_BUNDLED_FFMPEG=OFF"
    ];
  
    postPatch = ''
      # we already know the submodules are present
      substituteInPlace CMakeLists.txt \
        --replace "check_submodules_present()" ""
  
      # Trick configure system.
      sed -n 's,^ *path = \(.*\),\1,p' .gitmodules | while read path; do
      mkdir "$path/.git"
      done
  
      rm -rf externals/zstd externals/libressl
      cp -r ${zstd.src} externals/zstd
      tar xf ${libressl.src} -C externals/
  
negative.code:   '';
  
    # Todo: cubeb audio backend (the default one) doesn't work on the SDL interface.
    # This seems to be a problem with libpulseaudio, other applications have similar problems (e.g Duckstation).
    # Note that the two interfaces have two separate configuration files.
  
    meta = with lib; {
  