NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.32k stars 14.29k forks source link

Package request: Fightcade #253698

Open blueOkiris opened 1 year ago

blueOkiris commented 1 year ago

Project description

From their website:

Play arcade games online.

THE BEST WAY TO PLAY RETRO GAMES ONLINE

Fightcade is a matchmaking platform for retro gaming, bundled with different emulators for seamless online play.

It's basically a way to play old fighting games like Street Fighter III: Third Strike with others online with rollback.

Metadata


It's already packaged as a flatpak, and I think the tar it gives you from their website is self-contained, so it shouldn't be that difficult to package (I just don't know how to do that yet)

blueOkiris commented 1 year ago

The package will also want to apply the auto-download patch that everyone uses, since it won't be able to manually installed otherwise I think:

https://fightcade.guide/

blueOkiris commented 1 year ago

I tried to hack together something to throw into my configuration.nix for now:

let
    fightcade = pkgs.stdenv.mkDerivation rec {
        name = "fightcade";
        src = builtins.fetchTarball {
            url = "https://web.fightcade.com/download/Fightcade-linux-latest.tar.gz";
            sha256 = "0680q7j6lk13cd7kf2by029lxvbxr7hzh8g44pnm23ywfrfgh4qs";
        };
        buildPhase = ''
            mkdir -p $out/bin
            cp -ra *.sh $out/bin
            cp -ra *.desktop $out/bin
            cp -ra emulator/ $out/bin
            cp -ra fc2-electron/ $out/bin
            cp -ra ROMs/ $out/bin
            cp -ra fcade-upd $out/bin
        '';
        installPhase = ''
        '';
    };

But when trying to run Fightcade2.sh, it tries to modify itself, which obv it can't from the store, so that may be an issue when trying to create the package.

If you look in the flatpak yaml:

# A lot of things need to be symlinked to writable files. Fightcade
# expects to be able to write to files in its subdirectories,
# /app/fightcade/Fightcade is r/o in Flatpak.

Idk how you'd go about making this where it can modify itself, but that's one challenge to packaging Fightcade

blueOkiris commented 1 year ago

Recommend just use flatpak for now

AeronSor commented 4 months ago

Also wondering how one would go about packaging Fightcade.

blueOkiris commented 4 months ago

You can run it from source with this shell.nix:

{ pkgs ? import <nixpkgs> { } }:

let
    buildLibs = with pkgs; (with xorg; [
        alsa-lib
        atk
        cairo
        cups
        dbus
        expat
        gdk-pixbuf
        glib
        gtk3
        libdrm
        libX11
        libxcb
        libXcomposite
        libXcursor
        libXdamage
        libXext
        libXfixes
        libXi
        libXrandr
        libXrender
        libXScrnSaver
        libXtst
        mesa
        nss
        nspr
        pango
    ]);
in with pkgs; with xorg; mkShell {
    buildInputs = [
    ]++ buildLibs;
    shellHook = ''
        export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${lib.makeLibraryPath buildLibs}"
    '';
}

Haven't gotten auto-rom-download to work yet, but it's a start

blueOkiris commented 4 months ago

I got it working manually. I had to launch nix-shell, put the auto-download jsons in emulator/, a la the guide, soft link wine: sudo ln -s /run/current-system/sw/bin/wine /usr/bin/wine, then run with custom wine prefix: WINEARCH=win64 WINEPREFIX=$(pwd)/.wine ./Fightcade2.sh

blueOkiris commented 4 months ago

Perhaps the roms folder and the wine prefix (i.e. the non-static things) for the install folder fightcade could point to ~/.fightcade/ROMs and ~/.fightcade/wine.

Then the package could download the .tar.xz, extract it, create a new .desktop, and download the json files into the emulator/ folder and that stuff can go in /nix/store. Don't know what to do about Fightcade requiring /usr/bin/wine to exist. Probably not best to have a soft link.

Idk really know how to make packages tho, but with what files go where and now the dependencies known, is it possible someone who knows what they're doing could write up a package expression?

Just happy I can play for now at least. Hopefully others who want to use Fightcade can get it working until I or someone else figures out the package.

dinhokusanagi commented 3 weeks ago

Nixos + hyprland, the fightcade flatpak doesn't work for me, I looked for a solution but didn't find it, having it natively should definitely work, unfortunately I don't have the knowledge to help with the project, I hope someone can help with it.

pluiedev commented 3 weeks ago

From my cursory overview, unfortunately I don't think packaging Fightcade is even technically feasible — the upstream tarball does not have a stable, versioned download link as https://web.fightcade.com/download/Fightcade-linux-latest.tar.gz always returns the latest version, and so the hash would mismatch every time upstream pushes an update. Using a pinned Flatpak version might work also but I don't think Nixpkgs currently has a mechanism for unpacking Flatpaks either...

blueOkiris commented 3 weeks ago

@pluiedev What of someone were to maintain a copy of the tarball?

Create an empty GitHub repo and post a copy of the latest Fightcade in Releases, so older versions could be referenced for hashing?

At one point I was maintaining a package manager for AppImages, and that's what I'd do for AppImages that were built continuously with CIs

keenanweaver commented 3 weeks ago

Regarding the JSONs, could those even be included with the package? It'd definitely be a killer feature since the user wouldn't need to manually get them. Just wondering about legal ramifications.

pluiedev commented 3 weeks ago

@pluiedev What of someone were to maintain a copy of the tarball?

Create an empty GitHub repo and post a copy of the latest Fightcade in Releases, so older versions could be referenced for hashing?

There's no evidence that Fightcade is unfree redistributable, so no. As far as I'm concerned, you're only supposed to download it from their official website (or from Flathub).

However, it seems that the actual emulators that they're using are open-source (I mean, they have to, as they are forks of FOSS software actually no, it's complicated); it might then be useful to package these emulators, then? There's no way that the frontend and the backend are ever going to be FOSS though.