Forrest logo
back to the nix tool

nix3-run:tldr:06db1

nix3-run: Run a command whose name matches the package name from nixpkgs (if you want a different command from that package, see `tldr nix3 shell`).
$ nix run nixpkgs#${pkg}
try on your machine

The command nix run nixpkgs#${pkg} is used in the Nix package manager to run a package from the Nixpkgs collection.

Here's a breakdown of each part:

  • nix: This is the command-line interface for the Nix package manager.
  • run: This subcommand is used to run a package or a package derivation.
  • nixpkgs: This refers to the Nixpkgs collection, which is a large collection of pre-built packages maintained by the Nix community.
  • #${pkg}: This syntax is used to refer to a specific package within the Nixpkgs collection, where pkg is the name of the desired package.

When you execute the command nix run nixpkgs#${pkg}, Nix will search for the specified package within the Nixpkgs collection and then run it, ensuring that any required dependencies are correctly resolved and provided.

Overall, this command is a convenient way to run packages from the Nixpkgs collection without having to explicitly define them in a Nix expression or build them from source.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the nix tool