Lake packages are configured through a lakefile at the package root. The file can be written in TOML (Documentation Index
Fetch the complete documentation index at: https://mintlify.com/leanprover/lean4/llms.txt
Use this file to discover all available pages before exploring further.
lakefile.toml) or Lean DSL (lakefile.lean). Both formats support the same fields; this page documents each field with side-by-side examples.
- TOML
- Lean DSL
Metadata
These fields describe the package to the Reservoir package registry and to humans reading the configuration file. None of them affect the build.The name of the package. In TOML this is a top-level string field. In a Lean lakefile it is set by the
package "<name>" declaration.The package version. Must follow the form Lake’s versioning guidelines:
<major>.<minor>.<patch> with an optional -<suffix> for pre-releases.- Major increment — significant breaking changes; manual migration expected.
- Minor increment — notable but generally backwards-compatible changes.
- Patch increment — bug fixes and small touchups only.
A short human-readable description of the package. Used by Reservoir to index and display the package.
An array of keywords that help Reservoir users discover the package. Good keywords include the domain (e.g.
math, devtool), subtopics (e.g. topology), and notable implementation details (e.g. ffi, cli, dsl).A URL to more information about the package. Reservoir already links to the GitHub repository, so this field is best used for documentation sites or other resources.
An SPDX license identifier for the package’s license. Reservoir requires an OSI-approved license to index a package.
An array of files that contain licence information. For Apache 2.0, this should include both
LICENSE and NOTICE if a NOTICE file exists.The relative path to the package’s README file. Reservoir renders this file as HTML on the package’s page.
Whether Reservoir should include this package in its index. Set to
false to opt out.Git tag patterns that Reservoir treats as version releases. Defaults to tags that start with
v followed by a digit.Layout
These fields control the top-level directory structure of the package and its build outputs.The directory where Lake downloads remote dependencies.
The directory containing the package’s Lean source files. Passed to
lean as the -R option. All library and executable srcDir fields are relative to this.The top-level directory for all build outputs.
Build subdirectory for binary Lean libraries (
.olean, .ilean files).Build subdirectory for native libraries (
.a, .so, .dll files).Build subdirectory for binary executables.
Build subdirectory for intermediate results (
.c, .o files).Build & Run
These fields configure how code is compiled and run.The names of package targets to build on a bare
lake build. In the Lean DSL, use the @[default_target] attribute instead.When
true, each module is compiled into a native shared library that is loaded whenever the module is imported. This speeds up metaprogram evaluation and enables the interpreter to call @[extern] functions.An array of target names to build whenever the package is used (as a dependency or directly).
Additional
set_option-style options to pass to the Lean language server (lean --server) launched by lake serve, for this package only.Additional arguments passed to
lean --server that apply to this package and to any packages browsed from the same editor session (e.g. via go-to-definition into dependencies).The build optimisation mode. One of
debug, relWithDebInfo, minSizeRel, or release.| Value | C flags | Description |
|---|---|---|
debug | -O0 -g | Debug info, assertions enabled |
relWithDebInfo | -O3 -g -DNDEBUG | Optimised with debug info |
minSizeRel | -Os -DNDEBUG | Size-optimised release |
release | -O3 -DNDEBUG | Full optimisation (default) |
Additional arguments passed to
lean when compiling Lean source files. These do affect the build trace; changing them triggers a rebuild.Like
moreLeanArgs, but do not affect the trace. Changing them will not trigger a rebuild. They are prepended before moreLeanArgs.Additional arguments passed to
leanc when compiling the C files generated by lean. These affect the trace.Like
moreLeancArgs but do not affect the trace. Prepended before moreLeancArgs.Additional arguments passed to
leanc during linking (for executables and shared libraries). These affect the trace.Like
moreLinkArgs but do not affect the trace.Whether Lake should assume modules in this package are platform-independent:
true— exclude platform-dependent elements from traces; prevents re-elaboration on different platforms.false— forceSystem.Platform.targetinto traces; always re-elaborate on other platforms.- unset (default) — include platform info only when platform-dependent artefacts are actually used.
Test & Lint
The name of the script, executable, or library used by
lake test. To reference a definition in a dependency, use <pkg>/<name> syntax. In the Lean DSL, tag a definition with @[test_driver] instead.Arguments prepended before any CLI arguments when the test driver is invoked by
lake test.The name of the script or executable used by
lake lint. Libraries cannot be lint drivers. Tag with @[lint_driver] in Lean DSL.Arguments prepended before any CLI arguments when the lint driver is invoked by
lake lint.Cloud Releases
The URL of the GitHub repository hosting releases of this package. Defaults to the URL the package was downloaded from (for dependencies) or
gh’s default (for uploads).Custom file name for the build archive. Defaults to
{name}-{System.Platform.target}.tar.gz.When
true and this package is used as a dependency, Lake will attempt to download a prebuilt release archive from GitHub rather than building from source.Full Example
- TOML
- Lean DSL