LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

nix-repl

Start an interactive Nix expression evaluator

TLDR

Start the Nix REPL
$ nix repl
copy
Load the nixpkgs package set into scope
$ nix repl --expr 'import <nixpkgs> {}'
copy
Open a REPL with a flake's outputs in scope
$ nix repl [.#]
copy
Load a Nix file's attributes into scope
$ nix repl --file [default.nix]
copy

SYNOPSIS

nix repl [options] [files]

DESCRIPTION

nix repl starts an interactive read-eval-print loop for the Nix expression language. It is useful for exploring package attributes, debugging expressions, and prototyping configuration.Expressions are evaluated lazily. The REPL offers tab completion for attribute names and accepts colon-prefixed meta commands (see REPL COMMANDS) in addition to ordinary Nix expressions.

PARAMETERS

FILES

Nix files whose top-level attributes are brought into scope.
--expr EXPR
Evaluate the given expression and bring its attributes into scope.
--file PATH
Load attributes from the given Nix file (deprecated positional form still works).
--arg NAME EXPR
Pass the named argument as a Nix expression to the loaded file or flake.
--argstr NAME STRING
Pass the named argument as a string.
--help
Display help information.

REPL COMMANDS

:?

Show the list of available REPL commands.
:l PATH
Load a Nix file and add its attributes to the scope.
:r
Reload all loaded files.
:b EXPR
Build a derivation and print its output paths.
:e EXPR
Open the location of the given value in `$EDITOR`.
:t EXPR
Show the type of the given expression.
:q
Exit the REPL (Ctrl-D also works).

CAVEATS

Part of the experimental `nix` command (enable with `experimental-features = nix-command flakes`). The older standalone `nix-repl` binary is deprecated in favor of `nix repl`. Use `:?` inside the REPL for the full command list.

HISTORY

`nix repl` provides interactive evaluation for exploring and debugging Nix expressions. It superseded the separate `nix-repl` tool when the unified `nix` command was introduced.

SEE ALSO

Copied to clipboard
Kai