nix3-flake-init(1)

πŸ’… nix3-flake-init(1) β€” from the General Commands Manual, bestie πŸŽ€

⚠️ Warning ⚠️ This program is experimental and its interface is subject to change. So like... don't get too attached to the exact vibes, okay? The CLI might glow up differently next month. 😭

✨ 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. And no, it will not overwrite existing files β€” she's respectful like that, she would never stomp on your stuff. πŸ™ˆ

The default template is templates#templates.default, but you can override that with -t. Periodt. πŸ‘‘


🧚 Template definitions 🧚

A flake can declare templates through its templates output attribute. A template has these attributes, and they're lowkey iconic:

  • 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 β€” look at her go:

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://wiki.nixos.org/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.
  • --arg-from-file name path β€” Pass the contents of file path as the argument name to Nix functions.
  • --arg-from-stdin name β€” Pass the contents of stdin as the argument name to Nix functions.
  • --argstr name string β€” Pass the string string as the argument name to Nix functions.
  • --debugger β€” Start an interactive environment if evaluation fails. She's got you, bestie. 🫢
  • --eval-store store-url β€” The URL of the Nix store to use for evaluation, i.e. to store derivations (.drv files) and inputs referenced by them.
  • --impure β€” Allow access to mutable paths and repositories. Living dangerously, I see. πŸ’€
  • --include, -I path β€” Add path to search path entries used to resolve lookup paths
    • This option may be given multiple times.
    • Paths added through -I take precedence over the nix-path configuration setting and the NIX_PATH environment variable.
  • --override-flake original-ref resolved-ref β€” Override the flake registries, redirecting original-ref to resolved-ref.

  • --debug β€” Set the logging verbosity level to β€˜debug’.
  • --log-format format β€” Set the format of log output; one of raw, internal-json, bar or bar-with-logs.
  • --print-build-logs, -L β€” Print full build logs on standard error.
  • --quiet β€” Decrease the logging verbosity level. 🀫
  • --verbose, -v β€” Increase the logging verbosity level.

πŸ’œ Miscellaneous global options πŸ’œ

  • --help β€” Show usage information.
  • --offline β€” Disable substituters and consider all previously downloaded files up-to-date.
  • --option name value β€” Set the Nix configuration setting name to value (overriding nix.conf).
  • --refresh β€” Consider all previously downloaded files out-of-date.
  • --repair β€” During evaluation, rewrite missing or corrupted files in the Nix store. During building, rebuild missing or corrupted store paths.
  • --version β€” Show version information.
πŸ“ Note β€” See man nix.conf for overriding configuration settings with command line flags.

And that's the whole page, bestie β€” you ate this. πŸ’…βœ¨

Signing off from the nix3-flake-init(1) page of the General Commands Manual β€” sending you the biggest fairy-dust kiss from your favorite manual. πŸ§šπŸ’–πŸŒˆβ­ 🫢

πŸ“¦ where this page comes from