← 返回命令列表

Linux command

nix-eval 命令

文本

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

常用示例

Evaluate expression

nix eval --expr "[1 + 1]"

Evaluate from flake

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

Evaluate and apply function

nix eval --apply [builtins.attrNames] --expr "{a=1; b=2;}"

Output as JSON

nix eval --json --expr "[{a = 1;}]"

Evaluate file

nix eval -f [file.nix]

Raw output

nix eval --raw --expr "\"hello\""

说明

nix eval evaluates Nix expressions. It outputs the evaluated value. The tool inspects Nix values. Useful for debugging and querying.

参数

--expr _EXPR_
Nix expression.
--json
Output as JSON.
--raw
Raw string output.
--apply _FUNC_
Apply function to result.
--help
Display help information.

FAQ

What is the nix-eval command used for?

nix eval evaluates Nix expressions. It outputs the evaluated value. The tool inspects Nix values. Useful for debugging and querying.

How do I run a basic nix-eval example?

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

What does --expr _EXPR_ do in nix-eval?

Nix expression.