Jump to the navigation menu

Writing my own Nix Flake templates

nix flake init has a -t option that allows you to specify a template to use when creating the Flake file.

This is what flake.parts suggests:

nix flake init -t github:hercules-ci/flake-parts

It's also possible to create your own templates, which I've started to do for PHP and Sculpin projects.

For example, this will use the sculpin template to scaffold a new project:

nix flake init -t git+https://git.oliverdavies.uk/opdavies/nix-flake-templates#sculpin

Instead of a pre-built dev shell, this creates a new flake.nix and flake.lock file as well as any other files or directories within the template.

It's like a mini version of Build Configs.