{ config, lib, pkgs, util, ... }: # RetroArch with the selected PlayStation and Sega Saturn cores. let cfg = config.modules.desktop.emulation.retroarch; user = config.user.name; in { options.modules.desktop.emulation.retroarch = { enable = lib.mkEnableOption "RetroArch with PlayStation and Sega Saturn cores"; browserDirectory = lib.mkOption { type = lib.types.str; default = ""; description = "Directory where RetroArch starts its content browser."; }; }; config = lib.mkIf cfg.enable { sops.secrets = lib.genAttrs [ "retroarch/romm/user" "retroarch/romm/password" "retroarch/retroachievements/user" "retroarch/retroachievements/password" ] (_: { sopsFile = ../../../secrets + "/${config.networking.hostName}.yaml"; }); sops.templates.retroarch-credentials = { owner = user; mode = "0400"; content = '' webdav_username = "${config.sops.placeholder."retroarch/romm/user"}" webdav_password = "${config.sops.placeholder."retroarch/romm/password"}" cheevos_username = "${config.sops.placeholder."retroarch/retroachievements/user"}" cheevos_password = "${config.sops.placeholder."retroarch/retroachievements/password"}" ''; }; home-manager.users.${user} = { home.file.".config/retroarch/retroarch.cfg" = { force = true; text = '' config_save_on_exit = "false" #include "${config.sops.templates.retroarch-credentials.path}" ''; }; home.packages = [ (pkgs.wrapRetroArch { cores = with pkgs.libretro; [ beetle-psx-hw beetle-saturn ]; settings = { savefiles_in_content_dir = "false"; savestates_in_content_dir = "false"; system_directory = "/home/${user}/.config/retroarch/system"; video_fullscreen = "true"; sort_savefiles_enable = "true"; sort_savestates_enable = "true"; cloud_sync_enable = "true"; cloud_sync_driver = "webdav"; webdav_url = "https://games.alexion.dev/api/sync/retroarch/"; cloud_sync_sync_saves = "true"; cloud_sync_sync_configs = "true"; cloud_sync_sync_thumbs = "false"; cloud_sync_sync_system = "false"; cloud_sync_sync_mode = "0"; cloud_sync_destructive = "false"; cheevos_enable = "true"; cheevos_hardcore_mode_enable = "false"; menu_driver = "xmb"; menu_shader_pipeline = "1"; xmb_menu_color_theme = "19"; content_show_add_entry = "0"; content_show_contentless_cores = "0"; content_show_explore = "false"; content_show_favorites = "false"; content_show_history = "false"; content_show_images = "false"; content_show_playlists = "false"; content_show_video = "false"; menu_icon_thumbnails = "3"; menu_thumbnails = "0"; network_on_demand_thumbnails = "true"; netplay_nickname = user; } // lib.optionalAttrs (cfg.browserDirectory != "") { rgui_browser_directory = cfg.browserDirectory; }; }) ]; }; registry.window-icon.${config.networking.hostName}.retroarch = { class = "com.libretro.RetroArch"; icon = util.glyph "f11b"; }; }; }