91 lines
2.6 KiB
Nix
Raw Normal View History

2025-04-15 20:01:00 -04:00
{
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
'';
};
}
)
];
})
]
);
}