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

Trying to package for NixOS: Zygote error #66

Open
nezia1 opened this issue Aug 30, 2024 · 13 comments
Open

Trying to package for NixOS: Zygote error #66

nezia1 opened this issue Aug 30, 2024 · 13 comments

Comments

@nezia1
Copy link

nezia1 commented Aug 30, 2024

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
Copy link
Owner

Adamcake commented Aug 30, 2024

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
Copy link
Owner

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

@nezia1
Copy link
Author

nezia1 commented Aug 30, 2024

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
Copy link
Owner

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
Copy link
Author

nezia1 commented Aug 30, 2024

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
Copy link
Owner

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
Copy link
Author

nezia1 commented Aug 30, 2024

image

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

@nezia1
Copy link
Author

nezia1 commented Sep 2, 2024

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
Copy link
Owner

Adamcake commented Sep 4, 2024

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?

@Adamcake
Copy link
Owner

I looked into this today. Unfortunately, the libcef package on nixpkgs isn't really useful for anything. A normal CEF-based program would have all the libraries and the program itself in one directory, and in particular, CEF insists that libcef.so and icudtl.dat need to be in the same directory, otherwise it will just fail to load it. But the nixpkgs build downloads an official CEF binary and installs libcef.so in $out/lib, and icudtl.dat in $out/share/cef - different directories. So it's fundamentally broken.

The only package that uses nixpkgs libcef is "obs-studio", and that makes it work by symlinking all the stuff back to where it's supposed to be...

@nezia1
Copy link
Author

nezia1 commented Oct 31, 2024

Hey, I managed to fix it in the meantime. I got into a whole lot of issues since, like you said, libcef is broken on NixOS, but we managed to fix it by overriding the entire install process.

See NixOS/nixpkgs/pull/338470 for more details. I should probably open an issue for it, to avoid other people to spend the amount of time we did on the issue because of a broken package.

Thanks a lot for your time anyway!

@Adamcake
Copy link
Owner

Adamcake commented Oct 31, 2024 via email

@nezia1
Copy link
Author

nezia1 commented Nov 1, 2024

Yes exactly! I had to do something extremely similar (it made the whole derivation really ugly). From what I've seen, it looks like other apps use libcef in its current format without overriding, really unsure how it works for them (if it even does).

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

2 participants