Skip to content

Build and code generation ​

Functions of the tools module at v0.5.0. Each returns what a command runs in; import it with import * as tools from "tools".

buf.env ​

buf, the Protocol Buffers toolchain.

lask
buf.env(
  --image: Environment = #bufbuild/buf:1.73.0,
  --token: String | Null = <secret>,
  --cache_dir: String | Null = null,
  --with: Array<Record<env: Map<String>, volumes: Array<String>>> = [],
  --extra_env: Map<String> = {}
): Runnable

The image is #bufbuild/buf:1.73.0 unless --image names another. lask sync pulls and pins whichever image is used (lask spec 10.3); a run never pulls.

Parameters

  • --image The image to run; another release is passed as image = #bufbuild/buf:<tag>.
  • --token!! BUF_TOKEN, for the Buf Schema Registry; masked in the command log.
  • --cache_dir Host directory mounted at /cache; buf's cache is /cache/buf (BUF_CACHE_DIR).
  • --with Setups of other tools this environment should also carry.
  • --extra_env Any other variable; below --with and the named parameters.

Returns Runnable: The environment, for command { "buf" } on ... or $[...].

Image bufbuild/buf:1.73.0

Command words buf: import command { "buf" } from "tools"

bash
lask eval buf.env --cache_dir /tmp/cache

lib/buf.lask

protoc.env ​

protoc, the Protocol Buffers compiler, with the well-known types and the gRPC plugins.

lask
protoc.env(
  --with: Array<Record<env: Map<String>, volumes: Array<String>>> = [],
  --extra_env: Map<String> = {}
): Runnable

The image is built from lib/images/protoc/Dockerfile (Alpine 3.24), so it takes no --image, and lask sync builds it. A language's own plugin — protoc-gen-go, ts-proto — lives with that language's toolchain; buf, which fetches plugins itself, is often the simpler way.

Parameters

  • --with Setups of other tools this environment should also carry.
  • --extra_env Any other variable; below --with.

Returns Runnable: The environment, for command { "protoc" } on ... or $[...].

Image recipe lib/images/protoc/Dockerfile

Command words protoc: import command { "protoc" } from "tools"

bash
lask eval protoc.env

lib/protoc.lask

bazel.env ​

Bazel, through Bazelisk.

lask
bazel.env(
  --cache_dir: String | Null = null,
  --with: Array<Record<env: Map<String>, volumes: Array<String>>> = [],
  --extra_env: Map<String> = {}
): Runnable

The image is built from lib/images/bazel/Dockerfile: Bazelisk 1.29.0 on Debian, with a C++ compiler, Python and Git. Bazel's own image is published for amd64 only. Bazelisk runs the Bazel release the project's .bazelversion names, downloading it on first use; without --cache_dir that is every run. The image takes no --image, and lask sync builds it.

Parameters

  • --cache_dir Host directory mounted at /cache: Bazelisk's downloads (BAZELISK_HOME=/cache/bazelisk) and Bazel's output root (XDG_CACHE_HOME=/cache), so a build is incremental across runs.
  • --with Setups of other tools this environment should also carry.
  • --extra_env Any other variable; below --with and the named parameters.

Returns Runnable: The environment, for command { "bazel" } on ... or $[...].

Image recipe lib/images/bazel/Dockerfile

Command words bazel, bazelisk: import command { "bazel", "bazelisk" } from "tools"

bash
lask eval bazel.env --cache_dir /tmp/cache

lib/bazel.lask

Released under the MIT License.