Adamcake / Bolt

An alternative launcher for your favourite MMO
GNU Affero General Public License v3.0
156 stars 22 forks source link

Trying to package for NixOS: Zygote error #66

Open nezia1 opened 2 weeks ago

nezia1 commented 2 weeks ago

Hello, I'm trying to package your application for NixOS, but running into a Zygote issue and wondering if it's because I'm not using your CEF version. This is the error I'm getting:

[0100/000000.861912:ERROR:zygote_linux.cc(623)] Zygote could not fork: process_type gpu-process numfds 3 child_pid -1
[0100/000000.862026:ERROR:zygote_linux.cc(655)] write: Broken pipe (32)
fish: Job 1, './opt/bolt-launcher/bolt' terminated by signal SIGTRAP (Trace or breakpoint trap)

I was wondering if you applied specific patches to your cef version, that might have been important in able to run the application, or if I forgot any flags. Here's my full nix file:

{
lib
, stdenv
, fetchFromGitHub
, cmake
, ninja
, xorg
, libarchive
, luajit_2_1
, libcef
, zlib
}:

stdenv.mkDerivation rec {
  pname = "bolt-launcher";
  version = "0.9.0";

  src = fetchFromGitHub {
    owner = "AdamCake";
    repo = "bolt";
    rev = "${version}";
    fetchSubmodules = true;
    hash = "sha256-LIlRDcUWbQwIhFjtqYF+oVpTOPZ7IT0vMgysEVyJ1k8=";
  };

  nativeBuildInputs = [
    cmake
    ninja
  ];

  buildInputs = [
    xorg.libX11.dev
    xorg.libxcb.dev
    libarchive.dev
    luajit_2_1
    libcef
    zlib
  ];

  cmakeFlags = [ "-D CMAKE_BUILD_TYPE=Release" ];
  preConfigure = ''
    mkdir -p cef/dist
    mkdir -p cef/dist/Release
    mkdir -p cef/dist/Resources

    ln -s ${libcef}/cmake cef/dist/cmake
    ln -s ${libcef}/lib/* cef/dist/Release
    ln -s ${libcef}/share/cef/* cef/dist/Resources
    ln -s ${libcef}/libcef_dll cef/dist/libcef_dll
    ln -s ${libcef}/include cef/dist/include
    ls -al cef/dist/**
    '';

  enableParallelBuilding = false;

  meta = with lib; {
    homepage = "https://github.com/Adamcake/Bolt";
    description = "An alternative launcher for your favourite MMO";
    license = licenses.gpl2Plus;
    maintainers = with maintainers; [ nezia ];
    platforms = platforms.unix;
    mainProgram = "bolt-launcher";
  };
}

EDIT: I saw that you added two patches to your AUR package: https://aur.archlinux.org/cgit/aur.git/tree/fmt.patch?h=bolt-launcher&id=55a7ee5368e80689837beb6a94ad7d46a7d85327 https://aur.archlinux.org/cgit/aur.git/tree/cef-no-fortify.patch?h=bolt-launcher&id=55a7ee5368e80689837beb6a94ad7d46a7d85327

Would forgetting to apply any of those result in that Zygote error?

Adamcake commented 2 weeks ago

As far as I know, it should work with the generic CEF builds. The patches in AUR are to fix a compiler error caused by makepkg, and to make fmt a system dependency instead of statically compiled. Neither of them would be useful to you.

Your error message suggests that the fork() syscall failed, but it doesn't say what the error was. Something like strace might tell you.

Adamcake commented 2 weeks ago

By the way, Bolt's licence is agpl3+, not gpl2+.

nezia1 commented 2 weeks ago

Hey, thanks for the quick reply. I just updated the license.

It seems to be related to a sandboxing issue? I disabled zygote and CEF's sandboxing and it seemed to work. I'm still having issues with libGL however:

[0830/193918.584748:ERROR:gl_display.cc(520)] EGL Driver message (Critical) eglInitialize: Could not dlopen libGL.so.1: libGL.so.1: cannot open shared object file: No such file or directory
[0830/193918.584757:ERROR:gl_display.cc(791)] eglInitialize OpenGL failed with error EGL_NOT_INITIALIZED, trying next display type
[0830/193918.584795:ERROR:angle_platform_impl.cc(44)] Display.cpp:1052 (initialize): ANGLE Display::initialize error 12289: Could not dlopen libGL.so.1: libGL.so.1: cannot open shared object file: No such file or directory
ERR: Display.cpp:1052 (initialize): ANGLE Display::initialize error 12289: Could not dlopen libGL.so.1: libGL.so.1: cannot open shared object file: No such file or directory
[0830/193918.584812:ERROR:gl_display.cc(520)] EGL Driver message (Critical) eglInitialize: Could not dlopen libGL.so.1: libGL.so.1: cannot open shared object file: No such file or directory
[0830/193918.584823:ERROR:gl_display.cc(791)] eglInitialize OpenGLES failed with error EGL_NOT_INITIALIZED
[0830/193918.584834:ERROR:gl_display.cc(825)] Initialization of all EGL display types failed.
[0830/193918.584845:ERROR:gl_ozone_egl.cc(26)] GLDisplayEGL::Initialize failed.
fish: Job 1, './result/opt/bolt-launcher/bolt…' terminated by signal SIGTRAP (Trace or breakpoint trap)

Does that mean I incorrectly linked libGL?

EDIT: I managed to successfully link libGL, which fixed my zygote issues. However, I'm getting a new error:

[0830/195537.520272:ERROR:icu_util.cc(240)] Invalid file descriptor to ICU data received.
fish: Job 1, './result/opt/bolt-launcher/bolt' terminated by signal SIGTRAP (Trace or breakpoint trap)

Any clue what that might be about?

Adamcake commented 2 weeks ago

Yes. My understanding of Nix is that there's no standard location like /usr/lib where you'd find libraries like libGL, and instead the convention is to build executables and specify absolute paths to the libraries they import, such as by changing the executable's RPATH.

nezia1 commented 2 weeks ago

Yes. My understanding of Nix is that there's no standard location like /usr/lib where you'd find libraries like libGL, and instead the convention is to build executables and specify absolute paths to the libraries they import, such as by changing the executable's RPATH.

I managed to make it work :) However, I'm still getting an error that it cannot find icudtl.dat. Is that supposed to be available at runtime, or is it a build-time thing where it's bundled with the application?

openat(AT_FDCWD, "/nix/store/qavag7d0q4bslf85q61ika50h2prvk0y-cef-binary-121.3.13/lib/icudtl.dat", O_RDONLY) = -1 ENOENT (No such file

Adamcake commented 2 weeks ago

icudtl.dat should be in your CEF package, in the Resources directory, and it should be installed in the same directory as bolt at install-time. At runtime, CEF looks for it in the current working directory. So when running bolt you need to run it from the same directory as all that stuff is installed in. That's why, by default, the /usr/bin/bolt binary is this:

#!/bin/sh -eu
cd "$(dirname "$0")/../../../opt/bolt-launcher"
exec ./bolt "$@"

So either your CWD isn't set to the installation directory, or installation wasn't done correctly.

nezia1 commented 2 weeks ago

image

This is what I have. Is that all in the right location?

nezia1 commented 1 week ago

Hey, quick update on the NixOS packaging status. We're almost done working on it, as there has been a few issues we ran into, but it should be ready soon enough. We had to patch a few of your cmake files to make it work, as downloading libcef under cef/dist does not work with how NixOS does things (it's not possible/very recommended against to download binaries as part of a build system).

We were thinking of submitting a PR (as unobtrusive as possible to your build system) to allow us to use OS level libcef instead of the downloaded version. Ideally, this would just be a flag, and it would allow us and other atomic distributions to package your app more easily. Would that be fine by you?

Adamcake commented 1 week ago

How do "OS level" CEF distributions vary from the ones Bolt expects? You should be able to point it to any distribution using the CEF_ROOT value, unless the internal structure of them is different?