NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.04k stars 13.38k forks source link

Xenia(Xbox 360 emulator) #108212

Open schvabodka-man opened 3 years ago

schvabodka-man commented 3 years ago

Project description Xbox 360 emulator. Already working and can run tons of games. There is already an rpcs3 in repos(PS3 emu) so it would be kinda nice pair :)

Metadata

samuelgrf commented 3 years ago

Here's my current progress, building fails with error: implicit instantiation of undefined template 'std::__1::ctype<char16_t>' unfortunately (full log).

{ fetchFromGitHub
, gtk3
, llvmPackages_9
, lz4
, pkg-config
, python3
, SDL2
, vulkan-headers
, vulkan-loader
}:

let
  stdenv = llvmPackages_9.libcxxStdenv;
in

stdenv.mkDerivation {
  pname = "xenia";
  version = "unstable-2021-01-04";

  src = fetchFromGitHub {
    owner = "xenia-project";
    repo = "xenia";
    rev = "9a74df491ffd0189ddd26bc2030e0eae6a775f4e";
    sha256 = "106dkcnsc7ibx0c8fa8csp49dz59s9d4k6hxm4lybf3lybq0l491";
    fetchSubmodules = true;
  };

  nativeBuildInputs = [
    llvmPackages_9.bintools
    pkg-config
    python3
  ];

  buildInputs = [
    gtk3
    lz4
    SDL2
    vulkan-headers
    vulkan-loader
  ];

  patchPhase = ''
    runHook prePatch

    # Fixes "fatal error: 'sys/sysctl.h' file not found"
    substituteInPlace third_party/libav/config_lin.h \
      --replace "#define HAVE_SYSCTL 1" "#define HAVE_SYSCTL 0"

    runHook postPatch
  '';

  dontConfigure = true;

  buildPhase = ''
    runHook preBuild

    # TODO Look into using 'setup' argument
    python3 xenia-build build --config release -j $NIX_BUILD_CORES

    runHook postBuild
  '';

  NIX_CFLAGS_COMPILE = "-Wno-error-unused-result";

  enableParallelBuilding = true;
}
AndersonTorres commented 3 years ago

There is another distro running Xenia?

schvabodka-man commented 3 years ago

Hello @AndersonTorres @samuelgrf . Xenia is actually packages in arch AUR (which is also built from source) as latest git version. There are 2 versions of that package in repos: The "regular one" - https://aur.archlinux.org/packages/xenia-git/ And the one with some patches - https://aur.archlinux.org/packages/xenia-linux-fixes-git/ You can see a build script of them by clicking "View PKGBUILD" button

AndersonTorres commented 3 years ago

Fun to know. Can it be built and run on an AMD Ryzen 5?

schvabodka-man commented 3 years ago

@AndersonTorres on windows - definitely. On Linux - probably yes(why not?)

stale[bot] commented 3 years ago

I marked this as stale due to inactivity. → More info

adisbladis commented 2 years ago

This expression builds Xenia from master, but the canary build still fails:

{ clangStdenv
, fetchFromGitHub
, lib
, python3
, pkg-config
, gtk3
, SDL2
, lz4
, libunwind
, libiberty
, xorg
, vulkan-loader
}:

let
  mkXenia =
    { src
    , version
    , suffix ? ""
    }:

    clangStdenv.mkDerivation {
      pname = "xenia${suffix}";
      inherit src version;

      nativeBuildInputs = [
        python3
        pkg-config
      ];

      buildInputs = [
        gtk3
        SDL2
        lz4
        libunwind
        libiberty
        xorg.libX11
        xorg.libxcb
      ];

      dontConfigure = true;

      NIX_CFLAGS_COMPILE = [
        "-Wno-error=unused-result"
        "-fno-lto"
      ];

      buildPhase = ''
        runHook preBuild
        python3 ./xb build --config release -j $NIX_BUILD_CORES
        runHook postBuild
      '';

      installPhase = ''
        runHook preInstall
        mkdir -p $out/bin
        cp -a ./build/bin/*/*/xenia $out/bin/
        runHook postInstall
      '';

      postFixup = ''
        patchelf --add-rpath ${vulkan-loader}/lib $out/bin/xenia
      '';

      meta =
        let
          inherit (lib) licenses platforms;
        in
        {
          description = "Xenia is an experimental emulator for the Xbox 360";
          homepage = "https://xenia.jp";
          license = licenses.bsd3;
          maintainers = [ ];
          platforms = platforms.linux;
        };

    };

in
{

  xenia = mkXenia {
    version = "unstable-2022-07-27";
    src = fetchFromGitHub {
      owner = "xenia-project";
      repo = "xenia";
      fetchSubmodules = true;
      rev = "7595cdb52bd12d448aeabe4908862f59d283ce9d";
      hash = "sha256-W6lOZxMwNTxSPIcu2f2hrq8bxT/aqxdLTSLV9D1KY0U=";
    };
  };

  xenia-canary = mkXenia {
    version = "unstable-2022-08-20";
    src = fetchFromGitHub {
      owner = "xenia-canary";
      repo = "xenia-canary";
      fetchSubmodules = true;
      rev = "010b59e81cee3459dc03ed40f814537c2f682b6c";
      hash = "sha256-Njbp9wiyinRnC+Qw1tIEWU4UtQXmEHjAR5I+0Q2z8m8=";
    };
  };

}

I'm having some issues getting anything to actually run though. Hopefully this is enough for someone sufficiently motivated to take over the effort.