Enable optimized builds for steam deck.

This commit is contained in:
Tom Alexander 2025-03-24 19:54:09 -04:00
parent 44a49d7ac7
commit 3ecb2fc790
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
8 changed files with 211 additions and 98 deletions

View File

@ -8,6 +8,7 @@
{ {
imports = [ imports = [
./roles/2ship2harkinian ./roles/2ship2harkinian
./roles/global_options
./roles/graphics ./roles/graphics
./roles/pcsx2 ./roles/pcsx2
./roles/rpcs3 ./roles/rpcs3

View File

@ -10,6 +10,7 @@
config = { config = {
me.graphical = true; me.graphical = true;
me.optimizations.enable = true;
me.pcsx2.enable = true; me.pcsx2.enable = true;
me.rpcs3.enable = true; me.rpcs3.enable = true;
me.ship2harkinian.enable = true; me.ship2harkinian.enable = true;

View File

@ -54,23 +54,41 @@ in
}; };
nixpkgs.overlays = [ nixpkgs.overlays = [
(final: prev: { (
_2ship2harkinian = pkgs.buildEnv { final: prev:
name = prev._2ship2harkinian.name; let
paths = [ optimizeWithFlags =
(config.lib.nixGL.wrap prev._2ship2harkinian) pkg: flags:
]; pkg.overrideAttrs (old: {
extraOutputsToInstall = [ NIX_CFLAGS_COMPILE = [ (old.NIX_CFLAGS_COMPILE or "") ] ++ flags;
"man" });
"doc" original_package =
"info" if config.me.optimizations.enable then
]; (optimizeWithFlags prev._2ship2harkinian [
# 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. "-march=znver2"
postBuild = '' "-mtune=znver2"
chmod 0555 $out/share/applications/2s2h.desktop ])
''; else
}; prev._2ship2harkinian;
}) in
{
_2ship2harkinian = pkgs.buildEnv {
name = prev._2ship2harkinian.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/2s2h.desktop
'';
};
}
)
]; ];
}) })
] ]

View File

@ -0,0 +1,19 @@
{
config,
lib,
pkgs,
...
}:
{
imports = [ ];
options.me = {
optimizations.enable = lib.mkOption {
type = lib.types.bool;
default = false;
example = true;
description = "Whether we want to enable CPU optimizations (will trigger a rebuild from source).";
};
};
}

View File

@ -70,23 +70,41 @@ in
}; };
nixpkgs.overlays = [ nixpkgs.overlays = [
(final: prev: { (
pcsx2 = pkgs.buildEnv { final: prev:
name = prev.pcsx2.name; let
paths = [ optimizeWithFlags =
(config.lib.nixGL.wrap prev.pcsx2) pkg: flags:
]; pkg.overrideAttrs (old: {
extraOutputsToInstall = [ NIX_CFLAGS_COMPILE = [ (old.NIX_CFLAGS_COMPILE or "") ] ++ flags;
"man" });
"doc" original_package =
"info" if config.me.optimizations.enable then
]; (optimizeWithFlags prev.pcsx2 [
# 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. "-march=znver2"
postBuild = '' "-mtune=znver2"
chmod 0555 $out/share/applications/PCSX2.desktop ])
''; else
}; prev.pcsx2;
}) in
{
pcsx2 = pkgs.buildEnv {
name = prev.pcsx2.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/PCSX2.desktop
'';
};
}
)
]; ];
}) })
] ]

View File

@ -70,23 +70,41 @@ in
}; };
nixpkgs.overlays = [ nixpkgs.overlays = [
(final: prev: { (
rpcs3 = pkgs.buildEnv { final: prev:
name = prev.rpcs3.name; let
paths = [ optimizeWithFlags =
(config.lib.nixGL.wrap prev.rpcs3) pkg: flags:
]; pkg.overrideAttrs (old: {
extraOutputsToInstall = [ NIX_CFLAGS_COMPILE = [ (old.NIX_CFLAGS_COMPILE or "") ] ++ flags;
"man" });
"doc" original_package =
"info" if config.me.optimizations.enable then
]; (optimizeWithFlags prev.rpcs3 [
# 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. "-march=znver2"
# postBuild = '' "-mtune=znver2"
# chmod 0555 $out/share/applications/PCSX2.desktop ])
# ''; else
}; prev.rpcs3;
}) in
{
rpcs3 = pkgs.buildEnv {
name = prev.rpcs3.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/rpcs3.desktop
'';
};
}
)
]; ];
}) })
] ]

View File

@ -54,23 +54,43 @@ in
}; };
nixpkgs.overlays = [ nixpkgs.overlays = [
(final: prev: { (
shipwright = pkgs.buildEnv { final: prev:
name = prev.shipwright.name; let
paths = [ optimizeWithFlags =
(config.lib.nixGL.wrap prev.shipwright) pkg: flags:
]; pkg.overrideAttrs (old: {
extraOutputsToInstall = [ NIX_CFLAGS_COMPILE = [ (old.NIX_CFLAGS_COMPILE or "") ] ++ flags;
"man" });
"doc" original_package = prev.shipwright;
"info" # Optimization is broken for shipwright, fails to build "The following attributes are overlapping"
]; # original_package =
# 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. # if !config.me.optimizations.enable then
postBuild = '' # (optimizeWithFlags prev.shipwright [
chmod 0555 $out/share/applications/soh.desktop # "-march=znver2"
''; # "-mtune=znver2"
}; # ])
}) # else
# prev.shipwright;
in
{
shipwright = pkgs.buildEnv {
name = prev.shipwright.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/soh.desktop
'';
};
}
)
]; ];
}) })
] ]

View File

@ -52,38 +52,56 @@ in
}; };
nixpkgs.overlays = [ nixpkgs.overlays = [
(final: prev: { (
sm64ex = final: prev:
let let
desktop_item = pkgs.makeDesktopItem { optimizeWithFlags =
name = "sm64ex"; pkg: flags:
desktopName = "Super Mario 64"; pkg.overrideAttrs (old: {
comment = "A PC Port of Super Mario 64."; NIX_CFLAGS_COMPILE = [ (old.NIX_CFLAGS_COMPILE or "") ] ++ flags;
categories = [ });
"Game" original_package =
if config.me.optimizations.enable then
(optimizeWithFlags prev.sm64ex [
"-march=znver2"
"-mtune=znver2"
])
else
prev.sm64ex;
in
{
sm64ex =
let
desktop_item = pkgs.makeDesktopItem {
name = "sm64ex";
desktopName = "Super Mario 64";
comment = "A PC Port of Super Mario 64.";
categories = [
"Game"
];
icon = "sm64ex";
type = "Application";
exec = "sm64ex";
};
in
pkgs.buildEnv {
name = prev.sm64ex.name;
paths = [
(config.lib.nixGL.wrap original_package)
]; ];
icon = "sm64ex"; extraOutputsToInstall = [
type = "Application"; "man"
exec = "sm64ex"; "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 = ''
install -m 555 -D "${desktop_item}/share/applications/"* -t $out/share/applications/
install -m 444 -D "${./files/icon.png}" $out/share/pixmaps/sm64ex.png
'';
}; };
in }
pkgs.buildEnv { )
name = prev.sm64ex.name;
paths = [
(config.lib.nixGL.wrap prev.sm64ex)
];
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 = ''
install -m 555 -D "${desktop_item}/share/applications/"* -t $out/share/applications/
install -m 444 -D "${./files/icon.png}" $out/share/pixmaps/sm64ex.png
'';
};
})
]; ];
}) })
] ]