NixOS Nerd Fonts
Nix has a terrific package manager that enables quick and easy installation of any program or package under the sun, and this includes fonts, with the exact same workflow:
- Find a font package.
- Add it to your NixOS config.
- Rebuild and enjoy.
There are a couple of settings required to get this all to work, so let’s dive in!
HEADS UP! This guide assumes you are using Home Manager.
Installing Fonts
First enable fonts.fontDir
in configuration.nix
. If it isn’t already add this line:
fonts.fontDir.enable = true;
Rebuild, $ nixos-rebuild switch --flake .
. Next in the home manager ensure
fontconfig
is enabled as well.
fonts.fontconfig.enable = true;
Find and install the font package of your choice.
home.packages = with pkgs; [
pkgs.iosevka
];
Run $ home-manager switch --flake .
to install. Now Iosevka
should be available on your system.
Installing Nerd Fonts
With the ability to declare fonts as configuration, adding the prerequiste Nerd Fonts to beautify our terminals is incredibly easy.
home.packages = with pkgs; [
(pkgs.nerdfonts.override {
fonts = [
"IBMPlexMono"
"Iosevka"
"IosevkaTerm"
];
})
];
To avoid installing the entire Nerd Font package, which is quite large, add the
desired patched font ot the package override
.
Here is how I use them in Alacritty. The Nerd Font override name, like
IBMPlexMono
doesn’t always align with the font name you assign in your
config (BlexMono
is used instead in this case), so be sure to consult the
patched fonts table on GitHub.
programs.alacritty = {
enable = true;
settings = {
font = {
normal = {
family = "IosevkaTerm Nerd Font";
style = "Regular";
};
bold = {
family = "IosevkaTerm Nerd Font";
style = "Bold";
};
italic = {
family = "IosevkaTerm Nerd Font";
style = "Italic";
};
bold_italic = {
family = "IosevkaTerm Nerd Font";
style = "Bold Italic";
};
size = 16;
};
};
Hopefully this helps other fellow newcomers to NixOS. I always find documentation gets me 90% of the way there, so hopefully this post completes the picture for you. If you know of a better way feel free to reach out.