→Use the nix search
command to find packages in Nixpkgs
→Explore the search.nixos.org web interface
→Use the nix flake show
command to explore packages output by flakes
One great thing about Nix is that there are tons of packages available in the Nix ecosystem that you can use in Nix development environments, in your NixOS installations, and more. While Nixpkgs is by far the largest Nix package collection—over 80,000 packages and counting 😎—any Nix flake can provide package outputs.
But navigating all of this plenty can be tricky, so in this guide we'll learn how to search for packages in Nixpkgs using the nix search
command and using the web application at search.nixos.org.
Then we'll learn how to explore packages in other flakes.
nix search
commandThe Nix CLI has a search
command that you can use to search the packages in a flake based on a search term.
Let's start by searching Nixpkgs, which is where we're mostly likely to find packages we want.
This command will tell us if cargo is available in Nixpkgs:
nix search nixpkgs cargo
In this command, the nixpkgs
flake reference is shorthand for github:NixOS/nixpkgs
.
This brings up many results of the form legacyPackages.{system}.{package}
, the first of which should look like this on an Apple Silicon (aarch64-darwin
) system:
* legacyPackages.aarch64-darwin.cargo (1.65.0)
Downloads your Rust project's dependencies and builds your project
The system attribute varies on other platforms (you may see x86_64-linux
or something else).
After that first result, you should see many others, including packages like cargo-about
and cargo-audit
.
You can also output search results as JSON using the --json
flag:
nix search nixpkgs cargo --json
This can be useful if you want to parse the output using a tool like jq.
The web interface at search.nixos.org has a few advantages over the nix search
command:
nix flake show
commandAs an example, let's explore a popular flake for the Wayland window system protocol.
nix flake show github:nix-community/nixpkgs-wayland
One thing you'll notice about the search output for nix search
, search.nixos.org, and nix flake show
is that all the packages listed in the query results are for your current system (x86_64-linux
for an AMD/Intel Linux system, aarch64-darwin
for an Apple Silicon system, and so on).
That's because Nix works in a fundamentally system-specific way.
The cargo
package on a Linux machine is considered a different package from cargo
on a non-Linux system.