How to find the name of a Nix package to install it in configuration.nix?

372

Solution 1

NixOS community has three manuals, always consult them first, if you're stuck:

Every package on Nix is specified by a Nix expression. A Nix expression is some text, written in Nix language, typically residing in a file with extension .nix.

Every expression has the so-called “symbolic name”, a human-readable name that is printed, when you use nix-env. See sample Nix expression. Nix itself doesn't use this symbolic name anywhere internally, so it doesn't matter if your package is named aspell-dict-en, it's just for your, human's, convenience.

What actually matters is the so-called “attribute path”. So your confusion is between symbolic name and attribute path. Every package has an attribute path, which you can use in environment.systemPackages configuration option to install system-wide using declarative package management.

To find out your package's attribute path, add another flag -P to your query:

$ nix-env -qaP 'aspell.*en'
nixos.aspellDicts.en  aspell-dict-en-7.1-0

You should be comfortable using nix-env on a daily basis, so practice calling nix-env with --query and --install options. However you can also browse packages and find out their attribute paths online on Nix packages search. Type aspell, click on aspell-dict-en and you'll see various package's properties, including attribute path as part of the install command:

$ nix-env -iA nixos.pkgs.aspellDicts.en

Now you can put this attribute path into /etc/nixos/configuration.nix:

environment.systemPackages = with pkgs; [
  aspellDicts.en
];

Then update the system by running sudo nixos-rebuild switch.

Solution 2

In case you are using NixOS for Data Science:

Python modules:

nix-env -qaP .\*pylint.\*

or

py_pkgs="nix_packages_py35.txt"
nix-env -qaP | grep -i python36 > ${py_pkgs}
grep pandas ${py_pkgs}

OR if your are searching especially for R packages/libraries

nix-env -f "<nixpkgs>" -qaP -A rPackages .\*tidyverse.\*

alternatively you get e.g. npm packages with:

nix-env -qaPA 'nixos.nodePackages'

there is also a website for searching for pkgs

Solution 3

nix-env -v -qaP '*' | grep "nvim"

I would save the result of nix-env -v -qaP '*' to a file (as it usually takes a while to return).


Bear in mind, nix-env seems to ignore things under haskellPackages (and possibly others). You can search for packages in subcategories such as haskellPackages via nix-env -f '<nixpkgs>' -qaPA haskellPackages


nix-env search is currently quite frustrating as it'll take 5+ seconds and then come back with a error: regex error...

Share:
372

Related videos on Youtube

VAAA
Author by

VAAA

Updated on September 18, 2022

Comments

  • VAAA
    VAAA almost 2 years

    I'm trying to add to my grid the RowExpander plugin.

    Seems everything was going great with just one row, but when adding a second row the following rows are indented.

    I have created a Sencha Fiddle: https://fiddle.sencha.com/#fiddle/87d

    I'm doing it exactly as Sencha Examples, maybe because I have a datetime column first I get that issue.

    Any help is welcome.

  • VAAA
    VAAA almost 10 years
    Amazing... thanks a lot!! Actually there is an Ajax RowExpander that works for 4.1.1 and I just ported to 4.2.1 and works amazing. Where can I share that?
  • Karthik Bosan
    Karthik Bosan over 7 years
    Unfortunately, the -P option does not work with --installed, as can be seen with nix-env -q --installed -P | grep terminus which prints terminus-font instead of terminus_font. The workaround is to use nix-env -qaP | grep terminus-font, but it means that you can't easily dump the output of nix-env -q --installed into the configuration.nix.