Chromium: Difference between revisions
m Adjust the position of page translation tags and add tvar tags |
Added section explaining how to use fonts when running Chromium in a container |
||
| (5 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
<languages/> | <languages/> | ||
<translate> | <translate> | ||
== Installation == | == Installation == <!--T:1--> | ||
=== NixOS === | === NixOS === <!--T:2--> | ||
<!--T:3--> | |||
Add <tvar name="chromium_package">{{nixos:package|chromium}}</tvar> to <tvar name="systemPackages">{{NixOS Manual|name=systemPackages|anchor=#sec-package-management}}</tvar>. | Add <tvar name="chromium_package">{{nixos:package|chromium}}</tvar> to <tvar name="systemPackages">{{NixOS Manual|name=systemPackages|anchor=#sec-package-management}}</tvar>. | ||
== Updating browser policies == | == Updating browser policies == <!--T:4--> | ||
<!--T:5--> | |||
In Chromium, policy settings are accessible via <tvar name="chrome_policy_link">{{Ic|chrome://policy}}</tvar>. They allow the user to change enterprise policies affecting things like | In Chromium, policy settings are accessible via <tvar name="chrome_policy_link">{{Ic|chrome://policy}}</tvar>. They allow the user to change enterprise policies affecting things like | ||
<!--T:6--> | |||
* Creating webapps when the browser is installed | * Creating webapps when the browser is installed | ||
* Finding and downloading browser extensions automatically | * Finding and downloading browser extensions automatically | ||
| Line 18: | Line 21: | ||
* and more! | * and more! | ||
A full list of policies can be found at [https://chromeenterprise.google/policies/ Chrome Enterprise Policy List & Management]. | <!--T:7--> | ||
A full list of policies can be found at [<tvar name=1>https://chromeenterprise.google/policies/</tvar> Chrome Enterprise Policy List & Management]. | |||
=== Natively Supported Policies === | === Natively Supported Policies === <!--T:8--> | ||
<!--T:9--> | |||
By default NixOS provides a few policies that can be enabled directly, a simple example is given below to understand how these are implemented | By default NixOS provides a few policies that can be enabled directly, a simple example is given below to understand how these are implemented | ||
</translate> | </translate> | ||
| Line 45: | Line 50: | ||
<translate> | <translate> | ||
<!--T:10--> | |||
* <tvar name="homepageLocation">{{Ic|homepageLocation}}</tvar> option allows you to set the site that the homepage will open on | * <tvar name="homepageLocation">{{Ic|homepageLocation}}</tvar> option allows you to set the site that the homepage will open on | ||
* <tvar name="extensions">{{Ic|extensions}}</tvar> 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 [<tvar name="1">https://chromewebstore.google.com/</tvar> Chrome Web Store] by opening an extension page and copying the last part of the URL | * <tvar name="extensions">{{Ic|extensions}}</tvar> 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 [<tvar name="1">https://chromewebstore.google.com/</tvar> Chrome Web Store] by opening an extension page and copying the last part of the URL | ||
| Line 54: | Line 60: | ||
* But as shown above there is also an <tvar name="extraOpts">{{Ic|extraOpts}}</tvar> option and that is used for policies that are not supported for direct setup, such as the policy to install web-apps | * But as shown above there is also an <tvar name="extraOpts">{{Ic|extraOpts}}</tvar> 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 === | === Non-natively Supported Policies === <!--T:11--> | ||
<!--T:12--> | |||
There are hundreds of policies in Chromium based browsers, and not all have direct methods to set them. The <tvar name="extraOpts">{{Ic|extraOpts}}</tvar> option allows for the declaration of all the other policies. | There are hundreds of policies in Chromium based browsers, and not all have direct methods to set them. The <tvar name="extraOpts">{{Ic|extraOpts}}</tvar> option allows for the declaration of all the other policies. | ||
<!--T:13--> | |||
There is no single place to find all Chromium policies, but these are some places to look; | There is no single place to find all Chromium policies, but these are some places to look; | ||
<!--T:14--> | |||
* Commonly used policies are present and documented within {{Ic|man configuration.nix}} under {{Ic|programs.chromium}}. | * Commonly used policies are present and documented within {{Ic|man configuration.nix}} under {{Ic|programs.chromium}}. | ||
* You can navigate to <tvar name="chrome_policy_link">{{Ic|chrome://policy}}</tvar> and enable "Show policies with no value set" to see all available keys. Clicking a policy name opens its specific definition and usage details. | * You can navigate to <tvar name="chrome_policy_link">{{Ic|chrome://policy}}</tvar> and enable "Show policies with no value set" to see all available keys. Clicking a policy name opens its specific definition and usage details. | ||
* The most up to date policies for Chromium are available in the [<tvar name="1">https://source.chromium.org/chromium/chromium/src/+/main:chrome/common/pref_names.h</tvar> source code.] | * The most up to date policies for Chromium are available in the [<tvar name="1">https://source.chromium.org/chromium/chromium/src/+/main:chrome/common/pref_names.h</tvar> source code.] | ||
== Accelerated video playback == | == Accelerated video playback == <!--T:15--> | ||
<!--T:16--> | |||
Make sure [[<tvar name="1">Special:MyLanguage/Accelerated Video Playback</tvar>|Accelerated Video Playback]] is setup on the system properly. Check <tvar name="chrome_gpu_link">{{ic|chrome://gpu}}</tvar> to see if Chromium has enabled hardware acceleration. | Make sure [[<tvar name="1">Special:MyLanguage/Accelerated Video Playback</tvar>|Accelerated Video Playback]] is setup on the system properly. Check <tvar name="chrome_gpu_link">{{ic|chrome://gpu}}</tvar> to see if Chromium has enabled hardware acceleration. | ||
<!--T:17--> | |||
If accelerated video playback is not working, check relevant flags at <tvar name="chrome_flags_link">{{ic|chrome://flags}}</tvar>, or enable them using the CLI: | If accelerated video playback is not working, check relevant flags at <tvar name="chrome_flags_link">{{ic|chrome://flags}}</tvar>, or enable them using the CLI: | ||
</translate> | </translate> | ||
| Line 86: | Line 97: | ||
<translate> | <translate> | ||
<!--T:18--> | |||
In some cases, <tvar name="chrome_gpu_link">{{ic|chrome://gpu}}</tvar> will show Video Decode as enabled, but Video Acceleration Information as blank, with <tvar name="chrome_media_link">{{ic|chrome://media-internals}}</tvar> using the FFmpeg Video Decoder (software decoding). If this happens, try to enable the following features: | In some cases, <tvar name="chrome_gpu_link">{{ic|chrome://gpu}}</tvar> will show Video Decode as enabled, but Video Acceleration Information as blank, with <tvar name="chrome_media_link">{{ic|chrome://media-internals}}</tvar> using the FFmpeg Video Decoder (software decoding). If this happens, try to enable the following features: | ||
</translate> | </translate> | ||
| Line 106: | Line 118: | ||
<translate> | <translate> | ||
== Enabling native Wayland support == | == Enabling native Wayland support == <!--T:19--> | ||
<!--T:20--> | |||
You can enable native Wayland support in all Chromium based and most Electron apps by setting the `NIXOS_OZONE_WL` environment variable to `1`. | You can enable native Wayland support in all Chromium based and most Electron apps by setting the `NIXOS_OZONE_WL` environment variable to `1`. | ||
== Enabling DRM (Widevine support) == | == Enabling DRM (Widevine support) == <!--T:21--> | ||
<!--T:22--> | |||
By default, <tvar name="chromium_package">{{nixos:package|chromium}}</tvar> does not support playing DRM protected media. However, there is a build time flag to include the proprietary Widevine blob from Nixpkgs: | By default, <tvar name="chromium_package">{{nixos:package|chromium}}</tvar> does not support playing DRM protected media. However, there is a build time flag to include the proprietary Widevine blob from Nixpkgs: | ||
</translate> | </translate> | ||
| Line 124: | Line 138: | ||
<translate> | <translate> | ||
== KeePassXC support in Flatpak == | == KeePassXC support in Flatpak == <!--T:23--> | ||
<!--T:24--> | |||
To enable browser integration between KeePassXC and Chromium-based browsers when running in Flatpak, configure the following filesystem access: | To enable browser integration between KeePassXC and Chromium-based browsers when running in Flatpak, configure the following filesystem access: | ||
</translate> | </translate> | ||
| Line 143: | Line 158: | ||
<translate> | <translate> | ||
== Using libc memory allocator == | == Using libc memory allocator == <!--T:25--> | ||
<!--T:26--> | |||
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: | 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> | </translate> | ||
| Line 161: | Line 177: | ||
}; | }; | ||
}; | }; | ||
</syntaxhighlight> | |||
<translate> | |||
== Add support for Brave Browser in Profile Sync daemon == <!--T:27--> | |||
<!--T:28--> | |||
Adding Brave Browser support to Profile Sync daemon can be automated with an overlay. | |||
</translate> | |||
<syntaxhighlight lang="nix"> | |||
# /etc/nixos/configuration.nix | |||
{ | |||
nixpkgs = { | |||
overlays = [ | |||
(final: prev: { | |||
profile-sync-daemon = prev.profile-sync-daemon.overrideAttrs (oldAttrs: { | |||
installPhase = | |||
oldAttrs.installPhase | |||
+ '' | |||
cp $out/share/psd/{contrib,browsers}/brave | |||
''; | |||
}); | |||
}) | |||
]; | |||
}; | |||
# Enable the Profile Sync daemon service. | |||
services.psd.enable = true; | |||
} | |||
</syntaxhighlight> | |||
== Getting fonts to work in containers == | |||
When building a container using {{Nixpkgs Manual|name=dockerTools.streamLayeredImage|anchor=#ssec-pkgs-dockerTools-streamLayeredImage}} or {{Nixpkgs Manual|name=dockerTools.buildLayeredImage|anchor=#ssec-pkgs-dockerTools-buildLayeredImage}}, the image won't include any fonts, and so Chrome won't be able to render any text. To handle this, you must add {{nixos:package|fontconfig}} to the image, along with the fonts you want included. | |||
Adding fonts to your image will only add them at {{ic|/share/fonts}}, but fontconfig expects them at {{ic|/usr/share/fonts}}, so you just link the fonts to that directory: | |||
<syntaxhighlight lang="nix"> | |||
{ | |||
dockerTools, | |||
chromium, | |||
fontconfig, | |||
maple-mono, | |||
bashNonInteractive, | |||
... | |||
}: | |||
dockerTools.streamLayeredImage { | |||
name = "chromium"; | |||
tag = "latest"; | |||
contents = [ | |||
chromium | |||
fontconfig.out # The default .bin output only contains binaries | |||
# Fontconfig already contains a minimal set of DejaVu fonts, adding extra | |||
# fonts is optional | |||
maple-mono.NF | |||
]; | |||
# This part is only necessary if you're adding extra fonts | |||
fakeRootCommands = '' | |||
#!${bashNonInteractive} | |||
mkdir -p usr/share | |||
ln -s /share/fonts usr/share/fonts | |||
''; | |||
} | |||
</syntaxhighlight> | |||
Chrome will then be able to discover the DejaVu and Maple Mono NF fonts through fontconfig. | |||
If you instead want to use fonts from the {{nixos:package|texlivePackages}} package set, you'll need to symlink the {{ic|/fonts}} directory instead of {{ic|/share/fonts}} as the texlive packages have a different structure: | |||
<syntaxhighlight lang="nix"> | |||
{ | |||
dockerTools, | |||
chromium, | |||
fontconfig, | |||
texlivePackages, | |||
bashNonInteractive, | |||
... | |||
}: | |||
dockerTools.streamLayeredImage { | |||
name = "chromium"; | |||
tag = "latest"; | |||
contents = [ | |||
chromium | |||
fontconfig.out | |||
texlivePackages.opensans | |||
]; | |||
fakeRootCommands = '' | |||
#!${bashNonInteractive} | |||
mkdir -p usr/share | |||
ln -s /fonts usr/share/fonts | |||
''; | |||
} | |||
</syntaxhighlight> | </syntaxhighlight> | ||
[[Category:Applications]] | [[Category:Applications]] | ||
[[Category:Web Browser{{#translation:}}]] | [[Category:Web Browser{{#translation:}}]] | ||