46 lines
1.9 KiB
Markdown
46 lines
1.9 KiB
Markdown
# Toki's Nix Flake Template Repository
|
|
|
|
This is my personal collection of Nix flake templates for various programming
|
|
languages and build systems.
|
|
|
|
## Motivation
|
|
|
|
There already exists an [official repository of flake
|
|
templates](https://github.com/NixOS/templates), so why make my own?
|
|
|
|
I have a few different reasons:
|
|
|
|
- **Comprehensiveness:** The official template repository is rather small and
|
|
doesn't have most of the templates I would actually want to use.
|
|
- **Consistency:** The templates in the official repository are contributed by
|
|
community members, and there's very little stylistic or structural consistency
|
|
between them.
|
|
- **Preference:** The structure of a flake can be very opinionated, and most of
|
|
the official flake templates are rather poorly constructed by my standards,
|
|
often not bothering to follow established best practices.
|
|
|
|
## Usage
|
|
|
|
Flake templates are used with the `nix flake init` command:
|
|
|
|
```sh
|
|
nix flake init -t git+https://git.tokinanpa.dev/toki/templates#<template>
|
|
```
|
|
|
|
Replace `<template>` with the template you want to use. In the simplest case,
|
|
this is just the name of the programming language you want to use; the
|
|
repository will pick a recommended default template for that language.
|
|
|
|
If you want more control over the generated repository, you may select a
|
|
specific template instead. Templates names are organized by underscore-separated
|
|
*fields*; the number of fields may very depending on the language, but typically
|
|
there are three or four:
|
|
|
|
1. The programming language
|
|
2. The build system used to compile/package the repository
|
|
3. The Nix library/evaluation system used in the flake itself
|
|
4. (Optional) Additional differences in project structure
|
|
|
|
For example, the `python_pyproject_nixpkgs_cli` template generates a Python
|
|
repository packaged in Pyproject format where the flake uses Nixpkgs' standard
|
|
derivation builders (`buildPythonPackage`) and the repository exposes a CLI application.
|