nix-stuff/roles/gaming/programs/pcsx2.nix

162 lines
5.2 KiB
Nix

{
pkgs,
lib,
...
}: let
ps2-isos = pkgs.symlinkJoin {
name = "ps2-isos";
paths =
lib.lists.forEach [
(pkgs.fetchzip {
url = "https://myrient.erista.me/files/Redump/Sony%20-%20PlayStation%202/007%20-%20Nightfire%20%28USA%29.zip";
hash = "sha256-66Ey0SqC3Tk02Af+xR6rpxYSkO0n83NWYPCt4M3CUWo=";
})
(pkgs.fetchzip {
url = "https://myrient.erista.me/files/Redump/Sony%20-%20PlayStation%202/TimeSplitters%202%20%28USA%29.zip";
hash = "sha256-UPED4/MF9fjTOgiIJy+CSbuO9cJr3CsR/gEquY6GfsU=";
})
]
compress;
};
compress = iso:
pkgs.runCommand "compressed-ps2-isos" {} ''
mkdir $out
cd ${iso}
for file in ./*
do
${pkgs.mame-tools}/bin/chdman createdvd -i "$file" -o "$out/''${file%.iso}.chd"
done
'';
pcsx2-bios = pkgs.fetchzip {
url = "https://myrient.erista.me/files/Redump/Sony%20-%20PlayStation%202%20-%20BIOS%20Images/ps2-0200a-20040614.zip";
hash = "sha256-wMvswgmsKl+cJl49VlVW84tvU5Jzd+2dl07SOiUDtwA=";
};
in {
home-manager.users.toast = {
home = {
packages = with pkgs; [
pcsx2
];
file."Games/Isos/PS2".source = ps2-isos;
};
xdg.configFile = {
#PCSX2 silently overwrites the symlink so I need to force it's creation
"PCSX2/inis/PCSX2.ini".force = true;
"PCSX2/inis/PCSX2.ini".text =
lib.generators.toINI {
listsAsDuplicateKeys = true;
} {
UI = {
SettingsVersion = 1;
# Use the system theme
Theme = "";
HideMouseCursor = true;
};
Folders = {
Bios = "/home/toast/.local/share/PCSX2/bios";
};
GameList.RecursivePaths = [
"/home/toast/Games/Isos/PS2/"
];
"EmuCore/GS" = {
dithering_ps2 = 1;
upscale_multiplier = 2;
};
EmuCore = {
EnableDiscordPresence = true;
EnableFastBoot = true;
McdFolderAutoManage = false;
};
MemoryCards.Slot1_Filename = "MemoryCard1.ps2";
# Controller settings
Pad1 = {
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";
L2 = "SDL-0/+LeftTrigger";
R1 = "SDL-0/RightShoulder";
R2 = "SDL-0/+RightTrigger";
L3 = "SDL-0/LeftStick";
R3 = "SDL-0/RightStick";
Analog = "SDL-0/Guide";
LUp = "SDL-0/-LeftY";
LRight = "SDL-0/+LeftX";
LDown = "SDL-0/+LeftY";
LLeft = "SDL-0/-LeftX";
RUp = "SDL-0/-RightY";
RRight = "SDL-0/+RightX";
RDown = "SDL-0/+RightY";
RLeft = "SDL-0/-RightX";
LargeMotor = "SDL-0/LargeMotor";
SmallMotor = "SDL-0/SmallMotor";
};
# Default hotkeys
Hotkeys = {
ToggleFullscreen = "Keyboard/Alt & Keyboard/Return";
CycleAspectRatio = "Keyboard/F6";
CycleInterlaceMode = "Keyboard/F5";
CycleMipmapMode = "Keyboard/Insert";
GSDumpMultiFrame = "Keyboard/Control & Keyboard/Shift & Keyboard/F8";
Screenshot = "Keyboard/F8";
GSDumpSingleFrame = "Keyboard/Shift & Keyboard/F8";
ToggleSoftwareRendering = "Keyboard/F9";
ZoomIn = "Keyboard/Control & Keyboard/Plus";
ZoomOut = "Keyboard/Control & Keyboard/Minus";
InputRecToggleMode = "Keyboard/Shift & Keyboard/R";
LoadStateFromSlot = "Keyboard/F3";
SaveStateToSlot = "Keyboard/F1";
NextSaveStateSlot = "Keyboard/F2";
PreviousSaveStateSlot = "Keyboard/Shift & Keyboard/F2";
OpenPauseMenu = "Keyboard/Escape";
ToggleFrameLimit = "Keyboard/F4";
TogglePause = "Keyboard/Space";
ToggleSlowMotion = "Keyboard/Shift & Keyboard/Backtab";
ToggleTurbo = "Keyboard/Tab";
HoldTurbo = "Keyboard/Period";
};
};
# 007 nightfire
"PCSX2/gamesettings/SLUS-20579_5B86BB62.ini".text = lib.generators.toINI {} {
"EmuCore/GS".AspectRatio = "16:9";
};
};
xdg.dataFile = {
# I would prefer to use symlinkJoin like I do for the ISOs, but
# the bios folder needs to be writable to store the bios settings
"PCSX2/bios/ntsc.bin".source = pkgs.runCommandLocal "pcsx2-bios" {} ''
cp -v ${pcsx2-bios}/*.bin $out
'';
};
};
# Syncthing
services.syncthing.settings.folders."pcsx2" = {
label = "PCSX2";
id = "qcdsp-qaaej";
devices = ["steamdeck" "server" "pc" "winmax2"];
path = "~/.config/PCSX2";
};
home-manager.users.toast.xdg.configFile = {
"PCSX2/.stignore".text = ''
cahe
bios
gamesettings
inis/PCSX2.int*
inis/debuggersettings
inputprofiles
logs
'';
};
}