Chromium: Difference between revisions

From NixOS Wiki
Sdht0 (talk | contribs)
→‎Enable GPU accelerated video decoding (VA-API): Copy edit, add working configuration
Ad2tba (talk | contribs)
Add KeePassXC support in Flatpak section
 
(9 intermediate revisions by 5 users not shown)
Line 13: Line 13:
     (chromium.override {
     (chromium.override {
       commandLineArgs = [
       commandLineArgs = [
         "--enable-features=VaapiVideoDecodeLinuxGL"
         "--enable-features=AcceleratedVideoEncoder"
         "--ignore-gpu-blocklist"
         "--ignore-gpu-blocklist"
         "--enable-zero-copy"
         "--enable-zero-copy"
Line 22: Line 22:
</nowiki>}}
</nowiki>}}


== Gnome Shell extensions ==
In some cases, {{ic|chrome://gpu}} will show Video Decode as enabled, but Video Acceleration Information as blank, with {{ic|chrome://media-internals}} using FFmpeg Video Decoder (software decoding). If this happens, try to enable the following features:
 
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
Gnome Shell extensions can be enabled with <code>enableGnomeExtensions = true</code>. It is a mozilla plugin, therefore it does not work currently with Chromium.
{
  environment.systemPackages = with pkgs; [
    (chromium.override {
      commandLineArgs = [
        "--enable-features=AcceleratedVideoEncoder,VaapiOnNvidiaGPUs,VaapiIgnoreDriverChecks,Vulkan,DefaultANGLEVulkan,VulkanFromANGLE"
        "--enable-features=VaapiIgnoreDriverChecks,VaapiVideoDecoder,PlatformHEVCDecoderSupport"
        "--enable-features=UseMultiPlaneFormatForHardwareVideo"
        "--ignore-gpu-blocklist"
        "--enable-zero-copy"
      ];
    })
  ];
}
</nowiki>}}


== Enabling native Wayland support ==
== Enabling native Wayland support ==


Since Nixos 22.05 you can turn on native wayland support in all chrome and most electron apps by setting an environment variable: <code>environment.sessionVariables.NIXOS_OZONE_WL = "1"</code> ([https://nixos.org/manual/nixos/unstable/release-notes.html#sec-release-22.05-notable-changes see notable changes])
You can turn on native Wayland support in all chrome and most electron apps by setting an environment variable: <code>environment.sessionVariables.NIXOS_OZONE_WL = "1"</code>.


In earlier versions you can enable wayland support by setting the appropriate command-line flags:
== Enabling DRM (Widevine support) ==
By default, {{nixos:package|chromium}} does not support playing DRM protected media. However, there is a build time flag to include the unfree Widevine blob from nixpkgs:
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{
  environment.systemPackages = with pkgs; [
    (chromium.override { enableWideVine = true; })
  ];
}
</nowiki>}}
 
== KeePassXC support in Flatpak ==
To enable browser integration between KeePassXC and Chromium-based browsers when running in Flatpak, configure the following filesystem access:<syntaxhighlight lang="toml">
# NativeMessagingHost directory (browser-specific)
# Brave Browser
xdg-config/BraveSoftware/Brave-Browser/NativeMessagingHosts:ro
# Chromium
xdg-config/chromium/NativeMessagingHosts:ro
# Google Chrome
xdg-config/google-chrome/NativeMessagingHosts:ro


<syntaxhighlight lang="nix">
# KeePassXC server socket and Nix store
nixpkgs.config.chromium.commandLineArgs = "--enable-features=UseOzonePlatform --ozone-platform=wayland";
xdg-run/app/org.keepassxc.KeePassXC/org.keepassxc.KeePassXC.BrowserServer
/nix/store:ro
</syntaxhighlight>
</syntaxhighlight>
== Overriding Chromium ==
Note: This section was never properly tested. Please update it accordingly if you notice issues with the examples and feel free to extend it.
To create a customized Chromium the following approach can be used:
<pre>
chromium.mkDerivation (base: { name = "my-chromium"; gnFlags = { test_flag = 42; }; })
</pre>
It should also be possible to override a Chromium attribute using <pre>chromium.browser.overrideAttrs ...</pre>.
[[Category:Configuration]]
[[Category:Applications]]
[[Category:Applications]]
[[Category:Web Browser]]

Latest revision as of 08:50, 4 February 2025

Installation

NixOS

Add chromium to systemPackages.

Accelerated video playback

Make sure Accelerated Video Playback is setup on the system properly. Check chrome://gpu to see if Chromium has enabled hardware acceleration.

If accelerated video playback is not working, check relevant flags at chrome://flags, or enable them using the cli:

/etc/nixos/configuration.nix
{
  environment.systemPackages = with pkgs; [
    (chromium.override {
      commandLineArgs = [
        "--enable-features=AcceleratedVideoEncoder"
        "--ignore-gpu-blocklist"
        "--enable-zero-copy"
      ];
    })
  ];
}

In some cases, chrome://gpu will show Video Decode as enabled, but Video Acceleration Information as blank, with chrome://media-internals using FFmpeg Video Decoder (software decoding). If this happens, try to enable the following features:

/etc/nixos/configuration.nix
{
  environment.systemPackages = with pkgs; [
    (chromium.override {
      commandLineArgs = [
        "--enable-features=AcceleratedVideoEncoder,VaapiOnNvidiaGPUs,VaapiIgnoreDriverChecks,Vulkan,DefaultANGLEVulkan,VulkanFromANGLE"
        "--enable-features=VaapiIgnoreDriverChecks,VaapiVideoDecoder,PlatformHEVCDecoderSupport"
        "--enable-features=UseMultiPlaneFormatForHardwareVideo"
        "--ignore-gpu-blocklist"
        "--enable-zero-copy"
      ];
    })
  ];
}

Enabling native Wayland support

You can turn on native Wayland support in all chrome and most electron apps by setting an environment variable: environment.sessionVariables.NIXOS_OZONE_WL = "1".

Enabling DRM (Widevine support)

By default, chromium does not support playing DRM protected media. However, there is a build time flag to include the unfree Widevine blob from nixpkgs:

/etc/nixos/configuration.nix
{
  environment.systemPackages = with pkgs; [
    (chromium.override { enableWideVine = true; })
  ];
}

KeePassXC support in Flatpak

To enable browser integration between KeePassXC and Chromium-based browsers when running in Flatpak, configure the following filesystem access:

# NativeMessagingHost directory (browser-specific)
# Brave Browser
xdg-config/BraveSoftware/Brave-Browser/NativeMessagingHosts:ro
# Chromium
xdg-config/chromium/NativeMessagingHosts:ro
# Google Chrome
xdg-config/google-chrome/NativeMessagingHosts:ro

# KeePassXC server socket and Nix store
xdg-run/app/org.keepassxc.KeePassXC/org.keepassxc.KeePassXC.BrowserServer
/nix/store:ro