diff --git a/nix/steam_deck/configuration/flake.nix b/nix/steam_deck/configuration/flake.nix index 10bf39e..abe751a 100644 --- a/nix/steam_deck/configuration/flake.nix +++ b/nix/steam_deck/configuration/flake.nix @@ -35,7 +35,10 @@ homeConfigurations."deck" = home-manager.lib.homeManagerConfiguration { inherit pkgs; - extraSpecialArgs = { inherit nixgl; }; + extraSpecialArgs = { + inherit nixgl; + inherit home-manager; + }; modules = [ { nixpkgs.overlays = [ nixgl.overlay ]; } diff --git a/nix/steam_deck/configuration/home.nix b/nix/steam_deck/configuration/home.nix index 6ca17df..1800c16 100644 --- a/nix/steam_deck/configuration/home.nix +++ b/nix/steam_deck/configuration/home.nix @@ -9,6 +9,7 @@ imports = [ ./roles/2ship2harkinian ./roles/ares + ./roles/dolphin ./roles/global_options ./roles/graphics ./roles/pcsx2 diff --git a/nix/steam_deck/configuration/hosts/deck/default.nix b/nix/steam_deck/configuration/hosts/deck/default.nix index b6dd04c..05b3a52 100644 --- a/nix/steam_deck/configuration/hosts/deck/default.nix +++ b/nix/steam_deck/configuration/hosts/deck/default.nix @@ -10,6 +10,7 @@ config = { me.ares.enable = true; + me.dolphin.enable = true; me.graphical = true; me.optimizations.enable = true; me.pcsx2.enable = true; diff --git a/nix/steam_deck/configuration/roles/ares/default.nix b/nix/steam_deck/configuration/roles/ares/default.nix index 0225687..1a45aa8 100644 --- a/nix/steam_deck/configuration/roles/ares/default.nix +++ b/nix/steam_deck/configuration/roles/ares/default.nix @@ -64,6 +64,7 @@ in original_package = if config.me.optimizations.enable then (optimizeWithFlags prev.ares [ + # Verified working with ps "-march=znver2" "-mtune=znver2" ]) diff --git a/nix/steam_deck/configuration/roles/dolphin/default.nix b/nix/steam_deck/configuration/roles/dolphin/default.nix new file mode 100644 index 0000000..7b9fc20 --- /dev/null +++ b/nix/steam_deck/configuration/roles/dolphin/default.nix @@ -0,0 +1,150 @@ +{ + config, + lib, + pkgs, + home-manager, + ... +}: + +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; + }; + + home.persistence."/home/deck/.persist" = { + directories = [ + { + # The system memory + directory = ".local/share/dolphin-emu/Wii"; + method = "symlink"; + } + { + # Memory card(s) + directory = ".local/share/dolphin-emu/Load"; + method = "symlink"; + } + { + # Gamecube + directory = ".local/share/dolphin-emu/GC"; + method = "symlink"; + } + { + # Screenshots + directory = ".local/share/dolphin-emu/ScreenShots"; + method = "symlink"; + } + { + # GameBoy Advanced + directory = ".local/share/dolphin-emu/GBA/Saves"; + method = "symlink"; + } + ]; + }; + + home.persistence."/home/deck/.state" = { + directories = [ + { + directory = ".cache/dolphin-emu"; + method = "symlink"; + } + { + directory = ".local/share/dolphin-emu/Shaders"; + method = "symlink"; + } + { + directory = ".local/share/dolphin-emu/StateSaves"; + method = "symlink"; + } + ]; + }; + + home.activation = { + createDolphinDirectories = home-manager.lib.hm.dag.entryAfter [ "writeBoundary" ] '' + for dir in '.local/share/dolphin-emu/Wii' '.cache/dolphin-emu' '.local/share/dolphin-emu/Load' '.local/share/dolphin-emu/GC' '.local/share/dolphin-emu/ScreenShots' '.local/share/dolphin-emu/GBA/Saves' '.local/share/dolphin-emu/Shaders' '.local/share/dolphin-emu/StateSaves' ; do + echo "checking $dir" + if [[ ! -d "$HOME/.persist/$dir" ]]; then + $DRY_RUN_CMD mkdir $VERBOSE_ARG -p "$HOME/.persist/$dir" + fi + done + ''; + }; + + 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 [ + # Verified working with ps + "-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 + ''; + }; + } + ) + ]; + }) + ] + ); +} diff --git a/nix/steam_deck/configuration/roles/dolphin/files/Dolphin.ini b/nix/steam_deck/configuration/roles/dolphin/files/Dolphin.ini new file mode 100644 index 0000000..7184701 --- /dev/null +++ b/nix/steam_deck/configuration/roles/dolphin/files/Dolphin.ini @@ -0,0 +1,25 @@ +[Analytics] +Enabled = False +PermissionAsked = True +[Core] +GFXBackend = Vulkan +# GFXBackend = OGL +SlotA = 8 # GCI Folder (each game gets its own file) +SlotB = 255 # None +WiiSDCard = False +[Display] +RenderToMain = True +[General] +ISOPath0 = /home/deck/.persist/manual/games/nintendo_gamecube/roms +ISOPath1 = /home/deck/.persist/manual/games/nintendo_wii/roms +ISOPaths = 2 +RecursiveISOPaths = True +[DSP] +Backend = Cubeb +# Backend = Pulse +# Backend = ALSA +[USBPassthrough] +Devices = 057e:0305 +# BluetoothPassthrough must be at the end for the pairings to save properly +[BluetoothPassthrough] +Enabled = True diff --git a/nix/steam_deck/configuration/roles/dolphin/files/GCPadNew.ini b/nix/steam_deck/configuration/roles/dolphin/files/GCPadNew.ini new file mode 100644 index 0000000..2e15e1c --- /dev/null +++ b/nix/steam_deck/configuration/roles/dolphin/files/GCPadNew.ini @@ -0,0 +1,32 @@ +[GCPad1] +Device = SDL/0/Steam Deck Controller +Buttons/A = `Button S` +Buttons/B = `Button E` +Buttons/X = `Button W` +Buttons/Y = `Button N` +Buttons/Z = `Shoulder R` +Buttons/Start = Start +Main Stick/Up = `Left Y+` +Main Stick/Down = `Left Y-` +Main Stick/Left = `Left X-` +Main Stick/Right = `Left X+` +Main Stick/Modifier = `Thumb L` +Main Stick/Calibration = 100.00 101.96 108.24 120.27 137.87 120.27 108.24 101.96 100.00 101.96 108.24 120.27 141.42 120.27 108.24 101.96 100.00 101.96 108.24 120.27 141.42 120.27 108.24 101.96 100.00 101.96 108.24 120.27 136.32 120.27 108.24 101.96 +C-Stick/Up = `Right Y+` +C-Stick/Down = `Right Y-` +C-Stick/Left = `Right X-` +C-Stick/Right = `Right X+` +C-Stick/Modifier = `Thumb R` +C-Stick/Calibration = 100.00 101.96 108.24 120.27 141.42 120.27 108.24 101.96 100.00 101.96 108.24 120.27 136.25 120.27 108.24 101.96 100.00 101.96 108.24 120.27 134.42 120.27 108.24 101.96 100.00 101.96 108.24 120.27 141.42 120.27 108.24 101.96 +D-Pad/Up = `Pad N` +D-Pad/Down = `Pad S` +D-Pad/Left = `Pad W` +D-Pad/Right = `Pad E` +Triggers/L-Analog = `Trigger L` +Triggers/R-Analog = `Trigger R` +[GCPad2] +Device = XInput2/0/Virtual core pointer +[GCPad3] +Device = XInput2/0/Virtual core pointer +[GCPad4] +Device = XInput2/0/Virtual core pointer diff --git a/nix/steam_deck/configuration/roles/dolphin/files/GFX.ini b/nix/steam_deck/configuration/roles/dolphin/files/GFX.ini new file mode 100644 index 0000000..c53e8a4 --- /dev/null +++ b/nix/steam_deck/configuration/roles/dolphin/files/GFX.ini @@ -0,0 +1,16 @@ +# [Enhancements] +#MaxAnisotropy = 4 # 16x Anisotropic texture filtering +# MaxAnisotropy = 2 # 4x Anisotropic texture filtering +#MaxAnisotropy = 1 # 2x Anisotropic texture filtering +#MaxAnisotropy = 0 # default +[Settings] +WaitForShadersBeforeStarting = True +# WaitForShadersBeforeStarting = False +# MSAA = 0x00000004 # 4x MSAA +#MSAA = 0x00000002 # 2x MSAA +#MSAA = 0x00000001 # none +SSAA = False +# InternalResolution = 1 # 2x native +#ShaderCompilationMode = 2 # Hybrid ubershaders +ShaderCompilationMode = 3 # Skip +# ShowGraphs = True diff --git a/nix/steam_deck/configuration/roles/dolphin/files/deck.ini b/nix/steam_deck/configuration/roles/dolphin/files/deck.ini new file mode 100644 index 0000000..8a113e1 --- /dev/null +++ b/nix/steam_deck/configuration/roles/dolphin/files/deck.ini @@ -0,0 +1,26 @@ +[Profile] +Device = SDL/0/Steam Deck Controller +Buttons/A = `Button S` +Buttons/B = `Button E` +Buttons/X = `Button W` +Buttons/Y = `Button N` +Buttons/Z = `Shoulder R` +Buttons/Start = Start +Main Stick/Up = `Left Y+` +Main Stick/Down = `Left Y-` +Main Stick/Left = `Left X-` +Main Stick/Right = `Left X+` +Main Stick/Modifier = `Thumb L` +Main Stick/Calibration = 100.00 101.96 108.24 120.27 137.87 120.27 108.24 101.96 100.00 101.96 108.24 120.27 141.42 120.27 108.24 101.96 100.00 101.96 108.24 120.27 141.42 120.27 108.24 101.96 100.00 101.96 108.24 120.27 136.32 120.27 108.24 101.96 +C-Stick/Up = `Right Y+` +C-Stick/Down = `Right Y-` +C-Stick/Left = `Right X-` +C-Stick/Right = `Right X+` +C-Stick/Modifier = `Thumb R` +C-Stick/Calibration = 100.00 101.96 108.24 120.27 141.42 120.27 108.24 101.96 100.00 101.96 108.24 120.27 136.25 120.27 108.24 101.96 100.00 101.96 108.24 120.27 134.42 120.27 108.24 101.96 100.00 101.96 108.24 120.27 141.42 120.27 108.24 101.96 +Triggers/L-Analog = `Trigger L` +Triggers/R-Analog = `Trigger R` +D-Pad/Up = `Pad N` +D-Pad/Down = `Pad S` +D-Pad/Left = `Pad W` +D-Pad/Right = `Pad E`