Templates
nix flake init -t github:nixcafe/develop-templates#<name>| Name | Contents | Source |
|---|---|---|
nix | nixfmt, deadnix, statix, and pre-commit hooks | nixcafe-develop/nix |
node | Node.js, corepack, ni, Bun, and Deno | nixcafe-develop/node |
python | Python from requires-python, uv2nix, ruff hooks, and a package | nixcafe-develop/python |
rust | rust-overlay toolchain, crane package, cargo hooks | nixcafe-develop/rust |
java | GraalVM CE, Maven, and Gradle | nixcafe-develop/java |
kotlin | GraalVM CE, kotlinc, and Gradle | nixcafe-develop/kotlin |
latex | TeX Live, latexmk, texlab, chktex, and latexindent | nixcafe-develop/latex |
typst | typst, tinymist, and typstyle | nixcafe-develop/typst |
nix-config | NixOS, nix-darwin, and Home Manager hosts with installer images | nixcafe-develop/nix-config |
colmena-config | nix-config plus Colmena deployment | nixcafe-develop/colmena-config |
secrets | age secrets with ragenix and an update-secrets app | nixcafe-develop/nix-secrets |
purr | Minimal purr flake with mkFlake | nixcafe/purr |
purr-flake-parts | Minimal purr flake with flake-parts | nixcafe/purr |
Language templates
The language templates keep their Nix code out of the way. flake.nix calls purr's
mkFlake with src = ./develop, so the shell, the hooks, and any package live under
develop/ and the project root holds only your own files:
.envrc
flake.nix inputs, purr mkFlake, nixfmt-tree formatter
statix.toml
develop/
shells/default/default.nix dev shell
checks/git-hooks/default.nix pre-commit hooksThe dev shell reuses inputs.self.checks.${system}.git-hooks for its shellHook and
packages, so the hook configuration is written and evaluated once.
nix
A shell for Nix-only projects with nixfmt, deadnix, and statix, plus the matching
pre-commit hooks. Use it as the base for a repository of Nix expressions.
node
A shell with nodejs, corepack, ni (@antfu/ni),
bun, and deno.
ni,nr,nlx, and the othernicommands pick npm, pnpm, Yarn, or Bun from the lock file in the project.- The shell puts
node_modules/.binonPATHwhen it exists and setsCOREPACK_ENABLE_DOWNLOAD_PROMPT=0, so corepack-managed package managers install without a prompt. - Only the Nix hooks are enabled. Add JavaScript hooks in
develop/checks/git-hooks/default.nix.
python
A Python project managed with uv and built by Nix through uv2nix and pyproject.nix.
- The interpreter comes from the first
<major>.<minor>inrequires-python. The template's">=3.12"selectspython312. pyproject.tomlanduv.lockare the source of truth.nix buildproducespackages.defaultfrom them, andnix runruns theexamplescript.- The dev shell has a Nix-built virtualenv with every dependency group, your project
installed in editable mode from
$REPO_ROOT, anduv. Edits undersrc/take effect right away. uv addanduv lockupdatepyproject.tomlanduv.lockbut install nothing.UV_NO_SYNC=1andUV_PYTHON_DOWNLOADS=neverkeep uv from touching the Nix-managed environment. Reload the shell to pick up new dependencies.- Hooks:
ruff,ruff-format, and the Nix hooks.
pyproject.toml
uv.lock
src/example/
develop/lib/default.nix uv workspace and Python package set
develop/packages/default/default.nix application buildrust
A Rust crate built with crane and the latest stable toolchain from rust-overlay.
develop/overlays/rust-toolchain/default.nixdefinespkgs.rustToolchainwithrust-src. The package, the shell, and the hooks all use it, so changing the toolchain there changes it everywhere.nix buildrunscraneLib.buildDepsOnlyfirst and passes the result ascargoArtifacts, so editing your code does not rebuild the dependencies.- The shell gets the package's build inputs (
pkg-config,openssl) throughinputsFromand setsRUST_SRC_PATHfor rust-analyzer. - Hooks:
cargo-check,clippy,rustfmt, and the Nix hooks. The cargo hooks use crates vendored fromCargo.lock, because the check sandbox has no network.
java
A shell with GraalVM CE (graalvmPackages.graalvm-ce) as the JDK, Maven built against it,
and gradle_9 running on it. Change the jdk binding in
develop/shells/default/default.nix to switch JDKs for all three at once.
kotlin
The same GraalVM CE setup as java, with kotlinc instead of Maven. The Kotlin compiler
and gradle_9 both run on the GraalVM JDK.
latex
A shell with texliveMedium extended with latexmk, minted, upquote, latexindent,
and chktex, plus the texlab language server. minted needs upquote, which is
included, so code listings work without extra packages.
latexmk -pdf main.texPDF files and the intermediate TeX outputs are ignored in .gitignore.
typst
A shell with typst, the tinymist language server, and the typstyle formatter.
typstyle also runs as a pre-commit hook.
typst watch main.typConfiguration templates
nix-config
A purr flake for NixOS, nix-darwin, and Home Manager that imports
cattery-modules through extraModules, with
nixpkgsConfig.allowUnfree = true.
| Path | Contents |
|---|---|
systems/x86_64-linux/hostname-nixos | NixOS desktop with room.desktop.dev and KDE Plasma |
systems/x86_64-linux/hostname-server | NixOS server with a root user and IP forwarding |
systems/x86_64-linux/hostname-wsl | NixOS-WSL host |
systems/aarch64-darwin/hostname-mbp | nix-darwin host with room.desktop.dev |
systems/x86_64-linux/{graphical,minimal,minimal-no-zfs} | Image-only hosts with images = [ "iso-installer" ] in meta.nix |
homes/<arch>-<format>/<user>@<host> | Homes linked into the matching host and built as homeConfigurations |
lib/host/default.nix | User name, real name, email, time zone, login shell, and SSH keys |
lib/secrets/default.nix | enable and secretsPath for cattery.secrets |
Before you deploy, fill in lib/host/default.nix and generate a hardware.nix for each
NixOS host. The NixOS hosts ship placeholder file systems with lib.mkDefault so the
flake evaluates before you add real hardware.
nix build .#images.graphical.iso-installer
sudo nixos-rebuild switch --flake .#hostname-nixosSecrets are off by default. The my-secrets input points at the nix-secrets template
until you point it at your own repository and set enable = true.
colmena-config
nix-config plus Colmena. It adds a colmena
input, colmena in the dev shell, and a colmenaHive output built from
nixosConfigurations. Every NixOS host becomes a Colmena node, and SSH targets come from
colmena/colmenaHive/deployments.nix:
{
hostname-server.deployment = {
targetHost = "hostname-server";
targetPort = 22;
targetUser = "root";
};
}colmena apply --on hostname-serverImage-only hosts are not in nixosConfigurations, so they are not in the hive either.
secrets
A repository for age-encrypted secrets, edited with
ragenix and laid out the way
cattery.secrets reads them.
- Public keys and machines live in
develop/lib/keys/default.nix. The files to encrypt are listed indevelop/lib/settings/default.nix. The rootsecrets.nixreads both, so you never edit it by hand. - The template ships plain-text placeholder
.agefiles and placeholder keys. Replace the keys with your own, then delete the placeholders before you create real secrets. - A file's path decides its recipients.
hosts/<machine>/global/goes to that machine, its users, and the recovery keys.hosts/<machine>/users/<user>/andshared/users/<user>/go to that user.shared/global/goes to every machine withsharedSecretRecipient = true(the default), their users, and the recovery keys. sharedSecretRecipient = falsekeeps a machine out ofshared/globalsecrets while it still appears in the generated SSH config.nix run .#update-secretsbuilds the generated secrets, aknown_hostsfile and an SSH config for the machines inssh.fromMachines, and writes the encrypted files into the repository.
ragenix -e shared/global/wireguard/wg0.conf.age
nix run .#update-secretsThe dev shell has ragenix, age-plugin-yubikey, and a few editors. Keep the repository
private and use it from nix-config or colmena-config through the my-secrets input.
purr starters
purr
The template/default flake from purr: a mkFlake call with src = ./.,
namespace = "myproject", and nixfmt-tree as the formatter. Add directories such as
packages/, shells/, or systems/, and purr turns them into outputs. It has no dev
shell or hooks.
purr-flake-parts
The template/flake-parts flake from purr: flake-parts with purr.flakeModules.default
imported and purr.enable = true. It has no dev shell, hooks, or formatter.
See the purr docs for what each directory produces.