djanatyn / ssbm-nix

Nix expressions for Super Smash Bros. Melee players.
34 stars 21 forks source link

Slippi Desktop #11

Open ursi opened 3 years ago

ursi commented 3 years ago

I have the following expression for the slippi dekstop app, but I can't get it to actually be able to play a replay. As far as I can tell, It needs to pass some flags to dolphin-emu in the directory you set. I symlinked slippi-playback do dolphin-emu in its own directory but no luck. Any ideas?

{ appimageTools, gsettings-desktop-schemas, gtk3 }:
  let version = "1.6.8"; in
  appimageTools.wrapType2
    { name = "slippi-desktop";

      src =
        builtins.fetchurl
          { url = "https://github.com/project-slippi/slippi-desktop-app/releases/download/v1.6.8/Slippi-Launcher-${version}-x86_64.AppImage";
            sha256 = "0phwiwhl0pzxw3hs4bmi1zfi8vq2agnaba9jfmznycvjvsh73wiy";
          };

      # magic I found at https://discourse.nixos.org/t/failure-appimage-run-with-gsetting/4403/2
      # to get the popups for selecting files to work
      profile =
        ''
        export LC_ALL=C.UTF-8
        export XDG_DATA_DIRS=${gsettings-desktop-schemas}/share/gsettings-schemas/${gsettings-desktop-schemas.name}:${gtk3}/share/gsettings-schemas/${gtk3.name}:$XDG_DATA_DIRS
        '';
    }
djanatyn commented 3 years ago

I'll take a look this afternoon - I haven't touched replays in a bit, but I bet we can get this working.

djanatyn commented 3 years ago

I have this code on a branch I'm testing, feature/ssbm-nix: https://github.com/djanatyn/ssbm-nix/commit/5e5bbeb2a8e0a64a7a343bb9b1c8c06e5b1fd5e5

It looks like it's loading my configuration from "/home/djanatyn/.config/Slippi Desktop App/Settings":

[pid  5904] openat(AT_FDCWD, "/home/djanatyn/.config/Slippi Desktop App/Settings", O_RDONLY|O_CLOEXEC) = 38

That's JSON:

❯ jq '.' <  "/home/djanatyn/.config/Slippi Desktop App/Settings"
{
  "previousVersion": "1.6.8",
  "isoPath": "/home/djanatyn/melee/game.iso",
  "playbackDolphinPath": "/home/djanatyn/repos/Slippi-FM-installer/Slippi-FM-r18/netplay/dolphin-emu",
  "settings": {
    "isoPath": "/home/djanatyn/melee/game.iso",
    "rootSlpPath": "/home/djanatyn/Slippi/2021-03",
    "playbackDolphinPath": "/nix/store/vdkbcdxykachhmvfnsn9kqvjqmzxkm49-slippi-ishiiruka-2.2.1-playback/"
  }
}

The path is set here. I tried launching a game initially: old

It didn't work because it was using my old path. I had a recent slippi-playback available:

❯ ls /nix/store/2mayzj8nsn1vx2y50d4xvzmq0d1gzfrb-slippi-ishiiruka-2.2.1-playback/
bin  dolphin-emu  portable.txt  Sys  traversal_server

I updated /home/djanatyn/.config/Slippi Desktop App/Settings to point there:

❯ jq '.settings.playbackDolphinPath' <  "/home/djanatyn/.config/Slippi Desktop App/Settings"
"/nix/store/2mayzj8nsn1vx2y50d4xvzmq0d1gzfrb-slippi-ishiiruka-2.2.1-playback/"

After that, Dolphin successfully launched when I tried to watch a replay! However, nothing played. I took a look at what dolphin process it was launching to see what arguments were passed:

❯ pgrep -laf dolphin-emu
22850 /nix/store/2mayzj8nsn1vx2y50d4xvzmq0d1gzfrb-slippi-ishiiruka-2.2.1-playback/dolphin-emu -i /tmp/slippi-comm-vod-87890b4cc762e7f9dd748628.txt -b -e /home/djanatyn/melee/game.iso

It's not loading any configuration directories. Just like with slippi-netplay, it'll attempt to persist configuration inside of that read-only /nix/store/.../ directory. We need to pass an argument like -u ~/slippi-playback-config somewhere:

# taken from my command line history
cd ~/repos/ssbm-nix && nix run .#slippi-playback -- -e ~/melee/netplay.iso -i /dev/stdin -u ~/slippi-playback-config -o turnip <<< '{"replay":"/home/djanatyn/good-slippis/simna-turnip.slp"}'

So from my end, this derivation looks fine, but we need to wrap our slippi-playback binary

I tried poking at this by writing a quick shell script named dolphin-emu:

❯ cat /var/tmp/slippi-desktop-test/dolphin-emu
#!/usr/bin/env bash
exec /nix/store/2mayzj8nsn1vx2y50d4xvzmq0d1gzfrb-slippi-ishiiruka-2.2.1-playback/dolphin-emu -u ~/slippi-playback-config "$@"

This didn't end up working with the Slippi Desktop app.

Maybe the next step could be trying writeScriptBin, something like this (a derivation I wrote for quickly launching Crystal Melee):

overlay = final: prev: {
    crystal-melee = final.writeScriptBin "crystal-melee" ''
    #!${final.stdenv.shell}

    exec ${final.slippi-netplay}/bin/slippi-netplay -e ~/melee/diet-melee/DietMeleeLinuxPatcher/CrystalMelee_v1.0.1.iso -u ~/slippi-config
    '';
};
djanatyn commented 3 years ago

I think there may be some more issues with slippi-playback, I opened a ticket upstream: https://github.com/project-slippi/Ishiiruka/issues/315

r-burns commented 1 year ago

I have slippi playback / replays working on my setup, the main issue I encountered was that the default appimage wrapper doesn't pass additional arguments, but slippi needs these to set up the playback emulator. I wrote a wrapper like this:

with import <nixpkgs> {}; 
let
  src = fetchzip {
    url = "https://github.com/project-slippi/Ishiiruka-Playback/releases/download/v2.5.2/playback-2.5.2-Linux.zip";
    sha256 = "sha256-f6frHM9SpTKv6TWn/kiW/Fs4zvUBUSCxp6WQIvyoOzI=";
    stripRoot = false;
  };  

  ldlibpath = lib.makeLibraryPath [
    gmp 
    vulkan-loader
    "/run/opengl-driver"
  ];  
in
  writeShellScript "Slippi_Playback-x86_64.AppImage" ''
    LD_LIBRARY_PATH=${ldlibpath} ${appimage-run}/bin/appimage-run ${src}/Slippi_Playback-x86_64.AppImage "$@"
  ''

After setting the playback executable location to the result of that expression in the launcher settings, I am able to view replays.