2020-12-23 14:19:53 +02:00
|
|
|
R""(
|
|
|
|
|
|
|
|
# Examples
|
|
|
|
|
|
|
|
* Create a flake using the default template:
|
|
|
|
|
|
|
|
```console
|
|
|
|
# nix flake init
|
|
|
|
```
|
|
|
|
|
|
|
|
* List available templates:
|
|
|
|
|
|
|
|
```console
|
|
|
|
# nix flake show templates
|
|
|
|
```
|
|
|
|
|
|
|
|
* Create a flake from a specific template:
|
|
|
|
|
|
|
|
```console
|
|
|
|
# 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
|
2022-02-22 15:32:56 +02:00
|
|
|
template is `templates#templates.default`, but this can be overridden
|
2020-12-23 14:19:53 +02:00
|
|
|
using `-t`.
|
|
|
|
|
|
|
|
# Template definitions
|
|
|
|
|
2022-02-22 15:32:56 +02:00
|
|
|
A flake can declare templates through its `templates` output
|
2023-11-21 09:29:36 +02:00
|
|
|
attribute. A template has the following attributes:
|
2020-12-23 14:19:53 +02:00
|
|
|
|
|
|
|
* `description`: A one-line description of the template, in CommonMark
|
|
|
|
syntax.
|
|
|
|
|
|
|
|
* `path`: The path of the directory to be copied.
|
|
|
|
|
2022-02-17 20:59:32 +02:00
|
|
|
* `welcomeText`: A block of markdown text to display when a user initializes a
|
|
|
|
new flake based on this template.
|
2022-02-15 18:50:14 +02:00
|
|
|
|
|
|
|
|
2020-12-23 14:19:53 +02:00
|
|
|
Here is an example:
|
|
|
|
|
|
|
|
```
|
|
|
|
outputs = { self }: {
|
|
|
|
|
|
|
|
templates.rust = {
|
|
|
|
path = ./rust;
|
|
|
|
description = "A simple Rust/Cargo project";
|
2022-02-15 18:50:14 +02:00
|
|
|
welcomeText = ''
|
2022-02-17 20:59:32 +02:00
|
|
|
# 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)
|
|
|
|
- ...
|
2022-02-15 18:50:14 +02:00
|
|
|
'';
|
2020-12-23 14:19:53 +02:00
|
|
|
};
|
|
|
|
|
2022-02-22 15:32:56 +02:00
|
|
|
templates.default = self.templates.rust;
|
2020-12-23 14:19:53 +02:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
)""
|