A template for creating a Batteries cell: an independent Lean 4 repository that can be safely imported together with Batteries. Cells are kept up to date with Batteries and compatible with each other by the Batteries maintainers. See the "Batteries Cell Network" section of the Batteries README for the current list of cells.
-
Click "Use this template" and turn on the "Include all branches" option, so that the new repository gets both the
mainandnightly-testingbranches. -
Create a fine-grained personal access token with access to the new repository and with read and write permissions for contents, pull requests and workflows. Save it as a repository secret named
BATTERIES_CELL_TOKEN. The workflows push and open pull requests with this token; pushes made with the defaultGITHUB_TOKENwould not trigger the CI and CD workflows. -
Rename the package and library on both branches:
- in
lakefile.toml, replace the package namebatteries-cell-testand the libraryBatteriesCellwith your own names, and updatedefaultTargetsto match; - rename
BatteriesCell.leanto the new library's root module.
Keep the
batteriesrequirement:rev = "main"onmainandrev = "nightly-testing"onnightly-testing. - in
-
Replace this README with one describing your cell, including how to require it:
[[require]] name = "your-cell" git = "https://github.com/your-org/your-cell" rev = "main"
Keep the GitHub workflows as they are: they are what keeps the cell in step with Batteries.
The main branch builds against Batteries main and its Lean toolchain. The nightly-testing
branch builds against Batteries nightly-testing and the latest Lean nightly toolchain.
- CI Pipeline (
ci-pipeline.yml) builds every pull request tomainornightly-testing. - CD Pipeline (
cd-pipeline.yml) builds every push tomainornightly-testing. After a successful build onmain, it mergesmainintonightly-testing, keeping thelean-toolchain,lakefile.tomlandlake-manifest.jsonofnightly-testing. - Update Nightly Toolchain (
update-nightly-testing-toolchain.yml) runs daily. When the toolchain of Batteriesnightly-testingchanges, it updates the toolchain and manifest ofnightly-testingand pushes the result. - Update Main Toolchain (
update-main-toolchain.yml) runs daily. When the toolchain of Batteriesmainchanges, it mergesnightly-testinginto a new branch, sets the toolchain to match Batteriesmain, keeps themainlakefile, and opens a pull request tomain. Changes needed to adapt to a new toolchain can therefore be made onnightly-testingahead of time. - Build (
build.yml) is the shared build job, run with--wfailso that warnings fail the build. Every default target is built, so include your test library indefaultTargetsif you want CI to run your tests.
All workflows can also be started by hand from the Actions tab.