Jump to content

Chromium: Difference between revisions

From Official NixOS Wiki
imported>Nh2
Link to Java issue
Ardenet (talk | contribs)
m Adjust the position of page translation tags
 
(30 intermediate revisions by 19 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.
<languages/>
<translate>


== Per User ==
== Installation ==


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.
=== NixOS ===


To install Firefox and Chromium for a user profile you need to create <code>~/.nixpkgs/config.nix</code> and add the following options:
Add {{nixos:package|chromium}} to {{NixOS Manual|name=systemPackages|anchor=#sec-package-management}}.


~/.nixpkgs/config.nix:
== Updating browser policies ==
<syntaxhighlight lang="nix">
 
{
In Chromium the policy settings, which can be accessed by using {{Ic|chrome://policy}}, allow the user to change a lot of settings that dont exist anywhere else such as
    allowUnfree = true;
 
* Creating webapps when the browser is installed
* Finding and downloading browser extensions automatically
* Enabling or disabling the dinosaur game when the device is offline
* Disable screenshots to be taken with browser extensions
* Block all downloads from the browser (if you want to do that for some reason)
* and hundreds more settings
 
=== Natively Supported Policies ===
 
By default NixOS provides a few policies that can be enabled directly, a simple example is given below to understand how these are implemented


     firefox = {
</translate>
    enableGoogleTalkPlugin = true;
<syntaxhighlight lang="nixos" line="1">  programs.chromium = {
    enableAdobeFlash = true;
    enable = true;
    homepageLocation = "https://www.startpage.com/";
    extensions = [
      "eimadpbcbfnmbkopoojfekhnkhdbieeh;https://clients2.google.com/service/update2/crx" # dark reader
      "aapbdbdomjkkjkaonfhkkikfgjllcleb;https://clients2.google.com/service/update2/crx" # google translate
    ];
     extraOpts = {
      "WebAppInstallForceList" = [
        {
          "custom_name" = "Youtube";
          "create_desktop_shortcut" = false;
          "default_launch_container" = "window";
          "url" = "https://youtube.com";
        }
      ];
     };
     };
  };</syntaxhighlight>
<translate>


    chromium = {
* {{Ic|homepageLocation}} option allows you to set the site that the homepage will open on
    enablePepperFlash = true; # Chromium's non-NSAPI alternative to Adobe Flash
* {{Ic|extensions}} allows for the download of extensions directly in the browser through a simple list of the extension ID's that can be obtained from the [https://chromewebstore.google.com/ Chrome Web Store] by opening an extension page and copying the last part of the URL
    };
** In the example however there is another component, the download source from which the extensions will be downloaded
** The URL provided in the list is the link that is used by google for managing, checking and updating extensions
** So the method of just placing the extension ID can work like this: {{Ic|"fnpbehpgglbfnpimkachnpnecjncndgm"}}
** But just in case that method does not automatically function the second method is shown above, where you place {{Ic|;}} and then the URL {{Ic|https //clients2.google.com/service/update2/crx}} to explicitly tell NixOS where to install the extension from
* There are many more options that are natively supported and you can learn about them through {{Ic|man configuration.nix}}
* But as shown above there is also an {{Ic|extraOpts}} option and that is used for policies that are not supported for direct setup, such as the policy to install web-apps
 
=== Non-natively Supported Policies ===
 
As stated beforehand, there are hundreds of policies that are in chromium based browsers and not all of them can be supported directly and so the {{Ic|extraOpts}} option allows for the declaration of all the other policies
 
There is no one place to find all the policies and some places you can find a "list" are given below:


}
* A good number of commonly used policies are present and explained within {{Ic|man configuration.nix}} under {{Ic|programs.chromium}}
</syntaxhighlight>
* If you require a more comprehensive list then you can go to {{Ic|chrome://policy}} and click on the checkbox at the top of the page that says "Show policies with no value set", from there you can click on any of the policies to go to the documentation page for that policy to get details on how to use it
* If you just want to see the list of all policies supported by chromium then you cant really do that, unfortunately google does not provide documentation on every single policy in the chromium browser base and if you wish to see the list of every single policy then you can do so by going directly to the source code and figuring out how a policy works
* To see the most up-to-date file on all policies you can go [https://source.chromium.org/chromium/chromium/src/+/main:chrome/common/pref_names.h here]


After these options have been set you need to install the "Wrapper" versions of Firefox:
== Accelerated video playback ==


<syntaxhighlight lang="console">
$ nix-env -i firefox-with-plugins chromium
</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`):
Make sure [[Special:MyLanguage/Accelerated Video Playback|Accelerated Video Playback]] is setup on the system properly. Check {{ic|chrome://gpu}} to see if Chromium has enabled hardware acceleration.
<syntaxhighlight lang="nix">
  packageOverrides = pkgs: with pkgs; rec {
    # FF bin with plugins
    firefox-bin-wrapper = wrapFirefox { browser = firefox-bin; };
  };
</syntaxhighlight>


== For NixOS ==
If accelerated video playback is not working, check relevant flags at {{ic|chrome://flags}}, or enable them using the cli:


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.
</translate>
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{
  environment.systemPackages = with pkgs; [
    (chromium.override {
      commandLineArgs = [
        "--enable-features=AcceleratedVideoEncoder"
        "--ignore-gpu-blocklist"
        "--enable-zero-copy"
      ];
    })
  ];
}
</nowiki>}}
<translate>


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.
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:


To install Firefox and Chromium with Google Talk and Flash in your system profile you can add the following to your configuration.nix file.
</translate>
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{
  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>}}
<translate>


/etc/nixos/configuration.nix:
== Enabling native Wayland support ==
<syntaxhighlight lang="nix">
...


nixpkgs.config = {
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>.


    allowUnfree = true;
== Enabling ManifestV2 support ==


    firefox = {
To enable manifest v2 support <code>ExtensionManifestV2Availability</code> can be set to <code>2</code>.<ref>https://chromeenterprise.google/policies/#ExtensionManifestV2Availability</ref>
    enableGoogleTalkPlugin = true;
    enableAdobeFlash = true;
    };


     chromium = {
</translate>
    enablePepperFlash = true; # Chromium removed support for Mozilla (NPAPI) plugins so Adobe Flash no longer works
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{
  programs.chromium = {
     extraOpts = {
"ExtensionManifestV2Availability" = 2;
     };
     };
   };
   };
}
</nowiki>}}
<translate>


environment.systemPackages = [ pkgs.firefoxWrapper pkgs.chromium ];
== Enabling DRM (Widevine support) ==
...
</syntaxhighlight>


then run <pre>nixos-rebuild switch</pre>
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:


== Java ==
</translate>
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{
  environment.systemPackages = with pkgs; [
    (chromium.override { enableWideVine = true; })
  ];
}
</nowiki>}}
<translate>


Note: It is not clear whether this section is out of date, and whether any advice in this section ever worked. See https://github.com/NixOS/nixpkgs/issues/84909.
== KeePassXC support in Flatpak ==


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 enable browser integration between KeePassXC and Chromium-based browsers when running in Flatpak, configure the following filesystem access:


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.
</translate>
<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


== Enable GPU support ==
# KeePassXC server socket and Nix store
xdg-run/app/org.keepassxc.KeePassXC/org.keepassxc.KeePassXC.BrowserServer
/nix/store:ro</syntaxhighlight>
<translate>


For intel:
== Using libc memory allocator ==


64 bit
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:
 
</translate>
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
hardware.opengl.extraPackages = with pkgs; [ vaapiIntel ];
programs.firejail = {
</syntaxhighlight>
  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"
      ];
    };
  };
};


32 bit
<syntaxhighlight lang="nix">
hardware.opengl.extraPackages32 = with pkgs.pkgsi686Linux; [ vaapiIntel ];
</syntaxhighlight>
</syntaxhighlight>


== Gnome Shell extensions ==
[[Category:Applications]]
 
[[Category:Web Browser{{#translation:}}]]
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 17:04, 7 October 2025


Installation

NixOS

Add chromium to systemPackages.

Updating browser policies

In Chromium the policy settings, which can be accessed by using chrome://policy, allow the user to change a lot of settings that dont exist anywhere else such as

  • Creating webapps when the browser is installed
  • Finding and downloading browser extensions automatically
  • Enabling or disabling the dinosaur game when the device is offline
  • Disable screenshots to be taken with browser extensions
  • Block all downloads from the browser (if you want to do that for some reason)
  • and hundreds more settings

Natively Supported Policies

By default NixOS provides a few policies that can be enabled directly, a simple example is given below to understand how these are implemented

  programs.chromium = {
    enable = true;
    homepageLocation = "https://www.startpage.com/";
    extensions = [
      "eimadpbcbfnmbkopoojfekhnkhdbieeh;https://clients2.google.com/service/update2/crx" # dark reader
      "aapbdbdomjkkjkaonfhkkikfgjllcleb;https://clients2.google.com/service/update2/crx" # google translate
    ];
    extraOpts = {
      "WebAppInstallForceList" = [
        {
          "custom_name" = "Youtube";
          "create_desktop_shortcut" = false;
          "default_launch_container" = "window";
          "url" = "https://youtube.com";
        }
      ];
    };
  };
  • homepageLocation option allows you to set the site that the homepage will open on
  • extensions allows for the download of extensions directly in the browser through a simple list of the extension ID's that can be obtained from the Chrome Web Store by opening an extension page and copying the last part of the URL
    • In the example however there is another component, the download source from which the extensions will be downloaded
    • The URL provided in the list is the link that is used by google for managing, checking and updating extensions
    • So the method of just placing the extension ID can work like this: "fnpbehpgglbfnpimkachnpnecjncndgm"
    • But just in case that method does not automatically function the second method is shown above, where you place ; and then the URL https //clients2.google.com/service/update2/crx to explicitly tell NixOS where to install the extension from
  • There are many more options that are natively supported and you can learn about them through man configuration.nix
  • But as shown above there is also an extraOpts option and that is used for policies that are not supported for direct setup, such as the policy to install web-apps

Non-natively Supported Policies

As stated beforehand, there are hundreds of policies that are in chromium based browsers and not all of them can be supported directly and so the extraOpts option allows for the declaration of all the other policies

There is no one place to find all the policies and some places you can find a "list" are given below:

  • A good number of commonly used policies are present and explained within man configuration.nix under programs.chromium
  • If you require a more comprehensive list then you can go to chrome://policy and click on the checkbox at the top of the page that says "Show policies with no value set", from there you can click on any of the policies to go to the documentation page for that policy to get details on how to use it
  • If you just want to see the list of all policies supported by chromium then you cant really do that, unfortunately google does not provide documentation on every single policy in the chromium browser base and if you wish to see the list of every single policy then you can do so by going directly to the source code and figuring out how a policy works
  • To see the most up-to-date file on all policies you can go here

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 ManifestV2 support

To enable manifest v2 support ExtensionManifestV2Availability can be set to 2.[1]

❄︎ /etc/nixos/configuration.nix
{
  programs.chromium = {
    extraOpts = {
	"ExtensionManifestV2Availability" = 2;
    };
  };
}

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"
      ];
    };
  };
};