Warning: This program is experimental and its interface is subject to change.


nix repl - start an interactive environment for evaluating Nix expressions


nix repl [option...] files...


  • Display all special commands within the REPL:

    # nix repl
    nix-repl> :?
  • Evaluate some simple Nix expressions:

    # nix repl
    nix-repl> 1 + 2
    nix-repl> map (x: x * 2) [1 2 3]
    [ 2 4 6 ]
  • Interact with Nixpkgs in the REPL:

    # nix repl '<nixpkgs>'
    Loading '<nixpkgs>'...
    Added 12428 variables.
    nix-repl> emacs.name
    nix-repl> emacs.drvPath
    nix-repl> drv = runCommand "hello" { buildInputs = [ hello ]; } "hello > $out"
    nix-repl> :b x
    this derivation produced the following outputs:
      out -> /nix/store/0njwbgwmkwls0w5dv9mpc1pq5fj39q0l-hello
    nix-repl> builtins.readFile drv
    "Hello, world!\n"


This command provides an interactive environment for evaluating Nix expressions. (REPL stands for 'read–eval–print loop'.)

On startup, it loads the Nix expressions named files and adds them into the lexical scope. You can load addition files using the :l <filename> command, or reload all files using :r.


Common evaluation options:

  • --arg name expr
    Pass the value expr as the argument name to Nix functions.

  • --argstr name string
    Pass the string string as the argument name to Nix functions.

  • --eval-store store-url
    The Nix store to use for evaluations.

  • --impure
    Allow access to mutable paths and repositories.

  • --include / -I path
    Add path to the list of locations used to look up <...> file names.

  • --override-flake original-ref resolved-ref
    Override the flake registries, redirecting original-ref to resolved-ref.