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

vivaldi: allow selecting qt5 or 6 and gtk3 or 4 #292148

Closed
wants to merge 1 commit into from

Conversation

matklad
Copy link
Member

@matklad matklad commented Feb 28, 2024

Description of changes

Make vivaldi's qt and gtk versions overridable. qt5 and gtk3 are still used by default, but the user now have the option of vivaldi.override { qt = qt6; }

Notably, overriding qt to version 6 is required to make vivaldi work with plasma 6:

#286522 (comment)

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.05 Release Notes (or backporting 23.05 and 23.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@NickCao
Copy link
Member

NickCao commented Feb 28, 2024

Notably, overriding qt to version 6 is required to make vivaldi work with plasma 6:

I don't think so, please try using qt5.wrapQtAppsHook

@matklad
Copy link
Member Author

matklad commented Feb 28, 2024

Notably, overriding qt to version 6 is required to make vivaldi work with plasma 6:

I don't think so,

It definitely does not work on my box without that override

please try using qt5.wrapQtAppsHook

I gather we intentionally avoid the wrapper here?

https://github.com/NixOS/nixpkgs/pull/222718/files#r1147390358

@NickCao
Copy link
Member

NickCao commented Feb 28, 2024

It definitely does not work on my box without that override

I mean the override is just a hack instead of a proper solution.

I gather we intentionally avoid the wrapper here?

But why, if it depends on qt, it is a qt application. The wrapper provides the correct QT_PLUGIN_PATH for the wayland backend (or other qt plugins) to be found.

@matklad
Copy link
Member Author

matklad commented Feb 28, 2024

Ah, that makes sense. I must say I am out of my depth here, so let cc @spacefrogg here :-)

Copy link
Contributor

@AsPulse AsPulse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I'm author of below pull requests that started the conversation, and appereciate your awesome suggestion!!


However, there is a slight deviation from the original intent, which I would be happy if you consider.
Original problem which I thought is that vivaldi is not working on gtk4 even though it has --gtk-version=4 as a option.
Vivaldi cannot found gtk4 manually installed by user, the only way is to include gtk4 as a dependency on the nixpkgs side.


I think we have two options:

  1. So, If we decide that the Nixpkgs side specify which gtk to use...
    I believe that --gtk-version-4 should be automatically added to default flags. if gtk4 selected.

  2. Or as it has always been, If we decide that the User side specify which gtk to use by flags...
    What we should have is like...

    enableGtk3 ? true
    enableGtk4 ? false
    enableQt5 ? true
    enableQt6 ? false
    

    or,

    gtk ? [gtk3]
    qt ? [qt5]
    

    In short, the should be able to include multiple package because users may use --gtk-version=3, or they may use --gtk-version-4.

Personally, I think the latter is better, but I am not sure....

Copy link
Contributor

@spacefrogg spacefrogg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Please see other comments.

@@ -113,7 +115,7 @@ in stdenv.mkDerivation rec {
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}" \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also add the following to accommodate gtk4 support

--add-flags --gtk-version=${lib.versions.major gtk.version}

Comment on lines 12 to 15
, gtk ? gtk3
, qt ? qt5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Document, how they are supposed to be used,

@66Leo66
Copy link

66Leo66 commented Mar 9, 2024

Just upgraded to KDE 6, got a broken vivaldi and finally managed to bring it up using vivaldi --disable-features=AllowQt.

