Skip to main content
This repository previously hosted Nix flake templates, but they have been moved to a dedicated repository for better organization and maintenance.

Template repository

All templates are now available at: tgirlcloud/nix-templates

Using templates

There are two ways to use the templates:

Initialize in current directory

Initialize a template in the current directory:
nix flake init -t github:tgirlcloud/nix-templates#<template>
This will create template files in your current working directory. Make sure you’re in an empty directory or are okay with files being added.

Create in new directory

Create a new directory with the template:
nix flake new -t github:tgirlcloud/nix-templates#<template> <output-directory>
Example:
nix flake new -t github:tgirlcloud/nix-templates#rust my-rust-project
cd my-rust-project

Available templates

To see all available templates:
nix flake show github:tgirlcloud/nix-templates

Common templates

While the exact list may change, typical templates include:

Rust

Rust development environment with cargo and rust-analyzer

Python

Python environment with pip, virtualenv, and common tools

Node.js

Node.js/TypeScript setup with npm/pnpm and common tooling

Go

Go development environment with Go toolchain and LSP

Template structure

Templates typically include:
  • flake.nix - Flake configuration with development shell
  • flake.lock - Locked dependency versions
  • .envrc - direnv integration (optional)
  • Language-specific files (e.g., Cargo.toml, package.json)

Example template structure

rust-template/
├── flake.nix           # Nix flake with dev shell
├── flake.lock          # Dependency versions
├── .envrc              # direnv configuration
├── .gitignore          # Git ignore rules
├── Cargo.toml          # Rust manifest
└── src/
    └── main.rs         # Example source file

Using a template

Here’s a complete workflow for starting a new project:
1

Create project from template

nix flake new -t github:tgirlcloud/nix-templates#rust my-project
cd my-project
2

Enter development shell

nix develop
Or if you have direnv:
direnv allow
3

Start developing

The development shell provides all necessary tools:
# For Rust template
cargo build
cargo run

# For Python template  
python -m venv .venv
source .venv/bin/activate

# For Node.js template
npm install
npm run dev
4

Customize the flake

Edit flake.nix to add or remove dependencies:
flake.nix
{
  description = "My awesome project";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
  };

  outputs = { self, nixpkgs }:
    let
      system = "x86_64-linux";
      pkgs = nixpkgs.legacyPackages.${system};
    in
    {
      devShells.${system}.default = pkgs.mkShell {
        buildInputs = with pkgs; [
          # Add your tools here
          rustc
          cargo
          rust-analyzer
          clippy
        ];
      };
    };
}

Creating your own templates

You can create custom templates in your own repository:
1

Create template directory structure

mkdir -p templates/mytemplate
cd templates/mytemplate
2

Add template files

Create the files you want in the template:
flake.nix
{
  description = "My custom template";

  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";

  outputs = { nixpkgs, ... }: {
    # Template content
  };
}
3

Register in your flake

In your repository’s main flake.nix:
flake.nix
{
  outputs = { self }: {
    templates = {
      mytemplate = {
        path = ./templates/mytemplate;
        description = "My custom template for...";
      };
    };
  };
}
4

Use your template

nix flake new -t github:yourname/yourrepo#mytemplate new-project

Template best practices

Add direnv support for automatic shell activation:
.envrc
use flake
Users with direnv installed will automatically enter the dev shell.
Always include flake.lock to ensure reproducible builds:
nix flake lock
git add flake.lock
Include a README explaining:
  • What the template provides
  • How to use it
  • How to customize it
  • Common commands
Templates should be starting points, not complete applications. Include:
  • Essential dependencies
  • Basic configuration
  • Example files
Avoid:
  • Too many opinionated choices
  • Complex build setups
  • Large dependency trees

Integration with development shells

Templates work great with development shells defined in your system configuration:
home/yourname/dev/rust.nix
{
  pkgs,
  ...
}:
{
  # Global Rust tools available in all shells
  garden.packages = {
    inherit (pkgs)
      rustc
      cargo
      rust-analyzer
      rustfmt
      clippy
      ;
  };
}
Then project-specific flake.nix can add project dependencies:
devShells.default = pkgs.mkShell {
  buildInputs = with pkgs; [
    # Project-specific dependencies
    openssl
    postgresql
    redis
  ];
};

Next steps

nix-templates

Browse available templates

Adding packages

Learn about package management

Development environments

Read about nix develop

Flakes

Learn more about Nix flakes

Build docs developers (and LLMs) love