nix run command to run a program from Nixpkgs
→Learn about Nix flakes and packages
→Download and run a program from Nixpkgs
echo "Hello Nix" | nix run "nixpkgs#ponysay"
🚀 Success! You should see a charming equine greeting in your console.
What happened here? The Nix CLI did a few things:
nixpkgs flake reference to pull in some Nix code and targeted the
ponysay flake output (more on this later).
ponysay package and stored the result in the Nix store.
bin/ponysay from the
In Nix, every program is part of a package.
Packages are built using the Nix language.
ponysay package has a single program (also called
ponysay) but packages can contain multiple programs as well as man pages, configuration files, and more.
ffmpeg package, for example, provides both ffmpeg and ffprobe.
You may have noticed that
nix run doesn't require anything like a
nix install command.
This makes it handy for use cases like shell scripting or experimenting with in-progress tools.
For more on
nix run, see Using Nix to run software with no installation steps on the Determinate Systems blog.
Congrats! You've just run a program using the Nix CLI and learned a little bit about some core Nix concepts. You're now ready to explore Nix development environments.