LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

nix-flake-init

Create a flake in the current directory from a template

TLDR

Initialize a flake using the default template
$ nix flake init
copy
Initialize from a built-in template
$ nix flake init -t [templates#simpleContainer]
copy
Initialize from a GitHub repository template
$ nix flake init -t [github:owner/repo#template]
copy

SYNOPSIS

nix flake init [-t template] [flags]

DESCRIPTION

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.

PARAMETERS

-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.

CAVEATS

Will not overwrite existing files. Nix flakes must be enabled in the Nix configuration (`experimental-features = nix-command flakes`).

HISTORY

Nix flakes were introduced as an experimental feature in Nix 2.4 (2021) to provide reproducible, composable builds. The `nix flake init` subcommand is part of the new-style `nix` CLI (`nix3`).

SEE ALSO

Copied to clipboard
Kai