From ba81687d42dd076435801641f8ac62da78d8aaa8 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Tue, 15 Apr 2025 20:01:00 -0400 Subject: [PATCH] Add duckstation to the steam deck. --- nix/steam_deck/configuration/home.nix | 1 + .../configuration/hosts/deck/default.nix | 1 + .../roles/duckstation/default.nix | 90 +++++ .../roles/duckstation/files/settings.ini | 368 ++++++++++++++++++ 4 files changed, 460 insertions(+) create mode 100644 nix/steam_deck/configuration/roles/duckstation/default.nix create mode 100644 nix/steam_deck/configuration/roles/duckstation/files/settings.ini diff --git a/nix/steam_deck/configuration/home.nix b/nix/steam_deck/configuration/home.nix index d7f7806..db8b7d4 100644 --- a/nix/steam_deck/configuration/home.nix +++ b/nix/steam_deck/configuration/home.nix @@ -10,6 +10,7 @@ ./roles/2ship2harkinian ./roles/ares ./roles/dolphin + ./roles/duckstation ./roles/global_options ./roles/graphics ./roles/pcsx2 diff --git a/nix/steam_deck/configuration/hosts/deck/default.nix b/nix/steam_deck/configuration/hosts/deck/default.nix index ce3a43b..30944bd 100644 --- a/nix/steam_deck/configuration/hosts/deck/default.nix +++ b/nix/steam_deck/configuration/hosts/deck/default.nix @@ -11,6 +11,7 @@ config = { me.ares.enable = true; me.dolphin.enable = true; + me.duckstation.enable = true; me.graphical = true; me.optimizations.enable = true; me.pcsx2.enable = true; diff --git a/nix/steam_deck/configuration/roles/duckstation/default.nix b/nix/steam_deck/configuration/roles/duckstation/default.nix new file mode 100644 index 0000000..26833f1 --- /dev/null +++ b/nix/steam_deck/configuration/roles/duckstation/default.nix @@ -0,0 +1,90 @@ +{ + config, + lib, + pkgs, + ... +}: + +let + steam_duckstation = pkgs.writeScriptBin "steam_duckstation" '' + export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${pkgs.libglvnd}/lib" + exec ${pkgs.duckstation}/bin/duckstation-qt "''${@}" + ''; +in +{ + imports = [ ]; + + options.me = { + duckstation.enable = lib.mkOption { + type = lib.types.bool; + default = false; + example = true; + description = "Whether we want to install duckstation."; + }; + }; + + config = lib.mkIf config.me.duckstation.enable ( + lib.mkMerge [ + (lib.mkIf config.me.graphical { + home.packages = with pkgs; [ + duckstation + steam_duckstation + ]; + + home.file.".local/share/duckstation/settings.ini" = { + source = ./files/settings.ini; + }; + + me.persist.directories = [ + ".local/share/duckstation/memcards" + ".local/share/duckstation/savestates" + ]; + me.state.directories = [ + ".local/share/duckstation/cache" + ".local/share/duckstation/shaders" + ".local/share/duckstation/screenshots" + ".local/share/duckstation/videos" + ".local/share/duckstation/covers" + ]; + + nixpkgs.overlays = [ + ( + final: prev: + let + optimizeWithFlags = + pkg: flags: + pkg.overrideAttrs (old: { + env.CXXFLAGS = (old.env.CXXFLAGS or "") + (lib.strings.concatStringsSep " " flags); + }); + original_package = + if config.me.optimizations.enable then + (optimizeWithFlags prev.duckstation [ + "-march=znver2" + "-mtune=znver2" + ]) + else + prev.duckstation; + in + { + duckstation = pkgs.buildEnv { + name = prev.duckstation.name; + paths = [ + (config.lib.nixGL.wrap original_package) + ]; + extraOutputsToInstall = [ + "man" + "doc" + "info" + ]; + # We have to use 555 instead of the normal 444 here because the .desktop file ends up inside $HOME on steam deck and desktop files must be either not in $HOME or must be executable, otherwise KDE Plasma refuses to execute them. + postBuild = '' + chmod 0555 $out/share/applications/org.duckstation.DuckStation.desktop + ''; + }; + } + ) + ]; + }) + ] + ); +} diff --git a/nix/steam_deck/configuration/roles/duckstation/files/settings.ini b/nix/steam_deck/configuration/roles/duckstation/files/settings.ini new file mode 100644 index 0000000..c308636 --- /dev/null +++ b/nix/steam_deck/configuration/roles/duckstation/files/settings.ini @@ -0,0 +1,368 @@ +[Main] +SettingsVersion = 3 +EmulationSpeed = 1 +FastForwardSpeed = 0 +TurboSpeed = 0 +SyncToHostRefreshRate = false +IncreaseTimerResolution = true +InhibitScreensaver = true +StartPaused = false +StartFullscreen = false +PauseOnFocusLoss = true +PauseOnControllerDisconnection = false +SaveStateOnExit = true +CreateSaveStateBackups = true +SaveStateCompression = ZstDefault +ConfirmPowerOff = false +EnableDiscordPresence = false +LoadDevicesFromSaveStates = false +DisableAllEnhancements = false +RewindEnable = false +RewindFrequency = 10 +RewindSaveSlots = 10 +RunaheadFrameCount = 0 +SetupWizardIncomplete = false + + +[Console] +Region = Auto +Enable8MBRAM = false +EnableCheats = false + + +[PINE] +Enabled = false +Slot = 28011 + + +[CPU] +ExecutionMode = Recompiler +OverclockEnable = false +OverclockNumerator = 1 +OverclockDenominator = 1 +RecompilerMemoryExceptions = false +RecompilerBlockLinking = true +RecompilerICache = false +FastmemMode = MMap + + +[GPU] +Renderer = Automatic +Adapter = +ResolutionScale = 3 +Multisamples = 1 +UseDebugDevice = false +DisableShaderCache = false +DisableDualSourceBlend = false +DisableFramebufferFetch = false +DisableTextureBuffers = false +DisableTextureCopyToSelf = false +DisableMemoryImport = false +DisableRasterOrderViews = false +PerSampleShading = false +UseThread = true +ThreadedPresentation = false +UseSoftwareRendererForReadbacks = false +TrueColor = true +Debanding = false +ScaledDithering = true +ForceRoundTextureCoordinates = false +AccurateBlending = false +TextureFilter = Nearest +SpriteTextureFilter = +LineDetectMode = Disabled +DownsampleMode = Disabled +DownsampleScale = 1 +WireframeMode = Disabled +DisableInterlacing = true +ForceNTSCTimings = false +WidescreenHack = false +ChromaSmoothing24Bit = false +PGXPEnable = false +PGXPCulling = true +PGXPTextureCorrection = true +PGXPColorCorrection = false +PGXPVertexCache = false +PGXPCPU = false +PGXPPreserveProjFP = false +PGXPTolerance = -1 +PGXPDepthBuffer = false +PGXPDisableOn2DPolygons = false +PGXPDepthClearThreshold = 300 + + +[Display] +DeinterlacingMode = Adaptive +CropMode = Overscan +ActiveStartOffset = 0 +ActiveEndOffset = 0 +LineStartOffset = 0 +LineEndOffset = 0 +Force4_3For24Bit = false +AspectRatio = Auto (Game Native) +Alignment = Center +Rotation = Normal +Scaling = BilinearSmooth +OptimalFramePacing = false +PreFrameSleep = false +SkipPresentingDuplicateFrames = false +PreFrameSleepBuffer = 2 +VSync = true +DisableMailboxPresentation = true +ExclusiveFullscreenControl = Automatic +ScreenshotMode = InternalResolution +ScreenshotFormat = PNG +ScreenshotQuality = 85 +CustomAspectRatioNumerator = 0 +ShowOSDMessages = true +ShowFPS = false +ShowSpeed = false +ShowResolution = false +ShowLatencyStatistics = false +ShowGPUStatistics = false +ShowCPU = false +ShowGPU = false +ShowFrameTimes = false +ShowStatusIndicators = true +ShowInputs = false +ShowEnhancements = false +OSDScale = 100 +StretchVertically = false + + +[CDROM] +ReadaheadSectors = 8 +MechaconVersion = VC1A +RegionCheck = false +LoadImageToRAM = false +LoadImagePatches = false +MuteCDAudio = false +ReadSpeedup = 1 +SeekSpeedup = 1 + + +[Audio] +Backend = Cubeb +Driver = +OutputDevice = +StretchMode = TimeStretch +BufferMS = 50 +OutputLatencyMS = 20 +OutputLatencyMinimal = false +StretchSequenceLengthMS = 30 +StretchSeekWindowMS = 20 +StretchOverlapMS = 10 +StretchUseQuickSeek = false +StretchUseAAFilter = false +OutputVolume = 100 +FastForwardVolume = 100 +OutputMuted = false + + +[Hacks] +UseOldMDECRoutines = false +ExportSharedMemory = false +DMAMaxSliceTicks = 1000 +DMAHaltTicks = 100 +GPUFIFOSize = 16 +GPUMaxRunAhead = 128 + + +[PCDrv] +Enabled = false +EnableWrites = false +Root = + + +[BIOS] +TTYLogging = false +PatchFastBoot = false +SearchDirectory = ../../../.persist/manual/games/sony_ps2/bios + + +[MemoryCards] +Card1Type = PerGameTitle +Card2Type = None +UsePlaylistTitle = true +Directory = memcards + + +[ControllerPorts] +MultitapMode = Disabled +PointerXScale = 8 +PointerYScale = 8 +PointerXInvert = false +PointerYInvert = false + + +[Cheevos] +Enabled = false +ChallengeMode = false +Notifications = true +LeaderboardNotifications = true +SoundEffects = true +Overlays = true +EncoreMode = false +SpectatorMode = false +UnofficialTestMode = false +UseFirstDiscFromPlaylist = true +UseRAIntegration = false +NotificationsDuration = 5 +LeaderboardsDuration = 10 + + +[Logging] +LogLevel = Info +LogFilter = +LogTimestamps = true +LogToConsole = true +LogToDebug = false +LogToWindow = false +LogToFile = false + + +[Debug] +ShowVRAM = false +DumpCPUToVRAMCopies = false +DumpVRAMToCPUCopies = false +ShowGPUState = false +ShowCDROMState = false +ShowSPUState = false +ShowTimersState = false +ShowMDECState = false +ShowDMAState = false + + +[TextureReplacements] +EnableVRAMWriteReplacements = false +PreloadTextures = false +DumpVRAMWrites = false +DumpVRAMWriteForceAlphaChannel = true +DumpVRAMWriteWidthThreshold = 128 +DumpVRAMWriteHeightThreshold = 128 + + +[MediaCapture] +Backend = FFmpeg +Container = mp4 +VideoCapture = true +VideoWidth = 640 +VideoHeight = 480 +VideoAutoSize = false +VideoBitrate = 6000 +VideoCodec = +VideoCodecUseArgs = false +AudioCodecArgs = +AudioCapture = true +AudioBitrate = 128 +AudioCodec = +AudioCodecUseArgs = false + + +[Folders] +Cache = cache +Cheats = cheats +Covers = covers +Dumps = dump +GameIcons = gameicons +GameSettings = gamesettings +InputProfiles = inputprofiles +SaveStates = savestates +Screenshots = screenshots +Shaders = shaders +Textures = textures +UserResources = resources +Videos = videos + + +[InputSources] +SDL = true +SDLControllerEnhancedMode = false +SDLPS5PlayerLED = false +XInput = false +RawInput = false + + +[Pad1] +Type = AnalogController +Up = SDL-0/DPadUp +Right = SDL-0/DPadRight +Down = SDL-0/DPadDown +Left = SDL-0/DPadLeft +Triangle = SDL-0/Y +Circle = SDL-0/B +Cross = SDL-0/A +Square = SDL-0/X +Select = SDL-0/Back +Start = SDL-0/Start +L1 = SDL-0/LeftShoulder +R1 = SDL-0/RightShoulder +L2 = SDL-0/+LeftTrigger +R2 = SDL-0/+RightTrigger +L3 = SDL-0/LeftStick +R3 = SDL-0/RightStick +LLeft = SDL-0/-LeftX +LRight = SDL-0/+LeftX +LDown = SDL-0/+LeftY +LUp = SDL-0/-LeftY +RLeft = SDL-0/-RightX +RRight = SDL-0/+RightX +RDown = SDL-0/+RightY +RUp = SDL-0/-RightY +Analog = SDL-0/Guide +SmallMotor = SDL-0/SmallMotor +LargeMotor = SDL-0/LargeMotor + + +[Pad2] +Type = None + + +[Pad3] +Type = None + + +[Pad4] +Type = None + + +[Pad5] +Type = None + + +[Pad6] +Type = None + + +[Pad7] +Type = None + + +[Pad8] +Type = None + + +[Hotkeys] +FastForward = Keyboard/Tab +TogglePause = Keyboard/Space +Screenshot = Keyboard/F10 +ToggleFullscreen = Keyboard/F11 +OpenPauseMenu = Keyboard/Escape +LoadSelectedSaveState = Keyboard/F1 +SaveSelectedSaveState = Keyboard/F2 +SelectPreviousSaveStateSlot = Keyboard/F3 +SelectNextSaveStateSlot = Keyboard/F4 + + +[UI] +UnofficialBuildWarningConfirmed = true +MainWindowGeometry = AdnQywADAAAAAAAAAAAAAAAAAx8AAAKOAAAAAAAAAAAAAAMfAAACjgAAAAAAAAAABQAAAAAAAAAAAAAAAx8AAAKO +MainWindowState = AAAA/wAAAAD9AAAAAAAAAyAAAAJjAAAABAAAAAQAAAAIAAAACPwAAAABAAAAAgAAAAEAAAAOAHQAbwBvAGwAQgBhAHIAAAAAAP////8AAAAAAAAAAA== + + +[AutoUpdater] +CheckAtStartup = false + + +[GameList] +RecursivePaths = /home/deck/.persist/manual/games/sony_ps1/roms