Jump to content

Chromium: Difference between revisions

From NixOS Wiki
imported>Fadenb
Created page with "'''Note''': Firefox requires the Google Hangouts Video plugin but Chromium (37+) doesn't require any plugin to use Google Hangouts. == Per User == It is possible to configur..."
 
Add a workaround to make Chromium work with custom system-wide memory allocator.
 
(29 intermediate revisions by 17 users not shown)
Line 1: Line 1:
'''Note''': Firefox requires the Google Hangouts Video plugin but Chromium (37+) doesn't require any plugin to use Google Hangouts.
== Installation ==
=== NixOS ===
Add {{nixos:package|chromium}} to {{NixOS Manual|name=systemPackages|anchor=#sec-package-management}}.


== Per User ==
== Accelerated video playback ==  


It is possible to configure certain features in nixpkgs by creating <code>~/.nixpkgs/config.nix</code> and setting the options. See below for details on how to set the equivalent options for the system profile when running NixOS.
Make sure [[Accelerated Video Playback]] is setup on the system properly. Check {{ic|chrome://gpu}} to see if Chromium has enabled hardware acceleration.


To install Firefox and Chromium for a user profile you need to create <code>~/.nixpkgs/config.nix</code> and add the following options:
If accelerated video playback is not working, check relevant flags at {{ic|chrome://flags}}, or enable them using the cli:
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{
  environment.systemPackages = with pkgs; [
    (chromium.override {
      commandLineArgs = [
        "--enable-features=AcceleratedVideoEncoder"
        "--ignore-gpu-blocklist"
        "--enable-zero-copy"
      ];
    })
  ];
}
</nowiki>}}


~/.nixpkgs/config.nix:
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:
<pre>
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{
{
     allowUnfree = true;
  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>}}


    firefox = {
== Enabling native Wayland support ==
    enableGoogleTalkPlugin = true;
    enableAdobeFlash = true;
    };


    chromium = {
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>.
    enablePepperFlash = true; # Chromium's non-NSAPI alternative to Adobe Flash
    enablePepperPDF = true;
    };


== 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; })
  ];
}
}
</pre>
</nowiki>}}


After these options have been set you need to install the "Wrapper" versions of Firefox:
== 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


<pre>
# KeePassXC server socket and Nix store
$ nix-env -i firefox-with-plugins chromium
xdg-run/app/org.keepassxc.KeePassXC/org.keepassxc.KeePassXC.BrowserServer
</pre>
/nix/store:ro</syntaxhighlight>
 
If you are using a version that does not have a wrapper, you can write one (add to config.nix and install with `nix-env -iA nixpkgs.pkgs.firefox-bin-wrapper` or `nix-env -iA nixos.pkgs.firefox-bin-wrapper`):
<pre>
  packageOverrides = pkgs: with pkgs; rec {
    # FF bin with plugins
    firefox-bin-wrapper = wrapFirefox { browser = firefox-bin; };
  };
</pre>
 
== For NixOS ==
 
In NixOS you can configure nixpkgs options by adding a nixpkgs.config section to /etc/nixos/configuration.nix. This has no effect on nix-env commands but does apply to packages installed via the environment.systemPackages list. The options are exactly the same as above.
 
In order to install Firefox with support for plugins, you need to use the "Wrapper" version. For example, in /etc/nixos/configuration.nix environment.systemPackages this would be firefoxWrapper.
 
To install Firefox and Chromium with Google Talk and Flash in your system profile you can add the following to your configuration.nix file.
 
/etc/nixos/configuration.nix:
<pre>
...
 
nixpkgs.config = {
 
    allowUnfree = true;
 
    firefox = {
    enableGoogleTalkPlugin = true;
    enableAdobeFlash = true;
    };


== Using libc memory allocator ==
Chromium may not work when an alternative system-wide memory allocator like scudo is used. To use libc on Chromium, the following firejail wrap is required:<syntaxhighlight lang="nix">
programs.firejail = {
  enable = true;
  wrappedBinaries = {
     chromium = {
     chromium = {
    enablePepperFlash = true; # Chromium removed support for Mozilla (NPAPI) plugins so Adobe Flash no longer works
      executable = "${pkgs.chromium}/bin/chromium-browser";
    enablePepperPDF = true;
      profile = "${pkgs.firejail}/etc/firejail/chromium-browser.profile";
      extraArgs = [
        "--blacklist=/etc/ld-nix.so.preload"
      ];
     };
     };
   };
   };
};


environment.systemPackages = [ pkgs.firefoxWrapper pkgs.chromium ];
</syntaxhighlight>
...
[[Category:Applications]]
</pre>
[[Category:Web Browser]]
 
then run <pre>nixos-rebuild switch</pre>
 
== Java ==
 
To use Oracle's JRE as a browser's Java implementation, use the option "jre = true;" in the appropriate configuration file as described above.  Oracle's JRE must be manually downloaded to comply with its license.  These steps are described in the output when you try to install Firefox.
 
To use [http://icedtea.classpath.org/wiki/Main_Page IcedTea]/[http://openjdk.java.net/ OpenJDK] as a browser's Java implementation, use the option "icedtea = true;" in the appropriate configuration file as described above.  By using this Java implementation, it is possible to avoid a manual step whenever your system's Java implementation is updated or your configuration is used to build a new system.
 
== Enable GPU support ==
 
For intel:
 
<pre>
services.xserver.vaapiDrivers = [ pkgs.vaapiIntel ];
</pre>
 
== Gnome Shell extensions ==
 
Gnome Shell extensions can be enabled with <code>enableGnomeExtensions = true</code>. It is a mozilla plugin, therefore it does not work currently with Chromium.
 
[[Category:Configuration]]

Latest revision as of 21:40, 8 April 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

Using libc memory allocator

Chromium may not work when an alternative system-wide memory allocator like scudo is used. To use libc on Chromium, the following firejail wrap is required:

programs.firejail = {
  enable = true;
  wrappedBinaries = {
    chromium = {
      executable = "${pkgs.chromium}/bin/chromium-browser";
      profile = "${pkgs.firejail}/etc/firejail/chromium-browser.profile";
      extraArgs = [
        "--blacklist=/etc/ld-nix.so.preload"
      ];
    };
  };
};