LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

nix3-repl

starts interactive Nix shell

TLDR

Start REPL
$ nix repl
copy
Load nixpkgs from the search path
$ nix repl -f '<nixpkgs>'
copy
Load a flake (its outputs become variables)
$ nix repl [.#]
copy
Load the nixpkgs flake
$ nix repl nixpkgs
copy
Load an expression
$ nix repl --expr 'import <nixpkgs> {}'
copy
Inside the REPL: list special commands
$ :?
copy
Inside the REPL: load a flake into scope
$ :lf [.]
copy
Inside the REPL: build a derivation
$ :b [hello]
copy

SYNOPSIS

nix repl [options] [installables...]

DESCRIPTION

nix3-repl is the manual page for nix repl, an interactive read-eval-print loop for Nix expressions. Given files or flakes, it adds their attributes to the lexical scope, which makes it convenient for exploring nixpkgs, NixOS configurations and flake outputs. Tab completion and history are available.

PARAMETERS

INSTALLABLES

Flakes, or attribute paths with --file/--expr, whose attributes are added to the scope.
-f, --file FILE
Load attributes from the Nix expression in FILE.
--expr EXPR
Load attributes from the expression EXPR.
--stdin
Read installables from standard input.
--impure
Allow impure evaluation.
--help
Display help information.

REPL COMMANDS

:?

Show all special commands.
:l file, :lf flake
Load a Nix file or a flake into scope.
:r
Reload all loaded files.
:b expr
Build a derivation.
:p expr
Evaluate and print the result recursively.
:e expr
Open a package or function in the editor.
:t expr
Describe the type of the result.
:doc expr
Show documentation of a builtin function.
:log expr
Show the build log of a derivation.
:q
Quit.

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-repl or nix repl --help.Requires the nix-command experimental feature (and flakes to load flakes). Older Nix versions loaded a positional path like '<nixpkgs>' as a file; current versions treat positional arguments as installables, so use -f.

HISTORY

nix repl replaced the separate nix-repl tool when it was merged into Nix 2.0 (2018). The repl-flake feature that made positional arguments flakes was folded into flakes in Nix 2.19.

SEE ALSO

nix(1), nix-repl(1), nix3-eval(1)

RESOURCES

Copied to clipboard
Kai