Fonts: Difference between revisions

m Added some sample code for Nerd Fonts package installation
AveryKoen (talk | contribs)
Updated information.
Line 28: Line 28:
* <code>fonts.enableDefaultPackages</code>: when set to <code>true</code>, causes some "basic" fonts to be installed for reasonable Unicode coverage. Set to <code>true</code> if you are unsure about what languages you might end up reading.
* <code>fonts.enableDefaultPackages</code>: when set to <code>true</code>, causes some "basic" fonts to be installed for reasonable Unicode coverage. Set to <code>true</code> if you are unsure about what languages you might end up reading.
* <code>fonts.enableGhostscriptFonts</code>: affects the <code>ghostscript</code> package. Ghostscript packages some URW fonts for the standard PostScript typefaces. If <code>true</code>, these fonts will be visible to GUI applications. You could set it to <code>true</code> if you want these fonts, but <code>gyre-fonts</code> (part of <code>fonts.enableDefaultPackages</code>) might be higher-quality depending on your judgement.
* <code>fonts.enableGhostscriptFonts</code>: affects the <code>ghostscript</code> package. Ghostscript packages some URW fonts for the standard PostScript typefaces. If <code>true</code>, these fonts will be visible to GUI applications. You could set it to <code>true</code> if you want these fonts, but <code>gyre-fonts</code> (part of <code>fonts.enableDefaultPackages</code>) might be higher-quality depending on your judgement.
=== Installing all nerdfonts ===
The <code>nerdfonts</code> package includes all fonts from the [https://www.nerdfonts.com/ Nerd Fonts repository], making it quite large and resulting in a longer installation time. If you want to install the entire collection, add the following line to your system configuration:{{file|/etc/nixos/configuration.nix|nix|3=fonts.packages = with pkgs; [ nerdfonts ];}}


=== Installing specific nerdfonts ===
=== Installing specific nerdfonts ===


Before Nixpkgs commit [https://github.com/NixOS/nixpkgs/commit/de4dbc58fdeb84694d47d6c3f7b9f04a57cc4231 de4dbc5] that provides individual Nerd Fonts packages under the name <code>nerd-fonts</code>, the <code>nerdfonts</code> package, which contains all fonts from the [https://www.nerdfonts.com/ nerdfonts] repository was quite large and contained a large number of fonts which took some time to install. If you only need a selection of fonts from the package, you can overwrite the font selection on Stable 20.09 like so:
If you only need a selection of fonts from the package, you can overwrite the font selection like so:


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
Line 39: Line 42:
</syntaxhighlight>
</syntaxhighlight>


This will cause NixOS to download only the [https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/FiraCode Fira Code] and [https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/DroidSansMono Droid Sans Mono] fonts from [https://github.com/ryanoasis/nerd-fonts nerd-fonts] instead of the whole package. The relevant names can be found by looking at the file name for your relevant font on the [https://github.com/ryanoasis/nerd-fonts/releases official release page] assets.
This will cause NixOS to download only the [https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/FiraCode Fira Code] and [https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/DroidSansMono Droid Sans Mono] fonts from [https://github.com/ryanoasis/nerd-fonts nerd-fonts] instead of the whole package. The relevant names can be found by looking [https://github.com/NixOS/nixpkgs/blob/8764d898c4f365d98ef77af140b32c6396eb4e02/pkgs/data/fonts/nerdfonts/shas.nix at the list of the nerdfonts names in this commit].


For configurations using later versions of Nixpkgs, individual Nerd Fonts packages can be installed like so:<syntaxhighlight lang="nix">
For configurations using later versions of Nixpkgs (after 25.05), individual Nerd Fonts packages can be installed like so:<syntaxhighlight lang="nix">
fonts.packages = with pkgs; [
fonts.packages = with pkgs; [
   nerd-fonts.fira-code
   nerd-fonts.fira-code