Quick Start
Create a project
nix flake init copies a template into the current directory:
mkdir my-project && cd my-project
nix flake init -t github:nixcafe/develop-templates#nodeAdd --refresh if Nix may have cached an older version of the template flake. Each
template prints the commands it supports when it is copied.
The beans alias
nix registry add beans github:nixcafe/develop-templates
nix flake init -t beans#nodeOn a host that uses cattery-modules, cattery.nix
registers beans through nix.registry.beans.to, so you can skip the first command.
A new GitHub repository
Every template except purr and purr-flake-parts is also a GitHub template repository
under nixcafe-develop:
gh repo create my-project --template nixcafe-develop/node --cloneThe secrets template lives in nixcafe-develop/nix-secrets. Keep that one private:
gh repo create my-secrets --template nixcafe-develop/nix-secrets --private --cloneInitialize git first
After nix flake init, run this before nix develop:
git init && git add -AThe order matters for three reasons:
- Nix evaluates a flake in a git repository from the files git tracks. Untracked files,
such as a freshly copied
develop/directory, are invisible to it. nix developinstalls the pre-commit hooks into.git/hooks, which needs a repository.- Some shells read the repository root. The
pythonshell setsREPO_ROOTwithgit rev-parse --show-toplevelfor its editable install, and thesecretstemplate'snix run .#update-secretswrites the generated.agefiles into the repository.
Later, git add new files before you build or evaluate. git add -N <file> is enough to
make Nix see a file without staging its contents.
Enter the shell
nix developWith direnv, every template ships an .envrc with use flake.
Allow it once and the shell loads whenever you cd into the project:
direnv allowThe first Nix command writes flake.lock. Templates do not ship one, so you start from
current inputs. Commit it, together with uv.lock or Cargo.lock where the template
has one.
Everyday commands
| Command | What it does | Templates |
|---|---|---|
nix develop | Opens the dev shell and installs the hooks | All except purr and purr-flake-parts |
nix fmt | Formats the Nix files with nixfmt-tree | All except purr-flake-parts |
nix flake check | Runs the pre-commit hooks on every file | All except purr and purr-flake-parts |
nix build | Builds packages.default | python, rust |
nix flake show | Lists the outputs | All |
The hooks run nixfmt, deadnix, and statix everywhere. Some templates add their own:
ruff and ruff-format in python, cargo-check, clippy, and rustfmt in rust,
and typstyle in typst. On commit they check the staged files, and nix flake check
runs them over the whole repository.
What templates leave out
- No
flake.lock, as described above. - No
LICENSE. Add the license you want. - No
defaulttemplate.nix flake init -t github:nixcafe/develop-templateswithout a name fails, so always pass#<name>.
Next steps
- Templates describes each template.
- Contributing covers how templates are published and how to add one.