What's the suggested local fix before this gets merged (if it eventually will be)? And btw, shouldn't we land a fix asap, even if it's hacky, so that users won't face a broken browser after updating? (At least that what my understanding of distribution packaging's job...)

@yswtrue
Copy link

yswtrue commented Mar 9, 2024

After upgrade to plasma 6, it still can't start direct from start menu, but it can start in terminal

@padhia
Copy link

padhia commented Mar 9, 2024

Just upgraded to KDE 6, got a broken vivaldi and finally managed to bring it up using vivaldi --disable-features=AllowQt.

Thank you for providing this workaround! I held off upgrading to Plasma 6 just because of this regression!

I realize there are too many packages to test, but browsers are some of the core and highly personalized software that people can't function without.

@66Leo66
Copy link

66Leo66 commented Mar 9, 2024

Just upgraded to KDE 6, got a broken vivaldi and finally managed to bring it up using vivaldi --disable-features=AllowQt.

Thank you for providing this workaround! I held off upgrading to Plasma 6 just because of this regression!

I realize there are too many packages to test, but browsers are some of the core and highly personalized software that people can't function without.

I'm glad you find it helpful! And yes, really, it's frustrating when a browser is completely broken, and even more so when a fix PR remains inactive for a week.
Not to blame anyone though. The volume of nixpkgs issues and prs is overwhelming I guess.

@matklad matklad force-pushed the matklad/poly-vivaldi branch 2 times, most recently from b4f77fb to 02fc611 Compare March 21, 2024 14:16
@matklad
Copy link
Member Author

matklad commented Mar 22, 2024

@spacefrogg PTAL:

  • added doc comments for qt and gtk versions
  • added --gtk-version= flag

Still not sure whether we should go with the whole "wrapQtApp" thing. But I think this is already an improvements, and I personally would rather stop here, as I don't want to do a larger refactor here.

@matklad
Copy link
Member Author

matklad commented Mar 22, 2024

and even more so when a fix PR remains inactive for a week.

The PR was blocked on me doing the requested changes. In this situation, it might be better to submit a counter-PR which is better and can be merged as is (provided that you understand what maintainers want, and can actually send a PR which can be merged without requiring further review).

@spacefrogg
Copy link
Contributor

Still not sure whether we should go with the whole "wrapQtApp" thing. But I think this is already an improvements, and I personally would rather stop here, as I don't want to do a larger refactor here.

As I understand it, vivaldi is neither a qt nor a GTK application. It supports both libraries to blend-in with respective window managers. I suppose, that is what the qt5 and qt6 shims are there for. Thus, I would refrain from using any qt- or GTK-specific wrapper until this cannot be avoided. It would likely mean splitting the package into definite qt- and GTK-enabled versions which the user would have to be consciously picking.

@spacefrogg
Copy link
Contributor

@66Leo66 @yswtrue @padhia I would like you to test, whether the changes work on your side, picking any of the four variants of GTK3/4 and qt5/6.

@padhia
Copy link

padhia commented Mar 24, 2024

@66Leo66 @yswtrue @padhia I would like you to test, whether the changes work on your side, picking any of the four variants of GTK3/4 and qt5/6.

Not sure if I am doing something wrong, but vivalid still fails.

~❯ nix run github:nixos/nixpkgs#vivaldi --impure                                                                                          via 🐍 v3.11.8 (.venv) via ❄  impure (sfconn-env) 
Gtk-Message: 10:00:18.502: Failed to load module "appmenu-gtk-module"
qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in ""
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

[0324/100018.525458:ERROR:elf_dynamic_array_reader.h(64)] tag not found
[0324/100018.525534:ERROR:elf_dynamic_array_reader.h(64)] tag not found
[0324/100018.525806:ERROR:process_memory_range.cc(75)] read out of range

I am sure if override qt with qt6, I can then get vivaldi to open, but I'd have expected qt6 to be somehow selected magically at build time depending on the DE the user has selected -- or at the very least, instead of failing, the command should refuse to be built/run, if the configuration isn't supported.

@spacefrogg
Copy link
Contributor

No magic. So, it looks like we need four packages, then: vivaldi-gtk3-qt5, vivaldi-gtk4-qt5, vivaldi-gtk3-qt6 and vivaldi-gtk4-qt6, each of which is a simple vivaldi.override { ... } with the relevant selections for gtk and qt.

@matklad
Copy link
Member Author

matklad commented Mar 26, 2024

So, it looks like we need four packages

I'd rather leave that for someone else to do in a follow up: that will change the "public interface" of things, and I am not qualified enough to do that kind of change (and not motivated enough at this time to become qualified :) )

@matklad
Copy link
Member Author

matklad commented Apr 11, 2024

Status: my understanding is that this is waiting for review to either get merged, or get closed as an incorrect approach.

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/3032/3891

@JRodez
Copy link

JRodez commented May 27, 2024

I confirm that for Plasma 6 the following does the trick :

cus_vivaldi = pkgs.vivaldi.overrideAttrs (oldAttrs: {
      dontWrapQtApps = false;
      dontPatchELF = true;
      nativeBuildInputs = oldAttrs.nativeBuildInputs ++ [ pkgs.kdePackages.wrapQtAppsHook ];
    });

@yswtrue
Copy link

yswtrue commented May 28, 2024

I confirm that for Plasma 6 the following does the trick :

cus_vivaldi = pkgs.vivaldi.overrideAttrs (oldAttrs: {
      dontWrapQtApps = false;
      dontPatchELF = true;
      nativeBuildInputs = oldAttrs.nativeBuildInputs ++ [ pkgs.kdePackages.wrapQtAppsHook ];
    });

works finally

@Daholli
Copy link

Daholli commented Jul 4, 2024

I confirm that for Plasma 6 the following does the trick :

cus_vivaldi = pkgs.vivaldi.overrideAttrs (oldAttrs: {
      dontWrapQtApps = false;
      dontPatchELF = true;
      nativeBuildInputs = oldAttrs.nativeBuildInputs ++ [ pkgs.kdePackages.wrapQtAppsHook ];
    });

for me this now lets me start it from terminal again, but the taskbar icon just does nothing after some short loading.
it worked with

vivaldi.override { commandLineArgs = "--disable-features=AllowQt"; };

for quite some time but after the last update it just stopped working. using the wrapQtAppsHook i can at least open it in the terminal now, but i cant figure out what is still wrong with the icon alone

edit:

something i just found out is that if I attempt to run the pkg that is referenced in the .desktop file it does not work, but if i add a command line parameter it does start up

❯ /nix/store/i5324pwbijs0r0prh4x2ds4yrkv5w8vk-vivaldi-6.8.3381.46/bin/vivaldi
qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in ""
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx.

[0704/232857.071733:ERROR:elf_dynamic_array_reader.h(64)] tag not found
[0704/232857.071986:ERROR:elf_dynamic_array_reader.h(64)] tag not found
[0704/232857.073038:ERROR:process_memory_range.cc(75)] read out of range
fish: Job 1, '/nix/store/i5324pwbijs0r0prh4x2…' terminated by signal SIGABRT (Abort)
❯ /nix/store/i5324pwbijs0r0prh4x2ds4yrkv5w8vk-vivaldi-6.8.3381.46/bin/vivaldi --ozone-platform=wayland
libEGL warning: egl: failed to create dri2 screen
DRM kernel driver 'nvidia-drm' in use. NVK requires nouveau.
MESA: error: ZINK: failed to choose pdev
libEGL warning: egl: failed to create dri2 screen
libEGL warning: egl: failed to create dri2 screen
DRM kernel driver 'nvidia-drm' in use. NVK requires nouveau.
MESA: error: ZINK: failed to choose pdev
libEGL warning: egl: failed to create dri2 screen
[221184:221184:0704/232905.987894:ERROR:viz_main_impl.cc(166)] Exiting GPU process due to errors during initialization
libEGL warning: egl: failed to create dri2 screen
DRM kernel driver 'nvidia-drm' in use. NVK requires nouv

my current overlay looks like this:

final: prev: {
  vivaldi = (prev.vivaldi.overrideAttrs (oldAttrs: {
    dontWrapQtApps = false;
    nativeBuildInputs = oldAttrs.nativeBuildInputs ++ [
    channels.unstable.kdePackages.wrapQtAppsHook ];
  })).override {
    commandLineArgs = ''
      -enable-features=UseOzonePlatform
      --ozone-platform=wayland
      --ozone-platform-hint=auto
      --enable-features=WaylandWindowDecorations 
    '';
  };
}

@Daholli
Copy link

Daholli commented Jul 4, 2024

After some more testing, there are multiple versions in the nix store (due to me recompiling multiple times), that run out of the box, but the one linked in my .desktop file never does, anyone has some idea how i can properly update the desktop item, since the vivaldi package does not seem to use the makeDesktopIcon and it seems a bit backwards to reimplement the whole Install phase thing

@max06
Copy link

max06 commented Jul 8, 2024

@Daholli somehow your options don't work for me

[flo@monster:~/.config/vivaldi]$ vivaldi --enable-features=UseOzonePlatform --ozone-platform=wayland --ozone-platform-hint=auto --enable-features=WaylandWindowDecorations 
qt.qpa.plugin: Could not find the Qt platform plugin "wayland" in ""
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.

[0708/172115.819678:ERROR:process_memory_range.cc(75)] read out of range
Aborted (core dumped)

Installed vivaldi with

      ( vivaldi.overrideAttrs (oldAttrs: {
        dontWrapQtApps = false;
        dontPatchELF = true;
        nativeBuildInputs = oldAttrs.nativeBuildInputs ++ [ pkgs.kdePackages.wrapQtAppsHook ];
      }) )

(New to nixos, it could be me doing stupid things)

@Daholli
Copy link

Daholli commented Jul 8, 2024

You might also need the package qt5.qtwayland

@BonewheelMaster
Copy link

I was able to get Vivaldi running on Plasma 6 by installing the package libsForQt5.qt5.qtwayland and using the Wayland Ozone backend (achieved by adding --ozone-platform=wayland).

@Cybolic
Copy link

Cybolic commented Sep 11, 2024

While I could get Vivaldi to run with adding libsForQt5.qt5.qtwayland and running it with --ozone-platform=wayland as well as this mentioned setup:

I confirm that for Plasma 6 the following does the trick :

cus_vivaldi = pkgs.vivaldi.overrideAttrs (oldAttrs: {
      dontWrapQtApps = false;
      dontPatchELF = true;
      nativeBuildInputs = oldAttrs.nativeBuildInputs ++ [ pkgs.kdePackages.wrapQtAppsHook ];
    });

- both of those setups produced a mix of blank Vivaldi windows and/or blank/non-rendering tabs.

What finally worked for me, was using the same change as is in this PR, which still works on the current version in nixpkgs unstable:

(pkgs.vivaldi.overrideAttrs (oldAttrs: {
  buildPhase = builtins.replaceStrings
    ["for f in libGLESv2.so libqt5_shim.so ; do"]
    ["for f in libGLESv2.so libqt5_shim.so libqt6_shim.so ; do"]
    oldAttrs.buildPhase
  ;
})).override {
  qt5 = pkgs.qt6;
  commandLineArgs = [ "--ozone-platform=wayland" ];
  # The following two are just my preference, feel free to leave them out
  proprietaryCodecs = true;
  enableWidevine = true;
};

I'm running Plasma 6 on Wayland, so that might have something to do with my issues with qt5.

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/new-install-vivaldi-not-starting/53282/1

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

Successfully merging this pull request may close these issues.