Chromium: Difference between revisions

Ardenet (talk | contribs)
m Add the tvar tag to the external links that were overlooked.
Added section explaining how to use fonts when running Chromium in a container
 
(3 intermediate revisions by 2 users not shown)
Line 177: 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:}}]]