← 返回命令列表

Linux command

nix3-eval 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Evaluate Nix expression

nix eval --expr '1 + 2'

Evaluate flake attribute

nix eval [.#packages.x86_64-linux.default]

Evaluate nixpkgs attribute

nix eval nixpkgs#hello.version

Output as JSON

nix eval --json nixpkgs#hello.meta

Raw string output

nix eval --raw nixpkgs#hello.name

Read from file

nix eval -f [file.nix]

说明

nix eval is the new Nix 3.x command for evaluating Nix expressions. It replaces nix-instantiate --eval with a cleaner interface and flake support.

参数

--expr _expr_
Evaluate expression.
--json
Output as JSON.
--raw
Raw output (no quotes).
-f _file_
Evaluate file.
--apply _expr_
Apply function to result.
--impure
Allow impure evaluation.

FAQ

What is the nix3-eval command used for?

nix eval is the new Nix 3.x command for evaluating Nix expressions. It replaces nix-instantiate --eval with a cleaner interface and flake support.

How do I run a basic nix3-eval example?

Run `nix eval --expr '1 + 2'` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --expr _expr_ do in nix3-eval?

Evaluate expression.