17 , enableSdl2 ? true, SDL2
18 , enableQt ? true, qtbase, qtmultimedia, wrapQtAppsHook
19 , enableQtTranslation ? enableQt, qttools
20 , enableWebService ? true
21 , enableCubeb ? true, cubeb
22 , enableFfmpegAudioDecoder ? true
23 , enableFfmpegVideoDumper ? true
25 , useDiscordRichPresence ? true, rapidjson
26 , enableFdk ? false, fdk_aac
28 assert lib.assertMsg (!enableFfmpegAudioDecoder || !enableFdk) "Can't enable both enableFfmpegAudioDecoder and enableFdk";
30 stdenv.mkDerivation rec {
31 inherit pname version src;
37 ] ++ lib.optionals enableQt [ wrapQtAppsHook ];
42 ] ++ lib.optionals enableQt [ qtbase qtmultimedia ]
43 ++ lib.optional enableSdl2 SDL2
44 ++ lib.optional enableQtTranslation qttools
45 ++ lib.optionals enableCubeb cubeb.passthru.backendLibs
46 ++ lib.optional (enableFfmpegAudioDecoder || enableFfmpegVideoDumper) ffmpeg_4
47 ++ lib.optional useDiscordRichPresence rapidjson
48 ++ lib.optional enableFdk fdk_aac;
51 "-DUSE_SYSTEM_BOOST=ON"
52 "-DCITRA_WARNINGS_AS_ERRORS=OFF"
53 "-DCITRA_USE_BUNDLED_FFMPEG=OFF"
54 "-DCITRA_USE_BUNDLED_QT=OFF"
55 "-DUSE_SYSTEM_SDL2=ON"
56 "-DCMAKE_INSTALL_INCLUDEDIR=include"
57 "-DCMAKE_INSTALL_LIBDIR=lib"
59 # We dont want to bother upstream with potentially outdated compat reports
60 "-DCITRA_ENABLE_COMPATIBILITY_REPORTING=ON"
61 "-DENABLE_COMPATIBILITY_LIST_DOWNLOAD=OFF" # We provide this deterministically
62 ] ++ lib.optional (!enableSdl2) "-DENABLE_SDL2=OFF"
63 ++ lib.optional (!enableQt) "-DENABLE_QT=OFF"
64 ++ lib.optional enableQtTranslation "-DENABLE_QT_TRANSLATION=ON"
65 ++ lib.optional (!enableWebService) "-DENABLE_WEB_SERVICE=OFF"
66 ++ lib.optional (!enableCubeb) "-DENABLE_CUBEB=OFF"
67 ++ lib.optional enableFfmpegAudioDecoder "-DENABLE_FFMPEG_AUDIO_DECODER=ON"
68 ++ lib.optional enableFfmpegVideoDumper "-DENABLE_FFMPEG_VIDEO_DUMPER=ON"
69 ++ lib.optional useDiscordRichPresence "-DUSE_DISCORD_PRESENCE=ON"
70 ++ lib.optional enableFdk "-DENABLE_FDK=ON";
72 postPatch = with lib; let
73 branchCaptialized = (lib.toUpper (lib.substring 0 1 branch) + lib.substring 1 (-1) branch);
75 # Fix file not found when looking in var/empty instead of opt
76 mkdir externals/dynarmic/src/dynarmic/ir/var
77 ln -s ../opt externals/dynarmic/src/dynarmic/ir/var/empty
79 # Prep compatibilitylist
80 ln -s ${compat-list} ./dist/compatibility_list/compatibility_list.json
82 # We already know the submodules are present
83 substituteInPlace CMakeLists.txt \
84 --replace "check_submodules_present()" ""
87 echo 'set(BUILD_FULLNAME "${branchCaptialized} ${version}")' >> CMakeModules/GenerateBuildInfo.cmake
90 rm -rf externals/zstd externals/libressl
91 cp -r ${zstd.src} externals/zstd
92 tar xf ${libressl.src} -C externals/
93 mv externals/${libressl.name} externals/libressl
94 chmod -R a+w externals/zstd
97 # Fixes https://github.com/NixOS/nixpkgs/issues/171173
98 postInstall = lib.optionalString (enableCubeb && enableSdl2) ''
99 wrapProgram "$out/bin/citra" \
100 --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath cubeb.passthru.backendLibs}
104 broken = (stdenv.isLinux && stdenv.isAarch64);
105 homepage = "https://citra-emu.org";
106 description = "The ${branch} branch of an open-source emulator for the Ninteno 3DS";
108 A Nintendo 3DS Emulator written in C++
109 Using the nightly branch is recommended for general usage.
110 Using the canary branch is recommended if you would like to try out
111 experimental features, with a cost of stability.
113 mainProgram = if enableQt then "citra-qt" else "citra";
114 platforms = platforms.linux;
115 license = licenses.gpl2Plus;
116 maintainers = with maintainers; [