From d0f23c0cb16790d6f08bd40ca02dde17f100ac1e Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Fri, 12 Sep 2025 21:01:45 -0400 Subject: [PATCH] Add Spaghetti Kart to the Steam Deck. --- nix/steam_deck/configuration/flake.lock | 42 ++++++--- nix/steam_deck/configuration/flake.nix | 9 +- nix/steam_deck/configuration/home.nix | 1 + .../configuration/hosts/deck/default.nix | 5 +- .../roles/spaghettikart/default.nix | 88 +++++++++++++++++++ .../spaghettikart/files/spaghettify.cfg.json | 14 +++ 6 files changed, 142 insertions(+), 17 deletions(-) create mode 100644 nix/steam_deck/configuration/roles/spaghettikart/default.nix create mode 100644 nix/steam_deck/configuration/roles/spaghettikart/files/spaghettify.cfg.json diff --git a/nix/steam_deck/configuration/flake.lock b/nix/steam_deck/configuration/flake.lock index 491c594..d2a6cf3 100644 --- a/nix/steam_deck/configuration/flake.lock +++ b/nix/steam_deck/configuration/flake.lock @@ -1,12 +1,15 @@ { "nodes": { "flake-utils": { + "inputs": { + "systems": "systems" + }, "locked": { - "lastModified": 1659877975, - "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", "owner": "numtide", "repo": "flake-utils", - "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", "type": "github" }, "original": { @@ -22,11 +25,11 @@ ] }, "locked": { - "lastModified": 1739314552, - "narHash": "sha256-ggVf2BclyIW3jexc/uvgsgJH4e2cuG6Nyg54NeXgbFI=", + "lastModified": 1757698511, + "narHash": "sha256-UqHHGydF/q3jfYXCpvYLA0TWtvByOp1NwOKCUjhYmPs=", "owner": "nix-community", "repo": "home-manager", - "rev": "83bd3a26ac0526ae04fa74df46738bb44b89dcdd", + "rev": "a3fcc92180c7462082cd849498369591dfb20855", "type": "github" }, "original": { @@ -58,11 +61,11 @@ ] }, "locked": { - "lastModified": 1713543440, - "narHash": "sha256-lnzZQYG0+EXl/6NkGpyIz+FEOc/DSEG57AP1VsdeNrM=", + "lastModified": 1752054764, + "narHash": "sha256-Ob/HuUhANoDs+nvYqyTKrkcPXf4ZgXoqMTQoCK0RFgQ=", "owner": "nix-community", "repo": "nixGL", - "rev": "310f8e49a149e4c9ea52f1adf70cdc768ec53f8a", + "rev": "a8e1ce7d49a149ed70df676785b07f63288f53c5", "type": "github" }, "original": { @@ -73,11 +76,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1739138025, - "narHash": "sha256-M4ilIfGxzbBZuURokv24aqJTbdjPA9K+DtKUzrJaES4=", + "lastModified": 1757746433, + "narHash": "sha256-fEvTiU4s9lWgW7mYEU/1QUPirgkn+odUBTaindgiziY=", "owner": "nixos", "repo": "nixpkgs", - "rev": "b2243f41e860ac85c0b446eadc6930359b294e79", + "rev": "6d7ec06d6868ac6d94c371458fc2391ded9ff13d", "type": "github" }, "original": { @@ -94,6 +97,21 @@ "nixgl": "nixgl", "nixpkgs": "nixpkgs" } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", diff --git a/nix/steam_deck/configuration/flake.nix b/nix/steam_deck/configuration/flake.nix index abe751a..8ef73ff 100644 --- a/nix/steam_deck/configuration/flake.nix +++ b/nix/steam_deck/configuration/flake.nix @@ -4,8 +4,10 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; - nixgl.url = "github:nix-community/nixGL"; - nixgl.inputs.nixpkgs.follows = "nixpkgs"; + nixgl = { + url = "github:nix-community/nixGL"; + inputs.nixpkgs.follows = "nixpkgs"; + }; home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; @@ -23,6 +25,7 @@ ... }: let + forAllSystems = nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed; system = "x86_64-linux"; pkgs = import nixpkgs { inherit system; @@ -31,7 +34,7 @@ in # pkgs = nixpkgs.legacyPackages.${system}; { - defaultPackage.${system} = home-manager.defaultPackage.${system}; + defaultPackage.${system} = home-manager.packages.${system}.default; homeConfigurations."deck" = home-manager.lib.homeManagerConfiguration { inherit pkgs; diff --git a/nix/steam_deck/configuration/home.nix b/nix/steam_deck/configuration/home.nix index db8b7d4..a1b64a0 100644 --- a/nix/steam_deck/configuration/home.nix +++ b/nix/steam_deck/configuration/home.nix @@ -18,6 +18,7 @@ ./roles/ryujinx ./roles/shipwright ./roles/sm64ex + ./roles/spaghettikart ./roles/steam_rom_manager ./roles/yuzu ./util/copy_files diff --git a/nix/steam_deck/configuration/hosts/deck/default.nix b/nix/steam_deck/configuration/hosts/deck/default.nix index 30944bd..38668ba 100644 --- a/nix/steam_deck/configuration/hosts/deck/default.nix +++ b/nix/steam_deck/configuration/hosts/deck/default.nix @@ -11,15 +11,16 @@ config = { me.ares.enable = true; me.dolphin.enable = true; - me.duckstation.enable = true; + me.duckstation.enable = false; me.graphical = true; me.optimizations.enable = true; me.pcsx2.enable = true; me.rpcs3.enable = true; me.ryujinx.enable = true; me.ship2harkinian.enable = true; - me.shipwright.enable = true; + me.shipwright.enable = false; me.sm64ex.enable = true; + me.spaghettikart.enable = false; me.steam_rom_manager.enable = true; # Steam rom manager UI does not render. I think it wants to be in an AppImage. me.yuzu.enable = true; }; diff --git a/nix/steam_deck/configuration/roles/spaghettikart/default.nix b/nix/steam_deck/configuration/roles/spaghettikart/default.nix new file mode 100644 index 0000000..15c9348 --- /dev/null +++ b/nix/steam_deck/configuration/roles/spaghettikart/default.nix @@ -0,0 +1,88 @@ +{ + config, + lib, + pkgs, + ... +}: + +let + steam_spaghettikart = pkgs.writeScriptBin "steam_Spaghettify" '' + export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${pkgs.libglvnd}/lib" + exec ${pkgs.spaghettikart}/bin/Spaghettify "''${@}" + ''; +in +{ + imports = [ ]; + + options.me = { + spaghettikart.enable = lib.mkOption { + type = lib.types.bool; + default = false; + example = true; + description = "Whether we want to install spaghettikart."; + }; + }; + + config = lib.mkIf config.me.spaghettikart.enable ( + lib.mkMerge [ + { + allowedUnfree = [ "spaghettikart" ]; + } + (lib.mkIf config.me.graphical { + home.packages = with pkgs; [ + spaghettikart + steam_spaghettikart + ]; + + home.file.".local/share/spaghettikart/spaghettify.cfg.json" = { + source = ./files/spaghettify.cfg.json; + }; + + home.persistence."/home/deck/.persist" = { + files = [ + ".local/share/spaghettikart/default.sav" + ".local/share/spaghettikart/mk64.o2r" + ]; + }; + + 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.spaghettikart [ + "-march=znver2" + "-mtune=znver2" + ]) + else + prev.spaghettikart; + in + { + spaghettikart = pkgs.buildEnv { + name = prev.spaghettikart.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/SpaghettiKart.desktop + ''; + }; + } + ) + ]; + }) + ] + ); +} diff --git a/nix/steam_deck/configuration/roles/spaghettikart/files/spaghettify.cfg.json b/nix/steam_deck/configuration/roles/spaghettikart/files/spaghettify.cfg.json new file mode 100644 index 0000000..04470d3 --- /dev/null +++ b/nix/steam_deck/configuration/roles/spaghettikart/files/spaghettify.cfg.json @@ -0,0 +1,14 @@ +{ + "CVars": { + "gDisableLod": 1, + "gMSAAValue": 2, + "gShowSpaghettiVersion": 0, + "gSkipIntro": 1, + "gVsyncEnabled": 1 + }, + "Window": { + "Fullscreen": { + "Enabled": true + } + } +}