5. Search for Nix packages

Quick start / Search for Nix packages
Guide 5 of 8
In this guide

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.

The nix search command

The 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.

search.nixos.org

The web interface at search.nixos.org has a few advantages over the nix search command:

  • It enables you to select a release channel for Nixpkgs, such as 22.11 and unstable
  • It enables you to search across a range of public flakes beyond Nixpkgs (those flakes are listed here)

Exploring a flake with the nix flake show command

As an example, let's explore a popular flake for the Wayland window system protocol.

nix flake show github:nix-community/nixpkgs-wayland

System specificity

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.


Was this page helpful?