Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrating Fex support #237

Open
rowanG077 opened this issue Oct 2, 2024 · 5 comments
Open

Integrating Fex support #237

rowanG077 opened this issue Oct 2, 2024 · 5 comments

Comments

@rowanG077
Copy link
Contributor

rowanG077 commented Oct 2, 2024

With fex + vulkan seeming to be pretty close on fedora asahi I think we should start thinking about how we can support fex on nixos. As far as I see it a few different things need to happen for that:

  • Have a working FEX build
  • Be able to run a 4k page microVM, probably using the same method as fedora does it.
  • Run the rootFS in the VM

I personally have little experience how rootfs + krun functions so this is more to get the discussion started. I'm willing to work on this so if anyone has any pointers to achieve this that would help as well.

@rowanG077
Copy link
Contributor Author

Pinging @RossComputerGuy as you have packaged krun aka muvm upstream. Currently it crashes for me but maybe that is known.

@RossComputerGuy
Copy link
Contributor

This is definitely a good idea and I can look into it when I have a moment. (I should rename krun to muvm in nixpkgs, didn't know about the rename until recently)

@rowanG077
Copy link
Contributor Author

This is a fex derivation, I can't test it because you need a 4K pagesize system to run it. For which we will need muvm. If you disable tests though it fully builds and you can at the very least run FEXConfig.

{ lib, stdenv, clangStdenv, fetchgit, cmake, clang, ninja, pkg-config, lld, llvm
, llvmPackages, openssl, glibc, autoPatchelfHook, nasm, qt5, python, setuptools
, libclang
}:

clangStdenv.mkDerivation rec {
  pname = "fex-emu";
  version = "2410";

  src = fetchgit {
    url = "https://github.com/FEX-Emu/FEX.git";
    rev = "FEX-${version}";
    sha256 = "sha256-btzb7OGa3M89wDn8AK/iocT3GLY1mB3cZ0iuWAyNIFc=";
    fetchSubmodules = true;
  };

  nativeBuildInputs = [
    cmake
    clang
    ninja
    pkg-config
    nasm
    qt5.wrapQtAppsHook
    # required with "-DUSE_LINKER=lld"
    # lld
    # autoPatchelfHook
  ];

  buildInputs = [
    llvm
    python
    setuptools
    libclang
    openssl.dev
    qt5.full
  ];

  cmakeFlags = [
    # upstream recommends this but binaries have linker issues
    # libstdc++.so.6: cannot open shared object file: No such file or directory
    # autoPatchelfHook fixes that for the output binaries but test are run
    # by cmake prior to that
    # "-DUSE_LINKER=lld"
    "-DENABLE_ASSERTIONS=FALSE"
    "-DBUILD_TESTS=FALSE"
    "-DOVERRIDE_VERSION=FEX-${version}"
  ];

  meta = with lib; {
    description = "FEX - Fast x86 emulation frontend";
    homepage = "https://github.com/FEX-Emu/FEX";
    license = licenses.mit;
    platforms = platforms.linux;
    maintainers = with maintainers; [ rowanG077 ];
  };
}

@Lemm1
Copy link

Lemm1 commented Oct 8, 2024

This is a fex derivation, I can't test it because you need a 4K pagesize system to run it. For which we will need muvm. If you disable tests though it fully builds and you can at the very least run FEXConfig.

The problem with FEX is to create RootFS, there are prebuilds for fedora, arch and ubuntu. So for nixos you will need to create your own. I've tried to do it few months ago, but it wasn't that easy as creating FEX package. Also in order to make something distributable it will require some nix wizard to somehow either automate RootFS creation on package build or to have prebuilt RootFS distributed like FEX do it for some distros. I personally gave up on that and started using distrobox for FEX

@rencire
Copy link

rencire commented Jan 8, 2025

I was doing some basic research and found this post that could be helpful for those who want to pursue this: https://old.reddit.com/r/AsahiLinux/comments/1hd6wkg/fexemu_on_asahi_debian/m1u7uxr/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants