nix3-repl(1)
β¨ nix repl β the nix3-repl(1) page, bestie edition β¨
General Commands Manual who? She's serving "interactive Nix evaluation" and honestly she ate π
Warning β this program is experimental and its interface is subject to change. Not me being dramatic, that's literally what it says. Things may move around. Prepare your heart π«
πΈ NAME πΈ
nix repl β start an interactive environment for evaluating Nix expressions
Bestie. You type Nix in, Nix talks back. It's giving conversation. It's giving relationship π
π SYNOPSIS π
nix repl [optionβ¦] installablesβ¦
π¦ EXAMPLES π¦
Okay so first up, if you wanna see every special command the REPL has hiding in it:
# nix repl
nix-repl> :?
(Yes :? is the cheat code. Iconic.)
Next, some simple Nix math so you can see the vibe:
# nix repl
nix-repl> 1 + 2
3
nix-repl> map (x: x * 2) [1 2 3]
[ 2 4 6 ]
map (x: x * 2) [1 2 3] returning [ 2 4 6 ]?? She's so real for that π§
And now, the main event β hanging out with Nixpkgs in the REPL:
# nix repl --file example.nix
Loading Installable ''...
Added 3 variables.
# nix repl --expr '{a={b=3;c=4;};}'
Loading Installable ''...
Added 1 variables.
# nix repl --expr '{a={b=3;c=4;};}' a
Loading Installable ''...
Added 1 variables.
# nix repl --extra-experimental-features 'flakes' nixpkgs
Loading Installable 'flake:nixpkgs#'...
Added 5 variables.
nix-repl> legacyPackages.x86_64-linux.emacs.name
"emacs-27.1"
nix-repl> :q
# nix repl --expr 'import <nixpkgs>{}'
Loading Installable ''...
Added 12439 variables.
nix-repl> emacs.name
"emacs-27.1"
nix-repl> emacs.drvPath
"/nix/store/lp0sjrhgg03y2n0l10n70rg0k7hhyz0l-emacs-27.1.drv"
nix-repl> drv = runCommand "hello" { buildInputs = [ hello ]; } "hello; hello > $out"
nix-repl> :b drv
this derivation produced the following outputs:
out -> /nix/store/0njwbgwmkwls0w5dv9mpc1pq5fj39q0l-hello
nix-repl> builtins.readFile drv
"Hello, world!\n"
nix-repl> :log drv
Hello, world!
12439 variables?? She said "I contain multitudes" and meant it ππ
π DESCRIPTION π
This command gives you an interactive environment for evaluating Nix expressions. And yes, REPL stands for "readβevalβprint loop" β read it, evaluate it, print it, loop it, repeat forever, that's the whole personality π
On startup, it loads the Nix expressions named files and adds them into the lexical scope. You can load more files using the :l <filename> command, or reload all files using :r. Very much giving "come back here I'm not done with you" energy π«Ά
π OPTIONS π
--stdinβ read installables from the standard input. No default installable applied. (Piping things in like a little gift π)
π₯ Common evaluation options π₯
--arg name exprβ pass the value expr as the argument name to Nix functions.--arg-from-file name pathβ pass the contents of file path as the argument name to Nix functions.--arg-from-stdin nameβ pass the contents of stdin as the argument name to Nix functions.--argstr name stringβ pass the string string as the argument name to Nix functions.--debuggerβ start an interactive environment if evaluation fails. So when it goes wrong you get to poke at it instead of just screaming π--eval-store store-urlβ the URL of the Nix store to use for evaluation, i.e. to store derivations (.drvfiles) and inputs referenced by them.--impureβ allow access to mutable paths and repositories. (Living dangerously, I respect it π)--include/-I pathβ add path to search path entries used to resolve lookup paths.
This option may be given multiple times.
Paths added through -I take precedence over the nix-path configuration setting and the NIX_PATH environment variable. She doesn't queue, she goes first π
--override-flake original-ref resolved-refβ override the flake registries, redirecting original-ref to resolved-ref.
π Common flake-related options π
--commit-lock-fileβ commit changes to the flake's lock file.--inputs-from flake-urlβ use the inputs of the specified flake as registry entries.--no-registriesβ don't allow lookups in the flake registries.
DEPRECATED β use --no-use-registries instead.
--no-update-lock-fileβ do not allow any updates to the flake's lock file.--no-write-lock-fileβ do not write the flake's newly generated lock file.--output-lock-file flake-lock-pathβ write the given lock file instead offlake.lockwithin the top-level flake.--override-input input-path flake-urlβ override a specific flake input (e.g.dwarffs/nixpkgs). The input path must not be empty. This implies--no-write-lock-file.--recreate-lock-fileβ recreate the flake's lock file from scratch.
DEPRECATED β use nix flake update instead.
--reference-lock-file flake-lock-pathβ read the given lock file instead offlake.lockwithin the top-level flake.--update-input input-pathβ update a specific flake input (ignoring its previous entry in the lock file).
DEPRECATED β use nix flake update instead.
π Logging-related options π
--debugβ set the logging verbosity level to 'debug'.--log-format formatβ set the format of log output; one ofraw,internal-json,barorbar-with-logs.--print-build-logs/-Lβ print full build logs on standard error.--quietβ decrease the logging verbosity level. Shhh π€«--verbose/-vβ increase the logging verbosity level. Tell me EVERYTHING π£οΈ
β Miscellaneous global options β
--helpβ show usage information.--offlineβ disable substituters and consider all previously downloaded files up-to-date.--option name valueβ set the Nix configuration setting name to value (overridingnix.conf).--refreshβ consider all previously downloaded files out-of-date.--repairβ during evaluation, rewrite missing or corrupted files in the Nix store. During building, rebuild missing or corrupted store paths. Fixer-upper energy π§β¨--versionβ show version information.
π§ Options that change the interpretation of installables π§
--expr exprβ interpret installables as attribute paths relative to the Nix expression expr.--file/-f fileβ interpret installables as attribute paths relative to the Nix expression stored in file. If file is the character-, then a Nix expression is read from standard input. Implies--impure.
Note β see man nix.conf for overriding configuration settings with command line flags. Go read her too, she's part of the lore π
And that's the whole page, bestie β nix3-repl(1) from the General Commands Manual, signed, sealed, delivered. No cap, go open that REPL and evaluate something. :q when you're done. π«Άβ¨
π¦ where this page comes from
- fedora 44: nix-core 2.35.3-2.fc44 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms