How can I install some (not all) nerdfonts?

I installed nix in debian.
I would like to install some (not all) nerdfonts.

Here is what I did:
Use arg as specified in nix profile install --help:

  • Execute this:
$ nix profile install nixpkgs#nerdfonts --arg fonts '["JetBrainsMono"]'
error: '--arg' and '--argstr' are incompatible with flakes
Try 'nix --help' for more information.

Specify a custom package in ~/.config/nixpkgs/config.nix:

  • Write this in ~/.config/nixpkgs/config.nix:
{
  packageOverrides = pkgs: with pkgs; {
    jetbrains-mono-nerdfont = pkgs.nerdfonts.override {
      fonts = ["JetBrainsMono"];
    };
  };
}
  • Execute this:
$ nix profile install nixpkgs#jetbrains-mono-nerdfont
error: flake 'flake:nixpkgs' does not provide attribute 'packages.x86_64-linux.jetbrains-mono-nerdfont', 'legacyPackages.x86_64-linux.jetbrains-mono-nerdfont' or 'jetbrains-mono-nerdfont'

Override the existing nerdfonts package in ~/.config/nixpkgs/config.nix:

  • Write this in ~/.config/nixpkgs/config.nix:
{
  packageOverrides = pkgs: with pkgs; {
    nerdfonts = pkgs.nerdfonts.override {
      fonts = ["JetBrainsMono"];
    };
  };
}
  • Execute this:
$ nix profile install nixpkgs#nerdfonts
<tries to download all the fonts, not some>

What should I do to only install some (not all) nerdfonts?

Settings from ~/.config/nixpkgs/config.nix won’t apply in pure evaluation mode (the default for the nix command).

Try this:

nix profile install --expr 'with builtins.getFlake("flake:nixpkgs"); legacyPackages.x86_64-linux.nerdfonts.override { fonts = ["JetBrainsMono"]; };'
1 Like

When a new version of nerdfonts appears in nixpkgs, if I do this:

$ nix profile upgrade

Will my nerdfonts be updated as usual taking into account the fonts argument override?

If you have home-manager installed, you can do the following too:

  home.packages = with pkgs; [
    (nerdfonts.override { fonts = [ "JetBrainsMono" ]; })
  ];

  fonts.fontconfig.enable = true;