LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

nix3-run

executes packages without installing

TLDR

Run package
$ nix run nixpkgs#[hello]
copy
Run from flake in the current directory
$ nix run
copy
Run a named app from a flake
$ nix run [.#app-name]
copy
Run with args
$ nix run nixpkgs#[cowsay] -- "[text]"
copy
Run a program from a GitHub flake
$ nix run github:[owner]/[repo]
copy
Run a package that needs unfree or other impure settings
$ NIXPKGS_ALLOW_UNFREE=1 nix run --impure nixpkgs#[package]
copy
Run with a clean environment
$ nix run --ignore-env nixpkgs#[package]
copy

SYNOPSIS

nix run [options] [installable] [-- args...]

DESCRIPTION

nix3-run is the manual page for nix run, which builds (or downloads) an installable and runs it without installing it into a profile.If the installable is an app (a flake output with type = "app"), its program is executed. If it is a derivation, nix run executes out/bin/name, where name is the first of meta.mainProgram, pname, or the name part of name.

PARAMETERS

INSTALLABLE

Flake reference and output. Defaults to apps.<system>.default, then packages.<system>.default of the flake in the current directory.
ARGS
Arguments passed to the program. Put them after -- so nix does not parse them.
-i, --ignore-env
Clear the environment, except variables given with --keep-env-var.
-k, --keep-env-var NAME
Keep the variable when using --ignore-env.
-s, --set-env-var NAME VALUE
Set an environment variable.
-u, --unset-env-var NAME
Unset an environment variable.
--impure
Allow impure evaluation, e.g. to read NIXPKGSALLOWUNFREE.
--help
Display help information.

INSTALL

sudo apt install nix-bin
copy
sudo dnf install nix
copy
sudo pacman -S nix
copy
sudo apk add nix
copy
sudo zypper install nix
copy
nix profile install nixpkgs#nix
copy

CAVEATS

There is no nix3 executable: the new-CLI man pages are named nix3-subcommand. Use man nix3-run or nix run --help.Requires the nix-command experimental feature (and flakes for flake references). The first positional argument is always the installable, even after --, so write nix run . -- arg to pass arguments to the default app. The package stays in the store until the next garbage collection; network access is needed unless it is already cached.

HISTORY

In Nix 2.0-2.3, nix run started a shell with packages available; Nix 2.4 (2021) renamed that behavior to nix shell and made nix run execute a single app.

SEE ALSO

nix(1), nix-run(1), nix3-shell(1), nix-shell(1)

RESOURCES

Copied to clipboard
Kai