← 返回命令列表

Linux command

nix-flake-init 命令

文本

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

常用示例

Initialize a flake

nix flake init

Initialize from a built-in template

nix flake init -t [templates#simpleContainer]

Initialize from a GitHub repository template

nix flake init -t [github:owner/repo#template]

说明

nix flake init creates a new `flake.nix` in the current directory by copying the files from a template flake. It will not overwrite existing files. The default template source is the `nixpkgs` flakes template registry. Templates are identified by a flake reference plus an optional attribute path (e.g. `templates#python`). After initialization, any `welcomeText` defined in the template is printed to the terminal.

参数

-t, --template _FLAKE_
The template to use. Defaults to `templates#templates.default`. The template is a flake reference optionally followed by `#<attr>` to select a specific template attribute.

FAQ

What is the nix-flake-init command used for?

nix flake init creates a new `flake.nix` in the current directory by copying the files from a template flake. It will not overwrite existing files. The default template source is the `nixpkgs` flakes template registry. Templates are identified by a flake reference plus an optional attribute path (e.g. `templates#python`). After initialization, any `welcomeText` defined in the template is printed to the terminal.

How do I run a basic nix-flake-init example?

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

What does -t, --template _FLAKE_ do in nix-flake-init?

The template to use. Defaults to `templates#templates.default`. The template is a flake reference optionally followed by `#<attr>` to select a specific template attribute.