104 lines
2.9 KiB
Nix
Raw Normal View History

2025-03-30 15:57:01 -04:00
{
config,
lib,
pkgs,
...
}:
let
steam_dolphin = pkgs.writeScriptBin "steam_dolphin" ''
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${pkgs.libglvnd}/lib"
exec ${pkgs.dolphin-emu}/bin/dolphin-emu "''${@}"
'';
in
{
imports = [ ];
options.me = {
dolphin.enable = lib.mkOption {
type = lib.types.bool;
default = false;
example = true;
description = "Whether we want to install dolphin.";
};
};
config = lib.mkIf config.me.dolphin.enable (
lib.mkMerge [
(lib.mkIf config.me.graphical {
home.packages = with pkgs; [
dolphin-emu
steam_dolphin
];
home.file.".config/dolphin-emu/Dolphin.ini" = {
source = ./files/Dolphin.ini;
};
home.file.".config/dolphin-emu/GFX.ini" = {
source = ./files/GFX.ini;
};
home.file.".config/dolphin-emu/Profiles/GCPad/deck.ini" = {
source = ./files/deck.ini;
};
home.file.".config/dolphin-emu/GCPadNew.ini" = {
source = ./files/GCPadNew.ini;
};
2025-03-30 17:26:05 -04:00
me.persist.directories = [
".local/share/dolphin-emu/Wii" # The system memory
".local/share/dolphin-emu/Load" # Memory card(s)
".local/share/dolphin-emu/GC" # Gamecube
".local/share/dolphin-emu/ScreenShots" # Screenshots
".local/share/dolphin-emu/GBA/Saves" # GameBoy Advanced
];
me.state.directories = [
".cache/dolphin-emu"
".local/share/dolphin-emu/Shaders"
".local/share/dolphin-emu/StateSaves"
];
2025-03-30 15:57:01 -04:00
nixpkgs.overlays = [
(
final: prev:
let
optimizeWithFlags =
pkg: flags:
pkg.overrideAttrs (old: {
NIX_CFLAGS_COMPILE = [ (old.NIX_CFLAGS_COMPILE or "") ] ++ flags;
});
original_package =
if config.me.optimizations.enable then
(optimizeWithFlags prev.dolphin-emu [
"-march=znver2"
"-mtune=znver2"
])
else
prev.dolphin-emu;
in
{
dolphin-emu = pkgs.buildEnv {
name = prev.dolphin-emu.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/dolphin-emu.desktop
'';
};
}
)
];
})
]
);
}