table of contents
- bookworm 2.8.0-1.1+b1
- testing 2.24.12+dfsg-1
- unstable 2.24.12+dfsg-1+b1
- experimental 2.25.4+dfsg-1
nix3-flake-init(1) | General Commands Manual | nix3-flake-init(1) |
Warning: This program is experimental and its interface is subject to change.
Name¶
nix flake init - create a flake in the current directory from a template
Synopsis¶
nix flake init [option…]
Examples¶
- •
- Create a flake using the default template:
# nix flake init
- •
- List available templates:
# nix flake show templates
- •
- Create a flake from a specific template:
# nix flake init -t templates#simpleContainer
Description¶
This command creates a flake in the current directory by copying the files of a template. It will not overwrite existing files. The default template is templates#templates.default, but this can be overridden using -t.
Template definitions¶
A flake can declare templates through its templates output attribute. A template has two attributes:
- description: A one-line description of the template, in CommonMark syntax.
- path: The path of the directory to be copied.
- welcomeText: A block of markdown text to display when a user initializes a new flake based on this template.
Here is an example:
outputs = { self }: {
templates.rust = {
path = ./rust;
description = "A simple Rust/Cargo project";
welcomeText = ''
# Simple Rust/Cargo Template
## Intended usage
The intended usage of this flake is...
## More info
- [Rust language](https://www.rust-lang.org/)
- [Rust on the NixOS Wiki](https://nixos.wiki/wiki/Rust)
- ...
'';
};
templates.default = self.templates.rust; }
Options¶
- •
- --template / -t template
The template to use.
Common evaluation options:
- --arg name expr
Pass the value expr as the argument name to Nix functions. - --argstr name string
Pass the string string as the argument name to Nix functions. - --eval-store store-url
The Nix store to use for evaluations. - --impure
Allow access to mutable paths and repositories. - --include / -I path
Add path to the list of locations used to look up <...> file names. - --override-flake original-ref resolved-ref
Override the flake registries, redirecting original-ref to resolved-ref.