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:   '';
  
    # Todo: cubeb audio backend (the default one) doesn't work on the SDL interface.
    # Note that the two interfaces have two separate configuration files.
  
    meta = with lib; {
  
negative.code:     fetchSubmodules = true;
    };
  
    nativeBuildInputs = [
      cmake
      pkg-config
    ]
    ++ lib.optionals enableQt [ wrapQtAppsHook ];
  
    buildInputs = [
      boost17x
      libusb1
    ]
    ++ lib.optionals enableSdl2 [ SDL2 ]
    ++ lib.optionals enableQt [ qtbase qtmultimedia ]
    ++ lib.optionals enableQtTranslation [ qttools ]
    ++ lib.optionals enableCubeb [ libpulseaudio ]
    ++ lib.optionals (enableFfmpegAudioDecoder || enableFfmpegVideoDumper) [ ffmpeg ]
    ++ lib.optionals useDiscordRichPresence [ rapidjson ]
    ++ lib.optionals enableFdk [ fdk_aac ];
  
    cmakeFlags = [
      "-DUSE_SYSTEM_BOOST=ON"
    ]
    ++ lib.optionals (!enableSdl2) [ "-DENABLE_SDL2=OFF" ]
    ++ lib.optionals (!enableQt) [ "-DENABLE_QT=OFF" ]
    ++ lib.optionals enableQtTranslation [ "-DENABLE_QT_TRANSLATION=ON" ]
    ++ lib.optionals (!enableWebService) [ "-DENABLE_WEB_SERVICE=OFF" ]
    ++ lib.optionals (!enableCubeb) [ "-DENABLE_CUBEB=OFF" ]
    ++ lib.optionals enableFfmpegAudioDecoder [ "-DENABLE_FFMPEG_AUDIO_DECODER=ON"]
    ++ lib.optionals enableFfmpegVideoDumper [ "-DENABLE_FFMPEG_VIDEO_DUMPER=ON" ]
    ++ lib.optionals useDiscordRichPresence [ "-DUSE_DISCORD_PRESENCE=ON" ]
    ++ lib.optionals enableFdk [ "-DENABLE_FDK=ON" ];
  
    postPatch = ''
      # We already know the submodules are present
      substituteInPlace CMakeLists.txt \
        --replace "check_submodules_present()" ""
  
      # Devendoring
      rm -rf externals/zstd externals/libressl
      cp -r ${zstd.src} externals/zstd
      tar xf ${libressl.src} -C externals/
  