2025-03-20 20:18:40 -04:00
{
config ,
lib ,
pkgs ,
. . .
} :
let
steam_pcsx2 = pkgs . writeScriptBin " s t e a m _ p c s x 2 " ''
export LD_LIBRARY_PATH = " $ L D _ L I B R A R Y _ P A T H : ${ pkgs . libglvnd } / l i b "
2025-03-29 16:46:52 -04:00
exec $ { pkgs . pcsx2 } /bin/pcsx2-qt " ' ' ${ @ } "
2025-03-20 20:18:40 -04:00
'' ;
in
{
imports = [ ] ;
options . me = {
pcsx2 . enable = lib . mkOption {
type = lib . types . bool ;
default = false ;
example = true ;
description = " W h e t h e r w e w a n t t o i n s t a l l p c s x 2 . " ;
} ;
} ;
config = lib . mkIf config . me . pcsx2 . enable (
lib . mkMerge [
( lib . mkIf config . me . graphical {
home . packages = with pkgs ; [
pcsx2
steam_pcsx2
] ;
home . file . " . c o n f i g / P C S X 2 / i n i s / P C S X 2 . i n i " = {
source = ./files/PCSX2.ini ;
} ;
2025-03-30 17:26:05 -04:00
me . persist . directories = [ " . c o n f i g / P C S X 2 / m e m c a r d s " ] ;
me . state . directories = [
" . c o n f i g / P C S X 2 / c a c h e "
" . c o n f i g / P C S X 2 / s s t a t e s "
" . c o n f i g / P C S X 2 / s n a p s "
" . c o n f i g / P C S X 2 / c o v e r s "
" . c o n f i g / P C S X 2 / v i d e o s "
] ;
2025-03-20 20:18:40 -04:00
nixpkgs . overlays = [
2025-03-24 19:54:09 -04:00
(
final : prev :
let
optimizeWithFlags =
pkg : flags :
pkg . overrideAttrs ( old : {
2025-03-30 18:49:47 -04:00
env . CXXFLAGS = ( old . env . CXXFLAGS or " " ) + ( lib . strings . concatStringsSep " " flags ) ;
2025-03-24 19:54:09 -04:00
} ) ;
original_package =
if config . me . optimizations . enable then
( optimizeWithFlags prev . pcsx2 [
" - m a r c h = z n v e r 2 "
" - m t u n e = z n v e r 2 "
] )
else
prev . pcsx2 ;
in
{
pcsx2 = pkgs . buildEnv {
name = prev . pcsx2 . name ;
paths = [
( config . lib . nixGL . wrap original_package )
] ;
extraOutputsToInstall = [
" m a n "
" d o c "
" i n f o "
] ;
# 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/PCSX2.desktop
'' ;
} ;
}
)
2025-03-20 20:18:40 -04:00
] ;
} )
]
) ;
}