Templates
Updated 11 November 2026
Templates are a Calculate Utilities mechanism that sets up configuration files without manual editing. You describe "what should be" in the file, and the utilities add it to the existing configuration: they keep your other settings, the order of lines, the quotes and comments, link the file to its package, and rewrite it from scratch at every package update.
This solves two problems at once. The system stays up to date with continuous updating: packages change versions and configuration formats, and the templates bring the settings along with them. And the changes stay readable: the template holds only what you wanted to change, not scattered edits across dozens of files in /etc/.
Templates are used everywhere: when building an image, installing the system, running it for the first time, updating the Portage tree, configuring a package, and logging in to a user session.
Getting started
- Quick start: your first template in five minutes - three complete examples with a check of the result.
- Template syntax - the template header, variables, conditions, functions, and the
!,+,-prefixes. - Configuration file formats - which format to choose and how they differ.
References
- The complete Calculate templates manual - a reference in the style of a man page: the whole syntax in one file, the control elements, the appending rules, all formats and all template functions with examples.
- The complete formats reference - all 29 format= names with their behavior and examples from the calculate tree.
- Header parameters - separate lists for a file and for a directory: they differ.
- Template variables - how to view the variables, where they are stored, and how calculate.env differs from ini.env.
Advanced topics
- Template directories and storage layers - .calculate_directory, repository priority, /var/calculate/templates and *.clt files, event directories of the N_ac_* form, and an example of a tool that creates templates on its own (cl-kernel).
- Кто и когда налагает шаблоны — карта событий и матрица ac_*-переменных, а также избирательное отключение шаблонов для отдельных пакетов (cl_setup_skip_merge, cl_setup_skip_patch, cl_setup_skip_profile, cl_setup_skip_sync).
- The template was not applied and said nothing: diagnostics - six common causes.
- Life of a file after the template - file ownership, protected,
dispatch-conf, and correct removal. - Custom functions in an overlay - scripts/functions and the return protocol.
- A template next to the file: .clt - when you do not need to move the template into /var/calculate/templates.