← 返回命令列表

Linux command

nix-build 命令

文本

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

常用示例

Build default.nix

nix-build

Build specific file

nix-build [path/to/file.nix]

Build with attribute

nix-build -A [attribute]

Build from expression

nix-build -E "[with import <nixpkgs> {}; hello]"

Don't create result symlink

nix-build --no-out-link

Build and keep output

nix-build -o [result-link]

Show build log

nix-build -v

说明

nix-build builds Nix expressions. It creates derivations and builds them. The tool produces output in /nix/store. Creates result symlink by default.

参数

-A _ATTR_
Build specific attribute.
-E _EXPR_
Build expression.
--no-out-link
Don't create result link.
-o _LINK_
Output symlink name.
-v
Verbose mode.
--help
Display help information.

FAQ

What is the nix-build command used for?

nix-build builds Nix expressions. It creates derivations and builds them. The tool produces output in /nix/store. Creates result symlink by default.

How do I run a basic nix-build example?

Run `nix-build` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -A _ATTR_ do in nix-build?

Build specific attribute.